I have a Grid similar to this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="MyHeader1"/>
<myNamespace:MyRotatedTextBlock
Grid.Row="1" Grid.Column="0" MyText="MyHeader2"/>
</Grid>
and myNamespace:MyRotatedTextBlock is a custom WPF control like this:
<TextBlock Text="{Binding MyText}"
HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock.LayoutTransform>
<RotateTransform Angle="90"/>
</TextBlock.LayoutTransform>
</TextBlock>
The problem is when I open the window, I can't see the second row which contains the rotated text. But if I replace the Height
of the second row (which is set to "Auto"
) with "100"
then I can see that the second row is shown and it contains MyHeader2
You can also derive from TextBlock (instead of userControl) like this:
Then just use the Text property from the TextBlock like this:
EDIT
This way it works as a UserControl as well (because the elementname of the binding is specified explicitly to the user control's name):
Then i code behind use Change Notification by INotifyPropertyChanged (which WPF relies heavy upon ;)