开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜