Answered by:
Navigate from VB page to C# page WPF

Question
-
I am wondering how to make this work in wpf. I have a solution with 2 projects, one in VB and one in C#. How can I navigate from the VB to the C# page and vice versa via a button click. Normally if all the code was in C# I would just do a navigation service like this:
private void Button_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate( new Uri("WpfApp2VB.HomeVb.xaml", UriKind.Relative)); }
However when I do this I get the error
'Cannot locate resource 'wpfapp2vb/homevb.xaml'.
Thanks for any advice
Monday, August 27, 2018 4:57 PM
Answers
-
hello,
if I understand you want to navigate from a WPF CSharp Page to a different wpf page that is located in WPF Vb project, if so all you need to do is referencing the vb project in the c# one, and then navigate to the page object :
using VBPage1 = MVVMPattern.Page1; namespace MVVMPattern_CSharp { /// <summary> /// Interaction logic for Page1.xaml /// </summary> public partial class Page1 : Page { public Page1() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { var page = new VBPage1(); NavigationService.Navigate(page); } } }
Hope it Help;
- Proposed as answer by Cherry BuMicrosoft contingent staff Tuesday, August 28, 2018 5:41 AM
- Marked as answer by Azryel242 Thursday, September 13, 2018 2:35 PM
Monday, August 27, 2018 5:30 PM
All replies
-
hello,
if I understand you want to navigate from a WPF CSharp Page to a different wpf page that is located in WPF Vb project, if so all you need to do is referencing the vb project in the c# one, and then navigate to the page object :
using VBPage1 = MVVMPattern.Page1; namespace MVVMPattern_CSharp { /// <summary> /// Interaction logic for Page1.xaml /// </summary> public partial class Page1 : Page { public Page1() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { var page = new VBPage1(); NavigationService.Navigate(page); } } }
Hope it Help;
- Proposed as answer by Cherry BuMicrosoft contingent staff Tuesday, August 28, 2018 5:41 AM
- Marked as answer by Azryel242 Thursday, September 13, 2018 2:35 PM
Monday, August 27, 2018 5:30 PM -
Hi Azryel242,
You could also check if the relative path is exist.
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Thursday, September 6, 2018 3:05 AM -
hello,
Happy to help;
Good Coding;
Thursday, September 13, 2018 3:11 PM