开发者

Display another layout on button click

开发者 https://www.devze.com 2023-01-29 00:15 出处:网络
I have a layout MainPage.xaml in which i have images and a button. On click of button 开发者_C百科i want another layout Top.xaml to be displayed such that MainPage.xaml becomes invisible.

I have a layout MainPage.xaml in which i have images and a button. On click of button 开发者_C百科i want another layout Top.xaml to be displayed such that MainPage.xaml becomes invisible. I am new to Windows phone 7? Can someone help out?


This depends on what you are looking to do. You can either navigate from MainPage.xaml to Top.xaml using

NavigationService.Navigate(new Uri("Top.xaml", UriKind.Relative));

If you just want to switch between layouts (i.e. not navigate to a whole new page) you can implement both layouts in one XAML page and switch between them using VisualStateManager. Create one state called "Main" and other called "Top" then switch from one to the other as follows:

VisualStateManager.GoToState(this, "Top", true);

It all depends on how you want to layout your code and also how you expect the back button to work. Using states means you will have to handle the back button yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消