[索引页]
[源码下载]
作者:webabcd
介绍
Silverlight 2.0 提示和技巧系列
在线DEMO
http://www.voidcn.com/article/p-ounmxjds-tq.html
示例
1、在 Silverlight 程序中加载指定的 xap 文件
LoadXap.xaml
[源码下载]
作者:webabcd
介绍
Silverlight 2.0 提示和技巧系列
- 加载XAP - 加载指定的 xap 文件到当前的 Silverlight 应用程序中
- 加载XAML - 加载指定的 xaml 文件到当前的 Silverlight 应用程序中
- 加载DLL - 加载指定的 dll 文件,并调用其中的方法或加载其中的控件
- AppManifest.xaml文件说明 - 简要说明 AppManifest.xaml 文件内容中各个节点的作用
- 自定义鼠标指针 - 实现自定义的鼠标指针,即鼠标跟随
在线DEMO
http://www.voidcn.com/article/p-ounmxjds-tq.html
示例
1、在 Silverlight 程序中加载指定的 xap 文件
LoadXap.xaml
<UserControl x:Class="Silverlight20.Tip.LoadXap"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<Button x:Name="load" Content="加载游戏 - 俄罗斯方块" Click="load_Click" Margin="5" />
<Grid x:Name="container" Margin="5" />
</StackPanel>
</Grid>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<Button x:Name="load" Content="加载游戏 - 俄罗斯方块" Click="load_Click" Margin="5" />
<Grid x:Name="container" Margin="5" />
</StackPanel>
</Grid>
</UserControl>
LoadXap.xaml.cs
2、在 Silverlight 程序中加载指定的 xaml 文件
LoadXaml.xaml.cs
LoadXaml.xaml.cs
LoadDll.xaml
<UserControl x:Class="Silverlight20.Tip.LoadDll"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock x:Name="lblResult" Margin="5" />
</Grid>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock x:Name="lblResult" Margin="5" />
</Grid>
</UserControl>
LoadDll.xaml.cs
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="Silverlight20" EntryPointType="Silverlight20.App" RuntimeVersion="2.0.31005.0">
<Deployment.Parts>
<AssemblyPart x:Name="Silverlight20" Source="Silverlight20.dll" />
<AssemblyPart x:Name="Microsoft.Windows.Controls" Source="Microsoft.Windows.Controls.dll" />
</Deployment.Parts>
</Deployment>
一个 Silverlight 应用程序包(xap)内都会包含 AppManifest.xaml 文件,其内标识着打包的程序集和程序入口等信息
Deployment - 根节点
EntryPointAssembly - 程序入口的程序集
EntryPointType - 程序入口的类型
RuntimeVersion - 所需的 Silverlight 插件的版本
AssemblyPart - 标识 Silverlight 程序包(xap)内的程序集。其中的 Source 属性用于标识程序集的路径
<Deployment.Parts>
<AssemblyPart x:Name="Silverlight20" Source="Silverlight20.dll" />
<AssemblyPart x:Name="Microsoft.Windows.Controls" Source="Microsoft.Windows.Controls.dll" />
</Deployment.Parts>
</Deployment>
一个 Silverlight 应用程序包(xap)内都会包含 AppManifest.xaml 文件,其内标识着打包的程序集和程序入口等信息
Deployment - 根节点
EntryPointAssembly - 程序入口的程序集
EntryPointType - 程序入口的类型
RuntimeVersion - 所需的 Silverlight 插件的版本
AssemblyPart - 标识 Silverlight 程序包(xap)内的程序集。其中的 Source 属性用于标识程序集的路径
5、自定义鼠标指针,即鼠标跟随
CustomMouseCursor.xaml
CustomMouseCursor.xaml
<UserControl x:Class="Silverlight20.Tip.CustomMouseCursor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="Bisque">
<Canvas x:Name="canvas">
<Ellipse x:Name="ellipse" Width="30" Height="30" Fill="Red" />
</Canvas>
</Grid>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="Bisque">
<Canvas x:Name="canvas">
<Ellipse x:Name="ellipse" Width="30" Height="30" Fill="Red" />
</Canvas>
</Grid>
</UserControl>
CustomMouseCursor.xaml.cs
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。