How to navigate to another project inside same solution

后端 未结 4 515
半阙折子戏
半阙折子戏 2020-12-11 07:14

Hey Hope somebody can help.

I have in group developed on many different projects and we now want to combine these. I therefore include the projects. In the startup p

相关标签:
4条回答
  • 2020-12-11 07:26

    Just remove "/" before "component", like this:

    NavigationService.Navigate(new Uri("/MVVMTestApp;component/View/MainPage.xaml", UriKind.Relative));

    0 讨论(0)
  • 2020-12-11 07:31

    First you have to give reference to the Parent Project then

    you can solve that issue via this line

      NavigationService.Navigate(new
     Uri("/MVVMTestApp;/View/MainPage.xaml", UriKind.Relative));
    
    0 讨论(0)
  • 2020-12-11 07:40

    I think the issue lies in your setup. From your description you name your project MVVMTestApp. I assume this is the start up project. However, your reference is from TestUserControls to MVVMTestApp. This is backwards. I know based on what you are trying to do it seems right, but it is not (unless your project naming is messed up.)

    I suggest you have two projects:

    • MVVMTestApp (Windows Phone 8.1 Universal App which is start up project)
    • MVVMTestApp.Lib (Portable Class that supports Windows Phone 8.1)

    Add a reference from MVVMTestApp to MVVMTestApp.Lib.

    MVVMTestApp will have MainPage.xaml & SecondPage.xaml.

    I suggest that your Lib only has Shared User Controls and not Pages to be navigated to. You can put the user control on SecondPage.

    If you do want to have the SecondPage in your Shared Lib, it will be tougher to handle but still possible. However you won't be able to use the code everyone else has suggested. It doesn't make sense to have the Shared code call MVVMTestApp because then it is not really shareable. What if you had another app that you were sharing with called MVVMTestApp2. Your could would not work if you had MVVMTestApp hard coded even it you could make it work with MVVMTestApp and therefore you would not have any benefit of putting SecondPage in a separate project.

    To have a shareable page that calls back to the app I'm thinking you have two options. You could use Inversion of Control and define INavigationService in your Lib. Then in your MVVMTestApp implement INavigateService and register your implementation with your favorite Ioc container. Then in your Lib you can call a method on your INavigationService. In your MVVMTestApp implementation you can use the code provided in the other posts to navigate to main page.

    Another option would be to expose an event in your Lib. You listen to the event from MVVMTestApp and in the handler you navigate to MainPage like in the other posts. In your Lib you would Raise the event when you want to navigate to MainPage.

    Good luck & Have fun,

    Tom

    0 讨论(0)
  • 2020-12-11 07:43

    Solution 1:

    You use the same type of projects "Windows Phone App". In the solution you need to have one Windows Phone App project and other projects should be of type Windows Phone Class Library.

    Then you can navigate to view in another project inside same solution with this line of code:

     NavigationService.Navigate(new Uri("/MVVMTestApp;/component/View/MainPage.xaml", UriKind.Relative));
    

    Solution 2:

    Go to Configuration Manager in Debug.

    Configuration Manager

    Uncheck Deploy check-box from MVVMTestApp.

    Configuration Manager

    0 讨论(0)
提交回复
热议问题