0
votes

I do appreciate any help with this. I have a C# solution called Public Library with different projects in it. One project is called Books.View that I'm working on where this is the main page that loads upon startup and the user does data entry and other tasks from those pages and the other project is called Menu. The Menu project contains application settings that the admin will be able to make changes. I have added a Settings button to the MainWindow.xaml page which is located in my Books.View project and I would like for it to open the MainSettings.xaml located in the Menu project.

I have searched on here the different questions regarding similar questions such as: How to navigate to another project inside same solution

Redirect to another page in different project of same solution

It mentioned adding a reference, so I added a reference to Books.View project to the Menu project. I tried the following code in my settings button in the main project Books.View:

NavigationService.Navigate(new Uri("/Menu;/MainSettings.xaml", UriKind.Relative));

Then I receive an error stating that an object reference is required for the non-static field, method or property ‘System.Windows.Navigation.NavigationService.Navigate(System.Uri)’.

Any assistance with this would be appreciated.

Thank you

1
I think you're looking for thisGregoryHouseMD
@CyberSensei Are you sure that Menu is the parent folder which has the MainSettingx.xaml page in your project?Kulasangar
@Kulasangar Yes the Menu project is the parent folder that contains the page MainSettings.xaml and my project that loads on startup is Books which loads to MainWindow.xaml where the user can do data entry.CyberSensei

1 Answers

1
votes

Review the URI scheme references for XAML in MSDN.

As you are referencing XAML from a separate project, you will have to use fully qualified URI. Assuming your other project Assembly name is Menu, it should be something like:

NavigationService.Navigate(new Uri("pack://application:,,,/Menu;component/MainSettings.xaml", UriKind.Absolute));

Above is based on the reference for XAML URI in separate assembly (which is documented in the msdn link):

pack://application:,,,/ReferencedAssembly;component/Subfolder/ResourceFile.xaml