I'm trying to put some content inside my TabItem, but I can't add a container that fills the space of the TabItem. Anything that I add shows up centered.
I'm using a Theme from WPF Toolkit (WhistlerBlue.xaml), so I think that maybe it's that what is causing me this issue.
I cannot remove the Theme, because I need it. At most I could change something in it, but I'm new to WPF, and don't know what should I be changing.
My TabControl looks like this:
<TabControl Margin="0,71.25,0,206.25" Name="tabControl1" TabStripPlacement="Left">
<TabItem Name="tabItem1" FlowDirection="LeftToRight" FontSize="22" Height="200" Width="60" >
<TabItem.Header>
<StackPanel Orientation="Horizontal" >
<Image Height="40" Width="40" Margin="20,0,0,0" VerticalAlignment="Center"></Image>
<TextBlock Margin="15,0,25,0" VerticalAlignment="Center" FontWeight="Bold">
Header
</TextBlock>
</StackPanel>
</TabItem.Header>
<TabItem.Content>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,0" >
<TextBlock>Test</TextBlock>
</StackPanel>
</TabItem.Content>
</TabItem>
</TabControl>
There is similar question, but it don't has the answer: In WPF, how do I get the content of a tabItem to fill available space?
Can someone help me? Thanks.
Ok, I found the answer.
The .xaml of the theme started with these settings for TabItem:
<Style d:IsControlPart="True" TargetType="{x:Type TabItem}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
I've changed Center to Stretch, and the problem was solved.
I really need to learn WPF from a book, instead of just trying things out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With