Question

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.

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top