2014-11-30 14 views
3

분리 된 .xaml 안에 일련의 Xaml 벡터 아이콘이 있습니다.App.xaml에서 병합 된 사전

<Window.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/ScreenToGif;component/Themes/IconSet.xaml"></ResourceDictionary> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Window.Resources> 

나는 창문을 많이 가지고, 그래서 나는 단순히 App.xaml 내부에이 코드를 넣어 싶습니다 :이 지시어를 사용하여 내 window 내부를로드합니다. 그래서 여기

<Application.Resources> <!-- Error, The property "Resources" can only be set once. --> 
    <ResourceDictionary x:Key="IconSet"> <!--Not sure why this?--> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/Mine;component/Themes/Theme.xaml"/> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 

<!--Here goes the rest of the file, with Style and DropShadowEffect... --> 
</Application.Resources> 

을 문제 :

나는이 노력하고있어

모든 예는 x:Key 속성을 사용하지 않는,하지만 내가 필요로한다는 나에게 오류를 제공합니다. 나는 그 작업을 수행 할 때 , 그것은

답변

14

당신이를 제거해야 주석 텍스트를

<Application.Resources>  
    <ResourceDictionary>   
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/Mine;component/Themes/Theme.xaml"/> 
     </ResourceDictionary.MergedDictionaries> 

     <!--You have to add other style here only--> 

    </ResourceDictionary> 

<!--Not Here--> 

</Application.Resources> 

+1

감사합니다, 한 가지 더를 참조하시기 바랍니다 ... 내가 여러 속성 Resource을 가질 수 있다고 말한다 'x : Key' 속성. –

+0

당신은 환영합니다! –

+0

자, 문제가 있습니다. 예를 들어 벡터를 ViewBox의 자식으로 설정하면 다른 ViewBox로 다시 설정할 수 없습니다. 다른 곳에서 사용하려면'child = null'을 설정해야합니다. 각 창에 대해 사전을 병합하면 그럴 수 없습니다. –