开发者

How do I specify common layout markup or rules for controls in XAML?

开发者 https://www.devze.com 2023-01-02 01:00 出处:网络
I\'m a WCF newbie, and I wonder, is it possible to declare in XAML that all开发者_C百科 my TextBoxes should have a height of 26, for example? That is, not to set the height of each item individually?Y

I'm a WCF newbie, and I wonder, is it possible to declare in XAML that all开发者_C百科 my TextBoxes should have a height of 26, for example? That is, not to set the height of each item individually?


You need to define a style for your textbox

This will style the textbox when required

<Style x:Key="myTextBoxStyle">
    <Setter Property="Height" Value="26" />
</Style>

<TextBox Text="Hi" Style="{StaticResource myTextBoxStyle}"/>

This will style all the textboxes

<Style TargetType="{x:Type TextBox}">
    <Setter Property="Height" Value="26" />
</Style>

Put your Style into your resources block

0

精彩评论

暂无评论...
验证码 换一张
取 消