Silverlight中资源文件的引用
来源:互联网 发布:浪潮 java 笔试 编辑:程序博客网 时间:2024/05/15 06:55
1、新建一个资源文件,比如: Gaugestyle.xaml和MenuButton.xaml
2、在App.xaml中添加该资源:
<Applicationxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"x:Class="spjl1.App"><Application.Resources><!-- Resources scoped at the Application level should be defined here. --><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="Gaugestyle.xaml"/><ResourceDictionary Source="MenuButton.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources></Application>
3、在页面文件后台中使用:
ResourceDictionary resources = new ResourceDictionary(); resources.Source = new Uri("/spjl1;component/MenuButton.xaml", System.UriKind.Relative); RadWindow1.Style = resources["ChildWindowStyle1"] as Style;
=====================================================内容补充======================================================
这里用一个Label的资源样式文件LabelStyle.xaml来讲解:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!--添加面板·标题--> <Style x:Key="tbAddTitle" TargetType="{x:Type Label}"> <Setter Property="FontFamily" Value="Microsoft YaHei" /> <Setter Property="Height" Value="28" /> <Setter Property="FontSize" Value="16" /> <Setter Property="Foreground" Value="#FF0000" /> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="VerticalAlignment" Value="Center" /> </Style></ResourceDictionary>
将该资源样式文件添加到App.xaml中
<Applicationxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"x:Class="spjl1.App"><Application.Resources><!-- Resources scoped at the Application level should be defined here. --><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="LabelStyle.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources></Application>
如果在前台XAML中使用,使用Style属性,方式如下:
<TextBlock Foreground="Black" Margin="0,1,479,0" Name="textBlock1" Style="{StaticResource tbAddTitle}" Text="供货商名称:" Grid.ColumnSpan="2" />
- Silverlight中资源文件的引用
- C#Resources中资源文件的引用
- 引用framework中资源文件
- 在Applet中引用jar中资源文件的KEY!
- 安卓xml中资源文件的引用符(@,?,*)
- 代码中资源文件引用,过时方法的替代
- .NET中资源文件的使用
- Delphi中资源文件的使用
- c#中资源文件的使用
- S60 中资源文件的读取
- OGRE中资源文件的缩减
- C#中资源文件的管理
- Android中资源文件的使用
- Dephi中资源文件的应用
- Android中资源文件的使用
- Android中资源文件的使用
- .NET中资源文件的使用
- C# 中资源文件的类型
- 多线程程序常见Bug剖析(下)
- Android高手进阶教程(二十一)---Android WebView的缓存!!!
- XRDP:Unable to copy the users Xauthorization file.
- 哈希表操作
- android alertdialog
- Silverlight中资源文件的引用
- js引用顺序问题,新手的困惑啊
- API和ABI
- 测试 Android G1 是否支持 OpenGL 硬件加速
- 用git部署php站点
- 搭建网站时对SEO的需求
- jquery中的lazyload()学习
- i_number inode denry联系
- SPM 代理人設定 總結