WEB开发网
开发学院WEB开发ASP.NET silverlight全屏显示图片 阅读

silverlight全屏显示图片

 2012-10-16 12:32:04 来源:WEB开发网   
核心提示: 前台页面代码:<UserControl x:Class="SilverlightApplicationDome.fullScreenDome"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 前台页面代码:

<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;
}
}
}

Tags:silverlight 显示 图片

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接