简体   繁体   English

如何从UserControl事件更改WPF TabControl的TabItem?

[英]How to change TabItem of WPF TabControl from the UserControl Event?

In my project ie in WPF there is TabControl with 4 tab. 在我的项目中,即在WPF中,有4个选项卡的TabControl。 On the 4th Tab a UserControl that hold a DataGrid. 在第四个选项卡上,一个拥有DataGrid的UserControl。 I want to navigate the tha TabItem 1 ie TabIndex 0 when click on the Row of DataGrid 我想在单击DataGrid的行时浏览Tha TabItem 1即TabIndex 0

Before above when my DataGrid is directly hosted on the TabItem 4 not a UserControl, I am able to navigate the TabItem but when I put the DataGrid in the UserControl and set this UserControl to TabItem 4 then not able to navigate when Click on the Row Of DataGrid. 在上面之前,当我的DataGrid直接托管在TabItem 4而不是UserControl上时,我能够导航TabItem,但是当我将DataGrid放在UserControl中并将此UserControl设置为TabItem 4时,当单击Row Of数据网格。

Please help me... 请帮我...

As a simple solution : 作为一个简单的解决方案:

Add an Event to your UserControl like "IClickOnRowEvent". 向您的UserControl添加一个事件,例如“ IClickOnRowEvent”。 Your control onwning tabControl has to subcribe to it and then do navigation logic 您的控件所有者tabControl必须订阅它,然后执行导航逻辑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM