Reputation: 15
For example:
<TextBox x:Name="TextBox1" Text="A text" Width="Auto"/>
Instead of setting the width as Auto, I want to set it as 2*Auto, how to achieve it in XAML directly?
Upvotes: 0
Views: 1214
Reputation: 959
How about setting it through column definitions of your grid? Then set HorizontalAlignment="Stretch" of your TextBox
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" x:Name="TextBox1" Text="A text" Height="50" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
</Grid>
Upvotes: 2
Reputation: 354536
I'm not quite sure what your aim is here. Usually you let a container around the text box take care of that for you. One (hacky) way might be to use a grid with HorizontalContentAlignment=Stretch, and place a second TextBox in there with the text doubled and Visibility=Hidden.
Upvotes: 0