现在的位置: 首页 > 综合 > 正文

silverlight 自定义资源整理(待后续补充)

2012年09月06日 ⁄ 综合 ⁄ 共 673字 ⁄ 字号 评论关闭

1、直接在控件(窗体)中定义 

<UserControl.Resources> 
<SolidColorBrush x:Key="TextBoxBackgroundColor" Color="LemonChiffon"/>
</UserControl.Resources>

<TextBox Background="{StaticResource TextBoxBackgroundColor}"/>

2、在资源字典中直接定义

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml">

<SolidColorBrush x:Key="TextBoxBackgroundColor" Color="LemonChiffon"/>
</ResourceDictionary>

3、在资源字典中嵌套定义其他资源文件

<Application.Resources> 
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

优先级待整理后写上

抱歉!评论已关闭.