Navigate to Page in another DLL RRS feed

  • Question

  • I am working on an application that I want it to be able to display a page (xaml) from another DLL. I have a common libray I am creating that is used for our WCF services and setting up the users username and password for that service. I don't want to have to copy and paste these pages to all of my applications so I am trying to create this common library.

    The problem I am having is I don't know how to navigate to that page in the other DLL. This is most like a noob question as I am pretty new to Silverlight and WP7 development, but it seems like it should be possible.

    So lets say I have my main application Assembly1 with a PIN.xaml page in it. I want it to be able to call and navigate to the page UserSetup.xaml in Assembly2.dll

    Thanks for any help,
    Monday, November 29, 2010 7:59 PM


All replies

  • You should be able to reference it using a pack Uri.

    Something like this: new Uri("pack://application:,,,/<assembly name>;component/<path to page including file name>");

    Here is a blog post explaining it in detail.

    Also, it looks like in Silverlight, you don't need the "application:,,," declaration.
    Monday, November 29, 2010 8:14 PM
  • It could be me, but I can't get this to work. I will try with a small scale project.
    Monday, November 29, 2010 10:16 PM
  • Can you paste the snippet where you are trying to use it?
    Monday, November 29, 2010 10:25 PM
  • Well I tried many variations of what you described.

    I tried:

    this.NavigationService.Navigate(new Uri("pack://application:,,,/dotTime.WP.JobClockNET;component/UI/JobClockNET.xaml", UriKind.RelativeOrAbsolute));
    this.NavigationService.Navigate(new Uri("/dotTime.WP.JobClockNET;component/UI/JobClockNET.xaml", UriKind.RelativeOrAbsolute));
    this.NavigationService.Navigate(new Uri("dotTime.WP.JobClockNET;component/UI/JobClockNET.xaml", UriKind.RelativeOrAbsolute));

    Nothing was working. dotTime.WP.JobClockNET is the assembly name.
    Tuesday, November 30, 2010 12:36 AM
  • I think when you are using a pack Uri, you don't need the UriKind flag, so try removing that.
    Tuesday, November 30, 2010 4:03 AM
  • Hi,

    This is what I use to do that in my project 
    this.NavigationService.Navigate(new Uri("/MyStuff.BLL;component/Views/MyPage.xaml", UriKind.Relative));

    Where MyStuff.BLL is the name of the assembly

    Kind Regards,
    Nick Harris
    Tuesday, November 30, 2010 4:26 AM
  • So everyone thanks for the help. I found it was a problem between the keyboard and the chair. I renamed my project but never renamed the assembly and default namespace, so it could never find it. When I did:

    this.NavigationService.Navigate(new Uri("/dotTime.WP.JobClockNET;component/UI/Page1.xaml", UriKind.Relative));

    It worked fine. Also sorry for the formatting issue. This editor doesn't like IE9
    Friday, December 3, 2010 7:47 PM
  • You can fix your editor by going to your profile and changing Content Editor to Rich Text.
    Saturday, December 4, 2010 1:06 AM