Mergeddictionaries (learning)

Source: Internet
Author: User

When creating a resource, we usually right-click the root directory of this solution to create a new resource file, which is just a collection of any typed objects, not elements.

For example:

 1   <  Lineargradientbrush  Endpoint  = "1, 0"  X: Key  = "Brush1"  >  2   <  Gradientstop  Color  = "Yellow"  Offset = "0"   />  3   <  Gradientstop  Color  = "Orange"  Offset  = ". 7"   />  4   <  Gradientstop  Color  = "Darkred"  Offset  = "1"  />  5   </  Lineargradientbrush  > 

View code

When other XAML files (mainwindow. XAML or a view) need to use it

 
<EllipseFill="{Staticresource brush1}" />

However, I remember the resource at the <application. Resources> level or merge level.

Add the following open app. XAML. Inside the <application. Resources> tag

 1  <  Resourcedictionary  >  2   <  Resourcedictionary. mergeddictionaries  >  3   <  Resourcedictionary  Source  = "Brushes. XAML"   />  4   </  Resourcedictionary. mergeddictionaries >  5   </  Resourcedictionary  > 

View code

 

Note:

  1. Merge's source should be clearly written path:

     1   <  Resourcedictionary  >  2   <  Resourcedictionary. mergeddictionaries  > 3   <  Resourcedictionary  Source  = "Brushes. XAML"   />  4   </  Resourcedictionary. mergeddictionaries  >  5   </  Resourcedictionary  > 

    View code

    If the resource is in the resources folder, merging that into app. XAML wocould look like as follows:

     
    <ResourcedictionarySource= "Resources/brushes. XAML" />

     

  2. For other referenced assemblies. to base on Pack URI syntax. For example:
    <ResourcedictionarySource= "/Myclasslibrary; component/resources/brushes. XAML" />

     

  3. For duplicat resources, sort the rules. There is the first key to write the internal key, then the brush defined in the last resource, and then the second
     <  Resourcedictionary >  <  Solidcolorbrush  Color  = "Blue"  X: Key  = "Brush1"   />  <  Resourcedictionary. mergeddictionaries  >  <  Resourcedictionary  Source  = "Resources/brushes2.xaml"   /> <  Resourcedictionary  Source  = "Resources/brushes. XAML"   />  </  Resourcedictionary. mergeddictionaries  >  </  Resourcedictionary  > 

     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.