您的位置:首页 > Web前端 > CSS

WPF后台代码中应用样式资源

2014-05-05 08:42 363 查看
初学WPF,关于如何在后台中寻找样式资源代码如下:

1、Style xxStyle=(Style)this.FindResource("NorBtnStyle");

btnName.Style=xxStyle;

2、btnName.Style=FindResource("NorBtnStyle") as Style;

---应用资源文件中的图像

PathGeometry pg=this.FindResource("wavePath") as PathGemoetry;

资源文件MainStyle.xaml

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

<Style x:Key="NorBtnStyle" TargetType="{x:Type Button}">
...
</Style>

<PathGeometry x:Key="wavePath" ...>
...
</PathGeometry>
</ResourceDictionary>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: