C#C
C#3y ago
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>


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));
}


normally one would use a template binding in the style but i cant do that while keeping the style generic
Was this page helpful?