WPF选项卡控件:如何获取当前选定的选项卡? [英] WPF Tab Control: How do I get the currently selected tab?
本文介绍了WPF选项卡控件:如何获取当前选定的选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的标签SelectionChanged事件(这是正确的情况下,我无法找到一个选项卡更改事件?),我该如何访问新的标签?
另外,从本次活动中的正常code,我该如何访问当前选中的标签之外?
TabControl.SelectionChanged + =新System.Windows.Controls.SelectionChangedEventHandler(TabControl_SelectionChanged);
无效TabControl_SelectionChanged(对象发件人,System.Windows.Controls.SelectionChangedEventArgs E)
{
//如何让访问我的当前选择的选项卡???
}
解决方案
TabControl.SelectedItem是所选择的选项卡。
它转换为一个TabItem的获取属性。
我大多做的是将其绑定到一个视图模型。
In my tab SelectionChanged event (is this the correct event, I can't find a tab changed event?), how do I access the new tab?
Also from outside this event in normal code, how do I access the currently selected tab?
TabControl.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(TabControl_SelectionChanged);
void TabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
//How so access my currently selected tab???
}
解决方案
TabControl.SelectedItem is the selected tab.
cast it to a TabItem to get the properties.
What I mostly do is bind it to a viewmodel.
这篇关于WPF选项卡控件:如何获取当前选定的选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文