这是我的风格.xaml:
<Style TargetType="TabItem" x:Key="gMetroTabItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="6,2,6,2" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="MinWidth" Value="5" />
<Setter Property="MinHeight" Value="5" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type local:TabItemHeaderData}">
<StackPanel>
<TextBlock x:Name="rootText" Text="{Binding tabText}" FontSize="26.67"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
这是我的TabItemHeaderData:
public class TabItemHeaderData
{
public String tabText { get; set; }
public object Content { get; set; }
public object tabIconOff { get; set; }
public object tabIconOn { get; set; }
}
我的问题是:样式的代码似乎是正确的,我将属性tabText绑定到Text,但是如何从我的窗口代码发送TabItemHeaderData?实际上是这样的:
<TabItem Style="{StaticResource gMetroTabItem}">
<Grid>
...
</Grid>
</TabItem>