XAML Navigation and Control Access

Can someone provide direction on how I might achieve the following

I have an empty Main Page (PageMain.xml) in which I have navigated to another page file (in an external project). Within PageMain I would like to access controls on this new page which I have just navigated. I haven't been able to find resources yet.

Any guidance or suggestions would be greatly appreciated. Thanks.



Answer this question

XAML Navigation and Control Access

  • DanMeyers

    How do you navigate in the main page Are you using a Frame If yes, you can use Frame.Content to have access to the root element.


  • Abhas Kumar

    In your XAML, you can add x:FieldModifier to the elements you want to make public.

    Example:

    <Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Button x:FieldModifier="public" Name="MyButton">

    Then you won't have to make your own getters.

    The FieldModifier is language specific, so choose modifiers appropriate to the language of your codebehind.



  • Chris Jiang

    In the app I set the StartupUri to my blank page. After it's loaded I call my Init method which has the following:

    NavigationWindow navWindow;

    navWindow = (NavigationWindow)App.Current.MainWindow;

    UiPageIUIMain pageIUIMain = new UiPageIUIMain(); <-- This is defined in an external project

    pageIUIMain.InitializeComponent();

    navWindow.Content = pageIUIMain;

    I ended up adding get methods to the UiPageIUIMain class so I can call them from my other project.

    public Frame getFrmMainBar

    { get { return FrameMenuBar; } }

    Please advise if this is appropriate or if you can recommend alternate/better solutions. Thanks.


  • thomaskremmel

    Dave,

    Any relation to Rob



  • XAML Navigation and Control Access