XAML:
<Grid x:Name="LayoutRoot" Background="White"> <!-- 背景代码 --> <Image Source="img/Mac03.jpg" Stretch="UniformToFill"></Image> <!--全屏代码 --> <Button Width="150" Height="60" Content="全屏显示" FontSize="20" Click="Button_Click"/> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { //获取当前Silverlighthot对象 Content contentObj = Application.Current.Host.Content; //修改当前应用程序的全屏属性 contentObj.IsFullScreen = !contentObj.IsFullScreen; }
按F5运行结果: