0
我希望能夠判斷哪個選項卡是Microsoft功能區中的活動選項卡,以相應地更改內容顯示。檢測Microsoft Ribbon中的活動選項卡是否已更改
我該怎麼做?
這就是我想出了:
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)
{
}
,但必須有一個更好的方式來做到這一點。在那兒?
絕妙的主意!謝謝! – 2012-04-12 12:52:22