C# 进入全屏模式时更改页面
我的问题很简单:当用户更改列表框中的选择时,我需要我的应用程序进入全屏模式,但我需要更改显示的页面。我用Silverlight4C# 进入全屏模式时更改页面,c#,.net,silverlight,C#,.net,Silverlight,我的问题很简单:当用户更改列表框中的选择时,我需要我的应用程序进入全屏模式,但我需要更改显示的页面。我用Silverlight4 private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { PresentationPage currentPresentationPage = new PresentationPage();
private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PresentationPage currentPresentationPage = new PresentationPage();
App.Current.RootVisual = currentPresentationPage;
App.Current.Host.Content.IsFullScreen = true;
}
当上面的代码被执行时,应用程序进入全屏,但页面不会改变,它只会调整大小。有人能告诉我那个密码有什么问题吗?谢谢分配应用程序后,您无法更改应用程序.RootVisual。您需要做的是包含一个可以更改其内容的面板,并使该面板成为您的
RootVisual
private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PresentationPage currentPresentationPage = new PresentationPage();
(App.Current.RootVisual as Panel).Children.Clear();
(App.Current.RootVisual as Panel).Children.Add(currentPresentationPage);
App.Current.Host.Content.IsFullScreen = true;
}
然后在应用程序的启动
事件中执行类似操作
Panel grid = new Grid();
grid.Children.Add(new MainPage());
App.Current.RootVisual = grid;