tags:

views:

157

answers:

1

Hi,

I have tabcontrol in my main window. The different 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?

+1  A: 

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.

Reed Copsey
This looks really reasonable. I have read the suggested material plus some other ones, still I am missing something. When I declare. a tap event in my BaseWindow partial class (the main window of my application) and then call it in my user control's codebehind through: SubmitSearch.Click += new RoutedEventHandler(Edit_click);where SubmitSearch is the name of my button (defined in XAML) and Edit_Click is the name of the function, declared in the partial class: public event RoutedEventHandler Tap {//add/remove handler} void Edit_Click(object sender, RoutedEventArgs e) {//code}
Branimir
Should I define edit_click event in the user control and then try to link it to the editbutton_click event in the main window?(I am considerably new to WPF, so excuse me if the questions seems to be dull)
Branimir