MainPage.xaml.cs
上传用户:zhouwei825
上传日期:2021-04-15
资源大小:51k
文件大小:2k
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using System.Windows.Interop;//引入命名空间Interop
- namespace FullScreen
- {
- public partial class MainPage : UserControl
- {
- public MainPage()
- {
- InitializeComponent();
- //为全屏添加事件
- Application.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);
- }
- //全屏事件中如果是全屏按钮则显示Full Screen,否则显示Small Screen
- void Content_FullScreenChanged(object sender, EventArgs e)
- {
- Content contentObject = Application.Current.Host.Content;
- if (contentObject.IsFullScreen)
- {
- tbClick.Background = new SolidColorBrush(Colors.Gray);
- tbClick.Content = "Full Screen";
- }
- else
- {
- tbClick.Background = new SolidColorBrush(Colors.Green);
- tbClick.Content = "Small Screen";
- }
- }
- //点击全屏
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- //获取当前Silverlight插件"Content"对象,并设置IsFullScreen属性,点击后全屏,再次点击恢复
- Content contentObject = Application.Current.Host.Content;
- contentObject.IsFullScreen = !contentObject.IsFullScreen;
- }
- }
- }