Language: C#
Silverlight 4 FullScreen Command
public class FullScreenCommand : ICommand { public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { bool isFullScreen = (bool.TryParse(parameter.ToString(), out isFullScreen)) ? isFullScreen : true; return Application.Current.Host.Content.IsFullScreen != isFullScreen; } public void Execute(object parameter) { bool isFullScreen = (bool.TryParse(parameter.ToString(), out isFullScreen)) ? isFullScreen : true; Application.Current.Host.Content.FullScreenOptions = FullScreenOptions.StaysFullScreenWhenUnfocused; Application.Current.Host.Content.IsFullScreen = isFullScreen; } public FullScreenCommand() { Application.Current.Host.Content.FullScreenChanged += (s, e) => { EventHandler handler = CanExecuteChanged; if (handler != null) { handler(this, EventArgs.Empty); } }; } }
Tags:
Description:
Usage: <Button Command="{Binding FullScreenCommand}" CommandParameter="True">Full Screen</Button>
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

