从用户控件中导航 WPF 选项卡控件?
我的 WPF 应用程序由一个带有选项卡控件的主窗口组成,该窗口具有一系列选项卡项,每个选项卡项托管一个用户控件。
我希望用户控件之一能够触发应用程序将焦点从当前选项卡更改为其他选项卡。
有没有办法让用户控件触发其选项卡控件容器更改为另一个选项卡项?
My WPF application consists of a main window with a tab control which has a series of tab items, each hosting a user control.
I'd like one of the user controls to be able to trigger the application to change focus from the current tab to a different one.
Is there a way for the user control to trigger its tab control container to change to another tab item?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WPF系统提供了RoatedEvent。可以创建这种特殊类型的事件以供树中的每个元素捕获。通过这种方式,您可以在用户控件内触发事件,并在 TabControl 中捕获它,这将完成您需要的一切。选项卡控件可以捕获事件原因,因为它位于窗口的元素树中。
您可以从这里开始:
http://msdn.microsoft.com/en-us/library/ms742806。 aspx
您需要一个气泡事件。
希望这有帮助。
The WPF system provides the RoutedEvent. This special kind of event can be created to be catched by every element in the tree. With this way you can fire the event inside your user control, and catch it in the TabControl that will do everything you need. The tab control can catch the event cause of it lies in the element's tree of your window.
You can start from here:
http://msdn.microsoft.com/en-us/library/ms742806.aspx
You'll need a Bubble Event.
Hope this helps.
您可以拥有一个与 TabControl 的 SelectedItem 属性绑定的属性。
You can have a property that binds with SelectedItem property of TabControl.