Hi,
I'm having issues working out how to achieve the "anchor left and right" property from WinForms in Silverlight.
Here's the XAML showing my issue:
<Grid Width="400" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Some label" />
<TextBox Grid.Column="1" />
<Grid>
What I expect is to have the label on the left and the TextBox
on the right fill up the Grid
.
On the initial load, that's what happens.
However, if I type a very long text in the TextBox
, then it resizes itself to fit its content and becomes bigger than the Grid
.
Is it possible to prevent the TextBox
to resize itself and just make it take as much space as available as when setting anchor left and right in WinForms?
Maybe there's an easy property to set that I completely missed.
EDIT: Apologies, I missed a crucial element in the XAML (the Grid.Column=
bit) :(
I DO know the sizing properties of SL (Star
, Auto
, Pixel
).
My mistake made it unclear what I wanted to achieve.
In the corrected example, the TextBox
will fill the Grid
but typing a very long text will make it grow beyond the Grid
's width.
Cheers.