Silverlight捕獲事件操作方法介紹
Silverlight開發(fā)工具在實(shí)際使用中,有很多功能和使用技巧值得我們?nèi)ド钊氲奶接懀偨Y(jié),以此來方便我們的開發(fā)程序效率。在這里就介紹一下有關(guān)Silverlight捕獲事件的實(shí)現(xiàn)方法。#t#
有時(shí)候,我們需要在全屏模式和普通模式之間切換時(shí),添加一個(gè)其它的代碼,這時(shí)可以使用事件FullScreenChanged。
- public Page()
- {
- InitializeComponent();
- Application.Current.Host.
Content.FullScreenChanged +=
new EventHandler(Content_
FullScreenChanged); - }
實(shí)現(xiàn)Silverlight捕獲事件處理
- private void Content_FullScreen
Changed(object sender, EventArgs e)- {
- Content contentObject = Application.
Current.Host.Content;- if (contentObject.IsFullScreen)
- {
- toggleButton.Background = new
SolidColorBrush(Colors.Green);- toggleButton.Content = "Full
Screen Mode";- }
- else
- {
- toggleButton.Background = new
SolidColorBrush(Colors.Red);- toggleButton.Content =
"Normal Mode";- }
- }
在普通模式和全屏模式之間切換時(shí),改變按鈕的背景色和文字。
完整的Silverlight捕獲事件代碼如下:
- public partial class Page :
UserControl- {
- public Page()
- {
- InitializeComponent();
- Application.Current.Host.Content.
FullScreenChanged += new
EventHandler(Content_FullScreenChanged);- }
- private void toggleButton_Click
(object sender, RoutedEventArgs e)- {
- Content contentObject =
Application.Current.Host.Content;- contentObject.IsFullScreen =
!contentObject.IsFullScreen;- }
- private void Content_FullScreen
Changed(object sender, EventArgs e)- {
- Content contentObject = Application.
Current.Host.Content;- if (contentObject.IsFullScreen)
- {
- toggleButton.Background = new
SolidColorBrush(Colors.Green);- toggleButton.Content = "Full
Screen Mode";- }
- else
- {
- toggleButton.Background = new
SolidColorBrush(Colors.Red);- toggleButton.Content =
"Normal Mode";- }
- }
- }
Silverlight捕獲事件的相關(guān)實(shí)現(xiàn)方法就為大家介紹到這里。