我的WPF应用程序具有少量TabItem的TabControl。 TabItems具有样式触发器,用于在选择MouseOver或TabItem时更改背景。
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Panel.ZIndex" Value="1" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/Resources/tab-active-new.png"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="false">
<Setter Property="Width" Value="130" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/Resources/tab-inactive-new.png"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/Resources/tab-active-new.png"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
其中一个TabItem在Header中有UserControl。如果是MouseEnter事件,它应该打开弹出窗口:
private void OnShowBpPopupCommand(object obj)
{
var popup = this.bpPopup;
popup.IsOpen = true;
}
private void BpPopup_OnClosed(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Popup closed...");
}
有复制问题的步骤:
如何在弹出窗口关闭后(步骤3)强制Tab2根据样式刷新它的外观(将背景改为&#39;非活动&#39;)?
我附加了一个小项目来演示这种行为: Small sample project 感谢。