All, I have the following XAML in my main window

<TabControl ItemsSource="{Binding Path=Workspaces}" 
            Grid.Column="1" 
            Grid.ColumnSpan="3" 
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch" 
            TabStripPlacement="Top">
    <TabControl.ItemContainerStyle>
           <Style TargetType="TabItem">
              <Setter Property="Header" Value="{Binding Path=DisplayName}"/>
              <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
              <Setter Property="VerticalContentAlignment" Value="Stretch"/>
           </Style>
      </TabControl.ItemContainerStyle>    
</TabControl>

this is adding a TabItem with the desired content. But the content is not filling the TabItem/TabPage. Can someone tell me why?

Thanks for your time.

有帮助吗?

解决方案

Converting my comments into an answer:

use Snoop to inspect the Visual Tree at runtime. That should give you a hint about what's going on.

Inspect the View and check what the Alignment properties are for each element inside the Content part of the TabControl. Also check to see if there's some fixed Width or Height on any element, which would prevent it from stretching

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top