Welcome

首页 / 软件开发 / Silverlight / 在SharePoint页面嵌入简单的Silverlight程序

在SharePoint页面嵌入简单的Silverlight程序2014-12-081. 打开VS,新建项目Silverlight。

2. 命名MyBannerAd,确定。

3. 清除选项“在新网站中承载Silverlight应用程序”,确定。

4. 右击项目添加文件夹Images。右击Images添加现有项,添加两个图片gear.png和branded.png。

5. 右击MainPage.xaml文件,选择视图设计器。编辑代码:

<UserControl x:Class="MyBannerAd.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="700" d:DesignWidth="400"><Grid x:Name="LayoutRoot" Height="700" Width="400"><RectangleMargin="66,42,152,20"Stroke="#FF000000"RadiusX="0"RadiusY="0"><Rectangle.Fill><LinearGradientBrushx:Name="MRGB"EndPoint="0.5,1"StartPoint="0.5,0"><GradientStop Color="#FF000000" Offset="0" /><GradientStop Color="#FF5E0805" Offset="0.478" /></LinearGradientBrush></Rectangle.Fill></Rectangle><Image Margin="48,49,128,20"x:Name="brandedImage"Source="Images/brand.png" /><TextBlock x:Name="titleTextBlock"Margin="75,59,161,0"FontFamily="Arial"FontSize="24"FontWeight="Bold"TextWrapping="Wrap"Foreground="#FFF9F4F4"TextAlignment="Center"Height="56"VerticalAlignment="Top"Text="Life Without Borders"></TextBlock><TextBlock x:Name="footerTextBlock"Margin="75,564,161,0"FontFamily="Arial"FontSize="16"FontWeight="Bold"TextWrapping="Wrap"Foreground="#FFF9F4F4"TextAlignment="Center"Height="56"VerticalAlignment="Top"Text="Fabrikam, Inc."></TextBlock><Image Margin="121,559,216,14"x:Name="gearImage"Source="Images/gear.png" /></Grid></UserControl>

6. 你的Silverlight应用程序应该是这样:

7. 按下F5 测试是否正常。

8. 在SharePoint站点新建文档库XAPS,找到你创建的Silverlight应用程序里的MyBannerAd.xap,并上传。

9. 在SharePoint Designer中新建Web Part页面,添加Silverlight Web Part。设置属性。

10. 在浏览器中预览。

作者:csdn博客 张世辉