none
Navigating to page in another project.

    Question

  • I have multiple projects in my solution and control instantiated in project 1 wants to navigate to a page placed in project 2. Anyone know how to put the right uri together?

     

    Thanks

    Wednesday, April 4, 2007 9:29 AM

Answers

  • Do you have the xaml file at the root of your project? Do you give the correct assembly name?

     

    I just created an application with a window containing a frame (in a project called WindowApplication1, how inventive)

    <Window x:Class="WindowsApplication1.Window1"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="WindowsApplication1" Height="300" Width="300"

        >

        <Grid>

            <Frame Source="/CustomControlLibrary1;component/MyPage.xaml" />

        </Grid>

    </Window>

     

    I then created a dll in which i put a MyPage.xaml file (and the project is called CustomControlLibrary1). Here's the code.

    <Page x:Class="CustomControlLibrary1.MyPage"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MyPage"

        >

        <Grid>

            <TextBlock>Loaded</TextBlock>

        </Grid>

    </Page>

     

    And finally I reference the CustomControlLibrary1 from the WindowApplication1 project. Run the application, and "Loaded" shows up on the screen. So it does work Smile

    Wednesday, April 4, 2007 11:54 AM

All replies

  • Hi,

     

    Have a look at the Pack URIs in Windows Presentation Foundation  page, it's all explained. If from your application you reference an assembly named Assembly2 and you want to navigate to a page in that assembly called myPage.xaml, the uri would like like this:

    Uri uri = new Uri("/Assembly2;component/myPage.xaml", UriKind.Relative");

    Wednesday, April 4, 2007 10:35 AM
  • yes i did this before, and this approach is definitely not working, IOException is raised with following: "Cannot locate resource myPage.xml"

     

     

    Wednesday, April 4, 2007 11:39 AM
  • Do you have the xaml file at the root of your project? Do you give the correct assembly name?

     

    I just created an application with a window containing a frame (in a project called WindowApplication1, how inventive)

    <Window x:Class="WindowsApplication1.Window1"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="WindowsApplication1" Height="300" Width="300"

        >

        <Grid>

            <Frame Source="/CustomControlLibrary1;component/MyPage.xaml" />

        </Grid>

    </Window>

     

    I then created a dll in which i put a MyPage.xaml file (and the project is called CustomControlLibrary1). Here's the code.

    <Page x:Class="CustomControlLibrary1.MyPage"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MyPage"

        >

        <Grid>

            <TextBlock>Loaded</TextBlock>

        </Grid>

    </Page>

     

    And finally I reference the CustomControlLibrary1 from the WindowApplication1 project. Run the application, and "Loaded" shows up on the screen. So it does work Smile

    Wednesday, April 4, 2007 11:54 AM
  • yes you are right, i mistyped a path

     

    thank you

    Wednesday, April 4, 2007 12:14 PM