当前位置:编程学习 > C#/ASP.NET >>

silverlight全屏显示图片

前台页面代码:
 
<UserControl x:Class="SilverlightApplicationDome.fullScreenDome"
    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="300" d:DesignWidth="400">
   
    <Grid x:Name="LayoutRoot" Background="White">
        <Image Name="full" Source="img/3.jpg" Stretch="UniformToFill"></Image>
        <Button Name="btnFull" Width="120" Height="80"  Content="全屏显示" FontSize="24" Click="btnFull_Click"></Button>
    </Grid>
</UserControl>

其实很简单,我们只需要引用命名空间,System.Windows.Interop就可以了。
后台代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interop;
namespace SilverlightApplicationDome
{
    public partial class fullScreenDome : UserControl
    {
        public fullScreenDome()
        {
            InitializeComponent();
        }
        private void btnFull_Click(object sender, RoutedEventArgs e)
        {
            Content contentObject = Application.Current.Host.Content;
            contentObject.IsFullScreen = !contentObject.IsFullScreen;
        }
    }

补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,