Silverlight 皮肤的使用(vs2010+sl4+ Toolkit April 2010)
来源:互联网 发布:oracle数据库设置密码 编辑:程序博客网 时间:2024/06/06 06:19
Silverlight皮肤的使用(一)
开发环境:vs2010+sl4+ Toolkit April 2010
1、安装好Microsoft Silverlight 4 Toolkit April 2010
2、引入dll
3、写相关代码
例如:BureauBlackTheme.SetIsApplicationTheme(App.Current,true);//设置主题
//我是使用combobox 来做demo的
switch(cbSkins.SelectedValue.ToString()){
case "BureauBlackTheme":
BureauBlackTheme.SetIsApplicationTheme(App.Current, true);
break;
case "BureauBlueTheme":
BureauBlueTheme.SetIsApplicationTheme(App.Current, true);
break;
case "ShinyBlueTheme":
ShinyBlueTheme.SetIsApplicationTheme(App.Current, true);
break;
case "WhistlerBlueTheme":
ShinyBlueTheme.SetIsApplicationTheme(App.Current, true);
break;
}
4、效果
5、这种方法非常之简单,具体不多说了
Silverlight皮肤的使用(二)
开发环境:vs2010+sl4+ Toolkit April 2010
1、安装好Microsoft Silverlight 4 Toolkit April 2010
2、打开Toolkit安装目录下的Themes/xaml文件夹,你可以看到非常多的xaml主题文件
如图:
3、新建一个silverlight项目,并在项目下建一个Themes文件夹
4、把Toolkit安装目录下的Themes/xaml文件夹下的文件拷贝到Themes下
效果如图:
5、引入dll,命名空间(有好多,可以编译根据错误提示查看需要引入什么)
效果如图:
6、设计Demo界面
右上角放一个combobox用来选择皮肤
中间爱放啥就放啥
7、关键代码
//匹配路径
String skinStr ="Themes/System.Windows.Controls.Theming." + skinKey +".xaml";
//获取资源
Uri uri =newUri(skinStr,UriKind.Relative);
//应用猪蹄
Theme.SetApplicationThemeUri(App.Current, uri);
<!-- [if gte mso 9]><![endif]-->
8、源码
Xaml:
<UserControl x:Class="SkinsDemoTwo.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="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ComboBox x:Name="cbSkins" Grid.Row="0" Height="30" Width="100" HorizontalAlignment="Right" SelectionChanged="ComboBox_SelectionChanged">
</ComboBox>
<sdk:Calendar Grid.Row="1" Height="168" HorizontalAlignment="Left" Margin="24,38,0,0" Name="calendar1" VerticalAlignment="Top" Width="171" />
<Button Content="Button" Grid.Row="1" Height="115" HorizontalAlignment="Left" Margin="236,64,0,0" Name="button1" VerticalAlignment="Top" Width="144" />
</Grid>
</UserControl>
Cs:
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.Controls.Theming;
namespace SkinsDemoTwo
{
publicpartialclassMainPage :UserControl
{
public MainPage()
{
InitializeComponent();
initSkins();
}
void initSkins() {
// <ComboBoxItem Content="BubbleCreme"></ComboBoxItem>
//<ComboBoxItem Content="BureauBlack"></ComboBoxItem>
//<ComboBoxItem Content="BureauBlue"></ComboBoxItem>
//<ComboBoxItem Content="ExpressionDark"></ComboBoxItem>
//<ComboBoxItem Content="ExpressionLight"></ComboBoxItem>
//<ComboBoxItem Content="RainierOrange"></ComboBoxItem>
//<ComboBoxItem Content="RainierPurple"></ComboBoxItem>
//<ComboBoxItem Content="ShinyBlue"></ComboBoxItem>
//<ComboBoxItem Content="ShinyRed"></ComboBoxItem>
//<ComboBoxItem Content="SystemColors"></ComboBoxItem>
//<ComboBoxItem Content="TwilightBlue"></ComboBoxItem>
//<ComboBoxItem Content="WhistlerBlue"></ComboBoxItem>
cbSkins.Items.Add("BubbleCreme");
cbSkins.Items.Add("BureauBlack");
cbSkins.Items.Add("BureauBlue");
cbSkins.Items.Add("ExpressionDark");
cbSkins.Items.Add("ExpressionLight");
cbSkins.Items.Add("RainierOrange");
cbSkins.Items.Add("RainierPurple");
cbSkins.Items.Add("ShinyBlue");
cbSkins.Items.Add("ShinyRed");
cbSkins.Items.Add("SystemColors");
cbSkins.Items.Add("TwilightBlue");
cbSkins.Items.Add("WhistlerBlue");
}
privatevoid ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//获?取?你?选?择?的?主÷题琣
String skinKey = cbSkins.SelectedValue.ToString();
//匹¥配?路·径?
String skinStr ="Themes/System.Windows.Controls.Theming." + skinKey +".xaml";
//获?取?主÷题琣资哩?源′
Uri uri =newUri(skinStr,UriKind.Relative);
//应畖用?主÷题琣
Theme.SetApplicationThemeUri(App.Current, uri);
}
}
}
<!-- [if gte mso 9]><![endif]-->
6、效果图
<!-- [if gte mso 9]><![endif]-->
欢迎转载,请注明出处
- Silverlight 皮肤的使用(vs2010+sl4+ Toolkit April 2010)
- VS2010 SL4
- Silverlight 皮肤的使用(二)
- Windows Phone中Silverlight Toolkit的使用
- Silverlight 皮肤的使用(一)
- 使用Silverlight Toolkit的数据分页控件---DataPager
- 使用Silverlight Toolkit的数据分页控件---DataPager
- Silverlight使用微软自带的TOOLKIT创建右键菜单
- Silverlight Toolkit --- AutoCompleteBox的用法
- VS2010 winform使用控件皮肤出错的解决方案
- 解决皮肤控件skinEngine不能在vs2010使用的问题
- 使用Silverlight Toolkit TreeView树形控件
- 使用Silverlight Toolkit绘制图表(上)--柱状图
- 使用Silverlight Toolkit中的主题(Theme)
- 使用Silverlight Toolkit实现弹窗---ChildWindow
- 使用Silverlight Toolkit 等级控件---Rating
- 使用Silverlight Toolkit 等级控件---Rating
- 使用Silverlight Toolkit实现弹窗---ChildWindow
- Linux学习笔记一 ---- Linux基础知识认知以及初识Linux下C编程入门
- 对归并、堆排、快排的一些总结。
- hdu1162最小生成树
- 话题发现与跟踪系统
- search
- Silverlight 皮肤的使用(vs2010+sl4+ Toolkit April 2010)
- ViewPager多页面滑动切换以及动画效果
- Android竖直显示Text
- 浅谈翻译文件格式
- 数据结构复习之【线性表】
- 求一个串的反转串的方法很多。下面就是其中的一种方法,代码十分简洁
- Visual Studio中的引用项目和直接引用DLL文件
- 一种新的走迷宫的方法
- juggernaut如何安装