I. Overview of the article
This presentation describes how to define WPF resources in a separate file and invoke the relevant resource files where needed.
Related Downloads (code, screen recording): Http://pan.baidu.com/s/1sjO7StB
Play Online: http://v.youku.com/v_show/id_XODExODg0MzIw.html
Warm Tips: If the screen recording and code can not be downloaded properly, you can leave a message in the station, or send an email to [email protected]
First, define the resources in a separate file
The XAML code looks like this:
<resourcedictionary xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http// Schemas.microsoft.com/winfx/2006/xaml " xmlns:sys=" Clr-namespace:system;assembly=mscorlib "> <sys: String x:key= "Text" > Road long its repair far XI, I will go up and down and quest! </sys:String></ResourceDictionary>
Iii. Connect to a separate resource file where resources are used
The XAML code is as follows:
<window x:class= "Demo009.mainwindow" xmlns= "Http://sche1mas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml" title= "Resource Files" fontsize= "> <Window.Resources> <resourcedictionary source=" Shinyred.xaml "/> </Window.Resources> <StackPanel> <textblock text=" { StaticResource text} "/> </StackPanel></Window>
Follow the code above, even if it's done!
To define WPF resources in a stand-alone file