在我的应用程序中,我有一个由一些菜单和菜单项组成的主窗口以及一个TabControl. 在Window.DataContext中,我引用ViewModel了包含ObservableCollection<MyItemModel>名为Items.
MyTabControl.ItemsSource绑定到该Items属性,因此TabItems 动态声明:
<Window>
...
<Window.DataContext>
<local:ViewModel x:Name="model" />
</Window.DataContext>
...
<TabControl ItemsSource="{Binding Items}" />
</Window>
现在我想在 App.xaml 中Style为我的 s 定义一个,如下所示:TabItem
<App.xaml>
...
<Style TargetType="{x:Type TabItem}" x:Key="MyTabItem">
...
</Style>
...
<App.xaml>
并Style在我的Window. 但问题是如果TabControl没有属性ItemsStyle或类似的东西怎么办?