0

How does one set a value (similar to #define) that sets two different standard button widths (MinWidth) ... perhaps using application.resources? Buttons later use one of the standards defines.

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
bhs67
  • 19
  • 4

1 Answers1

0

If I understand the question, you could define multiple button styles in a resource dictionary, and then set your button's style to the desired one.

In resource definition:

<sys:Double x:Key="Key_Button_Wide">200</sys:Double>

    <Style x:Key="ButtonWide" TargetType="{x:Type Button}">
        <Setter Property="Control.Width" Value="{DynamicResource Key_Button_Wide}" />
    </Style>

Then your button could use this style when you define it:

<Button x:Name="MyButton" Style="{DynamicResource ButtonWide}" />

You could also bind your width to a static property, check out this post: Binding to static property

Community
  • 1
  • 1
Yves Rochon
  • 1,332
  • 14
  • 27