© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
Indeed

❔ WPF Border TemplateBinding

Hi!
I've created such style for most of my controls to have rounded corners
however i would like for them to be modifiable

ive written an attached property however i do not have a way to bind it

style
            <Style x:Key="RoundBorder">
                <Style.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="3" />
                    </Style>
                </Style.Resources>
            </Style>
            <Style x:Key="RoundBorder">
                <Style.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="3" />
                    </Style>
                </Style.Resources>
            </Style>


property
public static class ThemeProperties {
    public static float GetRoundedCornerRadius(DependencyObject obj) {
        return (float)obj.GetValue(RoundedCornerRadiusProperty);
    }
    public static void SetRoundedCornerRadius(DependencyObject obj, float value) {
        obj.SetValue(RoundedCornerRadiusProperty, value);
    }
    public static readonly DependencyProperty RoundedCornerRadiusProperty =
        DependencyProperty.RegisterAttached("RoundedCornerRadius", typeof(float), typeof(ThemeProperties), new PropertyMetadata(3f));
}
public static class ThemeProperties {
    public static float GetRoundedCornerRadius(DependencyObject obj) {
        return (float)obj.GetValue(RoundedCornerRadiusProperty);
    }
    public static void SetRoundedCornerRadius(DependencyObject obj, float value) {
        obj.SetValue(RoundedCornerRadiusProperty, value);
    }
    public static readonly DependencyProperty RoundedCornerRadiusProperty =
        DependencyProperty.RegisterAttached("RoundedCornerRadius", typeof(float), typeof(ThemeProperties), new PropertyMetadata(3f));
}


normally one would use a template binding in the style but i cant do that while keeping the style generic
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ WPF Border Button
C#CC# / help
3y ago
WPF Border around transparent image
C#CC# / help
4y ago
WPF : The ItemsControl border has extra lines appearing.
C#CC# / help
11mo ago