如何设置选择的背景Tabitem的颜色WPF?

时间:2018-11-25 11:35:16

标签: c# wpf vb.net visual-studio tabcontrol

如何设置所选背景Tabitem的颜色? 文本的颜色改变,背景不改变:

Sub changebackgroundcolorwhenselected(ByVal tabitem1 As TabItem)
    tabitem1.Background = Brushes.DeepSkyBlue
    tabitem1.Header = "House"
    Dim tr As New Trigger()
    tr.Property = TabItem.IsSelectedProperty
    tr.Value = True
    Dim h As New Setter(TabItem.BackgroundProperty, Brushes.Red) '?
    tr.Setters.Add(h)
    Dim h2 As New Setter(TabItem.ForegroundProperty, Brushes.Green)
    tr.Setters.Add(h2)
    Dim x As New Style
    x.Triggers.Add(tr)
    tabitem1.Style = x
End Sub

0 个答案:

没有答案