Note that there are some explanatory texts on larger screens.

plurals
  1. POCan you databind to CornerRadius via WPF Styles?
    primarykey
    data
    text
    <p>I have a Button style and can't seem to property databind the border's CornerRadius property to the template. This is a dependency property, so it should be data bindable. I wonder if I'm missing the right XAML syntax to use?</p> <pre><code>&lt;Style TargetType="{x:Type Button}" BasedOn="{x:Null}"&gt; &lt;Setter Property="FocusVisualStyle" Value="{DynamicResource MyButtonFocusVisual}"/&gt; &lt;Setter Property="Background" Value="{DynamicResource MyButtonBackgroundBrush}"/&gt; &lt;Setter Property="Foreground" Value="{DynamicResource MyButtonForegroundBrush}"/&gt; &lt;Setter Property="BorderBrush" Value="{DynamicResource MyButtonBorderBrush}"/&gt; &lt;Setter Property="BorderThickness" Value="3"/&gt; &lt;Setter Property="FontFamily" Value="Segoe UI"/&gt; &lt;Setter Property="FontSize" Value="14" /&gt; &lt;Setter Property="CornerRadius" Value="2" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;!-- We use Grid as a root because it is easy to add more elements to customize the button --&gt; &lt;Grid x:Name="Grid"&gt; &lt;Border x:Name="Border" CornerRadius="{TemplateBinding CornerRadius}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Both and CornerRadius="{TemplateBinding CornerRadius}" give me the error "CornerRadius is not recognized or is not accessible". </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload