How to Access Child Page Source Control / Element from MainWindow

Jun 4, 2013 at 9:13 AM
I have MainWindow with the following code
<mui:LinkGroup DisplayName="Survei Tanaman Pangan">
        <mui:LinkGroup.Links>
            <mui:Link DisplayName="Home" Source="/Pages/PageHome.xaml" />
            <mui:Link DisplayName="Blok1" Source="/Pages/PageBlok1.xaml" />
            <mui:Link DisplayName="Blok2 dan Blok3" Source="/Pages/PageBlok2.xaml" />
            <mui:Link DisplayName="Blok4" Source="/Pages/PageBlok4.xaml" />
            <mui:Link DisplayName="Blok4 Hal 2" Source="/Pages/PageBlok4Hal2.xaml" />
            <mui:Link DisplayName="Blok5" Source="/Pages/PageBlok5.xaml" />
        </mui:LinkGroup.Links>
    </mui:LinkGroup>
and I have button in PageHome like this
 <StackPanel Orientation="Horizontal">
    <mui:ModernButton x:Name="ButtonSave" Content="Save Data" />
 </StackPanel>
How I can access this button from MainWindow.xaml.cs file?? Maybe some kind of this ?
public MainWindow()
    {
        InitializeComponent();
        Button ButtonSave =(Button) FindName("ButtonSave");
        ButtonSave.Click += Button_Save_Click;
Coordinator
Jun 5, 2013 at 10:05 AM
You shouldn't access the button from the main window, it's technically feasible, but not recommended. Use the PageHome.xaml.cs code behind to wire up your event handlers.
Jun 16, 2013 at 4:42 AM
kozw wrote:
You shouldn't access the button from the main window, it's technically feasible, but not recommended. Use the PageHome.xaml.cs code behind to wire up your event handlers.
I want to navigate through main window because I use many control to easily navigate.. Could you give me an example how I can do that?
Coordinator
Jun 18, 2013 at 7:08 PM
Not sure what you mean with 'I use many control to easily navigate'. Can you elaborate?
Jun 20, 2013 at 1:29 AM
I want to make navigate from one page to another modern page which I want to automatically focus in one of control in selected page. And I want to navigate to another page to from dialog when I click to moderndialog. How I can achieve this?
Jun 20, 2013 at 7:24 AM
SaveButton:
I'd suggest to use MVVMLight. When clicking the Button send a message. Register a handler for this message in the MainWindow's ViewModel (or code behind).

Navigating and setting focus:
URL navigation with fragment. Implement IContent in the destination page, get the Fragment out of OnFragmentNavigation's e.Fragment. If you already know the focus destination at design time, then you don't need the fragment, just act in OnNavigatedTo.

"click to moderndialog":
I don't understand the meaning.
Jun 21, 2013 at 2:39 AM
Sory for not clear question I did. I mean I want to navigate to another page from event in button in moderndialog.. How I can do that?
Jun 23, 2013 at 4:48 AM
Edited Jun 23, 2013 at 4:49 AM
NavigationCommand.GoToPage.Execute("/yourpage.xaml", null);
That's the command which navigates to another page, if you want to navigate to another page located inside a separate modern window, you'll need to use a ViewModel which exposes a SelectedLink property to do it.
Jun 25, 2013 at 12:30 PM
Thanks.. for the response I have clear this issue by storing object as static so I can call it in every place