如何将 TabControl header 的文本左对齐?
How to align the text of the TabControl header to the left?
我已经尝试了 HorizontalAligenment Left 但是它不起作用,StackPanel 仍然在中间。
<TabControl x:Name="ControlTC" Grid.Row="1" HorizontalAlignment="Stretch" Margin="0,0,5,5" VerticalAlignment="Stretch" SelectionChanged="ControlTC_SelectionChanged" >
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="FontFamily" Value="Yu Gothic UI Semibold"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</TabControl.Resources>
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal" >
<Image Name="DeviceInfo" VerticalAlignment="Center" Width="20" Height="20"/>
<TextBlock Text="DeviceInfo" VerticalAlignment="Center" Margin="6,0,0,0" FontSize="13" FontFamily="Noto Sans Mono CJK KR Bold"/>
</StackPanel>
</TabItem.Header>
<Grid Background="#FFFFFFFF">
<cr:ElectricSignPanel x:Name="ElectricSign"></cr:ElectricSignPanel>
</Grid>
</TabItem>
</TabControl>
这可能有帮助
<TabControl TabStripPlacement="Left" HorizontalContentAlignment="Left" >
<TabItem HorizontalAlignment="Left" HorizontalContentAlignment="Left" Header="Header 1">
<TabItem.Content>
Test
</TabItem.Content>
</TabItem>
</TabControl>
我已经尝试了 HorizontalAligenment Left 但是它不起作用,StackPanel 仍然在中间。
<TabControl x:Name="ControlTC" Grid.Row="1" HorizontalAlignment="Stretch" Margin="0,0,5,5" VerticalAlignment="Stretch" SelectionChanged="ControlTC_SelectionChanged" >
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="FontFamily" Value="Yu Gothic UI Semibold"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</TabControl.Resources>
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal" >
<Image Name="DeviceInfo" VerticalAlignment="Center" Width="20" Height="20"/>
<TextBlock Text="DeviceInfo" VerticalAlignment="Center" Margin="6,0,0,0" FontSize="13" FontFamily="Noto Sans Mono CJK KR Bold"/>
</StackPanel>
</TabItem.Header>
<Grid Background="#FFFFFFFF">
<cr:ElectricSignPanel x:Name="ElectricSign"></cr:ElectricSignPanel>
</Grid>
</TabItem>
</TabControl>
这可能有帮助
<TabControl TabStripPlacement="Left" HorizontalContentAlignment="Left" >
<TabItem HorizontalAlignment="Left" HorizontalContentAlignment="Left" Header="Header 1">
<TabItem.Content>
Test
</TabItem.Content>
</TabItem>
</TabControl>