【发布时间】:2011-01-08 04:43:27
【问题描述】:
在我的应用程序中,我有一个由一些菜单和菜单项以及TabControl 组成的主窗口。在Window.DataContext 中,我引用了我的ViewModel,其中包含一个名为Items 的ObservableCollection<MyItemModel> 类型的属性。
我的TabControl.ItemsSource 绑定到Items 属性,因此TabItems 被动态声明:
<Window>
...
<Window.DataContext>
<local:ViewModel x:Name="model" />
</Window.DataContext>
...
<TabControl ItemsSource="{Binding Items}" />
</Window>
现在我想在 App.xaml 中为我的TabItems 定义一个Style,如下所示:
<App.xaml>
...
<Style TargetType="{x:Type TabItem}" x:Key="MyTabItem">
...
</Style>
...
<App.xaml>
在我的Window 中使用这个Style。但问题是如果TabControl 没有ItemsStyle 或类似的属性怎么办?
【问题讨论】:
标签: wpf styles tabcontrol tabitem