<UserControlx:class= "Fullscreen.mainpage"xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d= "http://schemas.microsoft.com/expression/blend/2008"XMLNS:MC= "http://schemas.openxmlformats.org/markup-compatibility/2006"mc:ignorable= "D"D:designheight= "+"D:designwidth= "The "> <Gridx:name= "LayoutRoot"Background= "White"> <BorderHorizontalAlignment= "Left"VerticalAlignment= "Top"Padding= "Ten"borderthickness= "1"Cornerradius= "4"Background= "#7F000000"> <StackPanel> <StackPanelOrientation= "Horizontal"> <TextBlockText= "Total CPU consumption:"textwrapping= "Wrap"D:layoutoverrides= "Height"Foreground= "White"></TextBlock> <TextBlockx:name= "Txtcpuload"textwrapping= "Wrap"D:layoutoverrides= "Height"Foreground= "White"></TextBlock> </StackPanel> <StackPanelOrientation= "Horizontal"> <TextBlockText= "Current CPU consumption:"textwrapping= "Wrap"D:layoutoverrides= "Height"Foreground= "White"></TextBlock> <TextBlockx:name= "Txtslcpuload"textwrapping= "Wrap"D:layoutoverrides= "Height"Foreground= "White"></TextBlock> </StackPanel> </StackPanel> </Border> <ButtonContent= "normal"Height= "+"HorizontalAlignment= "Left"Margin= "152,123,0,0"Name= "Btnfull"VerticalAlignment= "Top"Width= "The "Click= "Btnfull_click" /> </Grid></UserControl>
View Code
CS Code
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Net;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Animation;usingSystem.Windows.Shapes;usingSystem.Windows.Threading;namespacefullscreen{ Public Partial classMainpage:usercontrol {Analytics myanalytics; PublicMainPage () {InitializeComponent (); Loaded+=NewRoutedeventhandler (mainpage_loaded); Application.Current.Host.Content.FullScreenChanged+=NewEventHandler (content_fullscreenchanged); } voidMainpage_loaded (Objectsender, RoutedEventArgs e) {Myanalytics=NewAnalytics (); DispatcherTimer Timer=NewDispatcherTimer (); Timer. Interval= Timespan.fromseconds (1); Timer. Tick+=NewEventHandler (Timer_tick); Timer. Start (); } voidTimer_tick (Objectsender, EventArgs e) {Txtcpuload.text=myAnalytics.AverageProcessorLoad.ToString (); Txtslcpuload.text=myAnalytics.AverageProcessLoad.ToString (); } voidContent_fullscreenchanged (Objectsender, EventArgs e) { varContent =Application.Current.Host.Content; if(content. IsFullScreen) {Btnfull.background=NewSolidColorBrush (Colors.yellow); Layoutroot.background=NewSolidColorBrush (Colors.yellow); } Else{Btnfull.background=NewSolidColorBrush (colors.red); Layoutroot.background=NewSolidColorBrush (colors.red); } } Private voidBtnfull_click (Objectsender, RoutedEventArgs e) { varContent =Application.Current.Host.Content; if(!content. IsFullScreen) {content. IsFullScreen= !content. IsFullScreen; Btnfull.content="Restore"; } Else{content. IsFullScreen= !content. IsFullScreen; Btnfull.content="Full Screen"; } } }}
View Code
Silverlight fullscreen fullscreen