public
MainPage()
{
InitializeComponent();
//在全屏或嵌入之间切换时,会触发一个事件,可以利用这个事件进行一些操作
Application.Current.Host.Content.FullScreenChanged +=
new
EventHandler(Content_FullScreenChanged);
}
private
void
button1_Click(
object
sender, RoutedEventArgs e)
{
//实现全屏模式需要引用其页面宿主程序,并设置为true
//Application.Current.Host.Content.IsFullScreen = true;
//如果想实现单按钮的两种模式之间切换,如下设置就可以了
Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
}
//全屏时触发的事件
private
void
Content_FullScreenChanged(
object
sender, EventArgs e)
{
Content contentObject = Application.Current.Host.Content;
if
(contentObject.IsFullScreen)
{
button1.Content =
"全屏模式"
;
}
else
{
button1.Content =
"嵌入模式"
;
}
}