Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 进入全屏模式时更改页面_C#_.net_Silverlight - Fatal编程技术网

C# 进入全屏模式时更改页面

C# 进入全屏模式时更改页面,c#,.net,silverlight,C#,.net,Silverlight,我的问题很简单:当用户更改列表框中的选择时,我需要我的应用程序进入全屏模式,但我需要更改显示的页面。我用Silverlight4 private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { PresentationPage currentPresentationPage = new PresentationPage();

我的问题很简单:当用户更改列表框中的选择时,我需要我的应用程序进入全屏模式,但我需要更改显示的页面。我用Silverlight4

 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;