开发者

WPF - how to call mainwindow tabitems from inside a control

I have tabcontrol in my main window. The different开发者_如何学Go tbas I create with custom controls (for edit, addition etc.). I want to be able to address the other tabs from inside the control, so that when, for example, I click submit at some of the forms, it activates a specific other tab.

I tried with

       BaseWindow n = new BaseWindow();
        n.SearchTab.Visibility = System.Windows.Visibility.Hidden;

Still obviously this does not do the trick.

Any ideas?


I would consider reworking your architecture here.

One option would be to have your custom controls (UserControls?) inside of the tabs expose a Routed Event. Your main Window could then subscribe to the routed events (at the main window's level) and handle the application navigation.

This is much cleaner, from a design standpoint, since the user controls don't need to know about other controls, they just say "I hit this button", and the main window decides that event means to show the other window. If you ever change your tabs around, you won't break everything, since this keeps the coupling lower between your tabs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜