Gart
Gart

Reputation: 2336

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 my TextBoxes should have a height of 26, for example? That is, not to set the height of each item individually?

Upvotes: 0

Views: 69

Answers (1)

Amsakanna
Amsakanna

Reputation: 12954

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

Upvotes: 1

Related Questions