Silverlight捕獲事件操作方法介紹
作者:佚名
當我們在進行全屏模式和普通模式之間進行切換的時候,需要進行Silverlight捕獲事件來獲得功能的實現。大家可以通過本文介紹的內容提高對這款工具的認識。
Silverlight開發工具在實際使用中,有很多功能和使用技巧值得我們去深入的探討,總結,以此來方便我們的開發程序效率。在這里就介紹一下有關Silverlight捕獲事件的實現方法。#t#
有時候,我們需要在全屏模式和普通模式之間切換時,添加一個其它的代碼,這時可以使用事件FullScreenChanged。
- public Page()
- {
- InitializeComponent();
- Application.Current.Host.
Content.FullScreenChanged +=
new EventHandler(Content_
FullScreenChanged); - }
實現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";- }
- }
在普通模式和全屏模式之間切換時,改變按鈕的背景色和文字。
完整的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捕獲事件的相關實現方法就為大家介紹到這里。
責任編輯:曹凱
來源:
博客園