How to navigate wpf window1.xaml form to Page.xaml in button click event

Posted by Gow.Net under WPF on 7/25/2013 | Points: 10 | Views : 54709 | Status : [Member] | Replies : 6
HI

i have two xaml file in my wpf application window.xaml and page.xaml.My question is click button in window.xaml oopen page.xaml. how can i write thate code for button click event?

gowthaman8870226416


Responses

Posted by: Jitendrasoft09 on: 7/25/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Dear,

You add following code for opening one xaml to another.

private void Button_Click(object sender, RoutedEventArgs e)

{
Button theButton = sender as Button;
string url = theButton.Tag.ToString();

this.navFrame.Navigate(new Uri(url, UriKind.Relative));
}


Refer below link for information-
http://stackoverflow.com/questions/2709274/how-can-i-navigate-one-xaml-page-to-another

Jitendra Kumar
If my post helps you, plz mark as an answer.

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 7/25/2013 [Member] Starter | Points: 25

Up
0
Down
hi,
refer this link i hope it will clear your doubt
http://theprofessionalspoint.blogspot.in/2013/05/difference-between-window-and-page.html

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 8/3/2013 [Member] Starter | Points: 25

Up
0
Down
hi Jitendrasoft09 and Aswinialuri@Gmail.Com

Thanks for yours reply but i got below error how can i solve this
Assembly 'System.Windows.Controls.Navigation' was not found.Verify that you are not missing an assembly reference.

gowthaman8870226416

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jitendrasoft09 on: 8/3/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Gow,

Do not keep file name as existing with Microsoft visual studio assembly. Keep exact name of form that will work perfectly. You add the following code to open one xaml to another xaml.

window.xaml

 private void button1_Click(object sender, RoutedEventArgs e)

{
page1 p = new page1();
p.Show();

}


Hope you have understood.


Jitendra Kumar
If my post helps you, plz mark as an answer.

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 8/5/2013 [Member] Starter | Points: 25

Up
0
Down
you need to add reference
using System.Windows.Navigation;

and then
this.NavigationService.Navigate(new Uri(<<Page1.xaml>>, UriKind.Relative));

Regards,
Jayakumar Selvakani

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/5/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
You should derive the Window.xaml from NavigationWindow to support that type of navigation. Same is explained clearly in the follwoing link
http://mrbool.com/visual-studio-wpf-lesson-3-page-navigation-service-in-wpf-application-using-vs-net/14329

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response