문제

So if I have a converter in the resource dictionary for my app like so:

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


      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="ResourceDictionaries/GraphViewerBrushes.xaml" />
        <ResourceDictionary Source="ResourceDictionaries/ColorPickerResources.xaml" />
      </ResourceDictionary.MergedDictionaries>



    </ResourceDictionary>
  </Application.Resources>

How can I reference the converter from within one of the external xaml files? or is this not possible? i know i could just reinstance another converter there, but that seems wasteful.

도움이 되었습니까?

해결책

You can use DynamicResource instead of StaticResource to reference the converter. This will cause it to look up the resource dynamically, which should succeed as it's part of the Application resources.

That being said, I typically just create another instance, as it is simpler, and a converter has very, very little overhead to create (since it should have no state).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top