2013-07-26 2 views
6

फिर से लिखा है में इस XAML कोड App.xaml:MergedDictionaries कोड

<Application x:Class="Company.Product.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    > 
    <Application.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/Company.Windows.Themes.Theme1;component/Themes/System.Windows.xaml"/> 
      <ResourceDictionary Source="/Company.Windows.Themes.Theme1;component/Themes/Company.Windows.Controls.xaml"/> 
      <ResourceDictionary Source="/Company.Windows.Themes.Theme1;component/Themes/Company.Windows.Controls.Data.xaml"/>    
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </Application.Resources> 
</Application> 

बराबर करने के लिए:

App.xaml:

<Application x:Class="Company.Product.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    > 
</Application> 

और में App.xaml.cs:

public partial class App : Application 
{ 
    public App() 
    {    
     Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() 
     { 
      Source = new Uri("/Company.Windows.Themes.Theme1;component/Themes/System.Windows.xaml", UriKind.RelativeOrAbsolute) 
     }); 
     Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() 
     { 
      Source = new Uri("/Company.Windows.Themes.Theme1;component/Themes/Company.Windows.Controls.xaml", UriKind.RelativeOrAbsolute) 
     }); 
     Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() 
     { 
      Source = new Uri("/Company.Windows.Themes.Theme1;component/Themes/Company.Windows.Controls.Data.xaml", UriKind.RelativeOrAbsolute) 
     }); 
    } 
} 



एक ओर ध्यान दें: मैं Application.Current.Resources.MergedDictionaries.Clear() कॉल करने के लिए की जरूरत है; मर्ज किए गए शब्दकोश जोड़ने शुरू करने से पहले इस स्थिति में? मुझे लगता है कि इस समय डिफ़ॉल्ट मर्ज किए गए शब्दकोश संग्रह प्रारंभ में खाली है।

उत्तर

4

Ans1) हाँ बिल्कुल। वे वही हैं।

Ans2) वहाँ कोई MergedDictionaries हैं और इसलिए Count0 है के लिए कोई आप Clear() करने के लिए उन्हें जरूरत नहीं है।

+0

आपके लिए तेज़ी से बहुत धन्यवाद - लगभग तत्काल - उत्तर। :) – kajovajo