大佬教程收集整理的这篇文章主要介绍了SilverLight样式表继承,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
SilverLight样式表继承与Css样式表继承很相似,只不过是语法结构不同而已。SilverLight功能更强大。
还是举最简单的例子,开启这扇大门:
新建文件:
/Style/Main.xaml:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation">
<Style x:Key="button1" TargetType="Button">
<Setter Property="BACkground" Value="Black"/>
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="Margin" Value="20"/>
</Style>
APP.xaml:
<Application.resources>
<resourceDictionary.MergedDictionaries>
<!--引用外部样式表-->
<resourceDictionary source="Style/Main.xaml"></resourceDictionary>
</resourceDictionary.MergedDictionaries>
<!--在这里也可定义其它样式表例如-->
<Style x:Key="button2" TargetType="Button" BasedOn="{Staticresource button1}">
<Setter Property="Foreground" Value="Red"/>
</Application.resources>
@H_146_39@mainPage.xaml
<Style x:Key="button3" TargetType="Button" BasedOn="{Staticresource button2}">
<Setter Property="FontSize" Value="99"/>
</UserControl.resources>
<Button Content="Button" Style="{Staticresource button3}" HorizontalAlignment="Left" VerticalAlignment="Top" />
运行结果可以看到所有样式都加载到Button中。OK!
继承顺序:
@H_146_39@main.xaml--APP.xaml--MainPage.xaml
从 <http://www.cnblogs.com/caixiaodong/archive/2010/07/03/1770375.html> 插入
以上是大佬教程为你收集整理的SilverLight样式表继承全部内容,希望文章能够帮你解决SilverLight样式表继承所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。