2012-02-21 14 views
1

현재 프로젝트간에 변환기를 잘라내어 붙여 넣기가 다소 지겨워졌습니다.StaticResource의 하위 객체를 사용할 수 있습니까?

필드/속성으로 변환기가있는 단일 변환기 개체를 사용할 수있는 방법이 있습니까?

다음과 같이 입력하십시오 :

<Application.Resources> 
    <sharedLib:Converters 
     x:Key="Converters" /> 
</Application.Resources> 

<TextBlock Text="{Binding Target, Converter={StaticResource Converters.MakeAllCaps}}" /> 

그렇다면 변환기에서 대량 가져 오기를 수행하는 방법에 대한 제안 사항이 있습니까?

당신은이 같은 리소스 사전에 모든 컨버터를 정의 할 수 있습니다

답변

2

:

<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="Converters.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

<TextBlock Text="{Binding Target, Converter={StaticResource MakeAllCaps}}" /> 
: 어디 이런 MergedDictionaries를 통해

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:loc="..."> 

    <loc:BooleanToVisibilityConverter x:Key="BooleanToVisibility" /> 
    <loc:MakeAllCapsConverter x:Key="MakeAllCaps" /> 

    <!-- Define all the common converters here --> 
</ResourceDictionary> 

지금이 리소스 사전을 가져올 수 있습니다