我想知道,哪个选项卡是 Microsoft 功能区中的活动选项卡,以相应地更改内容呈现。
我怎样才能做到这一点?
这是我想出的:
public MainWindow()
{
InitializeComponent();
// Insert code required on object creation below this point.
new Thread(() =>
{
int lastIndex = int.MinValue;
while (true)
{
Thread.Sleep(100);
int newIndex = -1;
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(() =>
{
newIndex = Ribbon.SelectedIndex;
}));
if (newIndex != lastIndex)
{
lastIndex = newIndex;
var index = lastIndex;
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) (() =>OnCurrentTabChanged(index)));
}
}){ IsBackground=true}.Start();
}
void OnCurrentTabChanged(int tabIndex)
{
}
但必须有更好的方法来做到这一点。在那儿?