Using Themes in Silverlight

1. You should firstly add System.Windows.Controls.Theming.Toolkit.dll reference to your project. The path in my machine is C:/Program Files/Microsoft SDKs/Silverlight/v3.0/Toolkit/Jul09/Bin

 

2. Add existing themes to your SilverLight Application. The path here is C:/Program Files/Microsoft SDKs/Silverlight/v3.0/Toolkit/Jul09/Themes/Xaml. Under this folder, there are several existing themes. Such as System.Windows.Controls.Theming.BubbleCreme.xaml, System.Windows.Controls.Theming.ShinyRed.xaml, System.Windows.Controls.Theming.RainierPurple.xaml, and so on......

 

3. Change each Theming Xaml's "Build Action" property to Content, which allows you reference them using relative path. By the way, remove the settings for "Custom Tool"

4. You can use themes as follows,

Notice:

ImplicitStyleManager.ApplyMode("Auto","None","OneTime")

Auto: the theme can be applied to the controls dynamically added in to the UI.

None: equals not set this property

OneTime: the theme will be applied only for the first time when the control loaded.

Fine I'll use OneTime.  What if I need to style a dynamically created control though?

If you want to ensure a dynamically created control is styled you can use ISM's "Apply" method.  You can manually call this method after adding your dynamically generated control to the styled container:

 

At last, you can also define your own themes or modifying them based on the existing themes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值