3

I try to insert an Image to my GUI application by means of a Binding and a Converter. I create an instance of a value converter in the resources of my MainWindow:

"xmlns:my1="clr-namespace:MyApp"    

<Window.Resources>
     <ResourceDictionary x:Key="Resc">
         <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary Source="StylesDictionary.xaml"/>
         </ResourceDictionary.MergedDictionaries>
     </ResourceDictionary>

     <my1:DirectionToImageConverter x:Key="DirectionToImageConverter"/>
</Window.Resources>

However, when I try to run the application I get the following exception:

''Resources' property has already been set on 'MainWindow'.' Line number '16' and
line position '11'.

Please help. Thanks a lot in advance.

Anatoliy Nikolaev
  • 22,370
  • 15
  • 69
  • 68

1 Answers1

9

You need to put your converter in the resource dictonary, see this question.

<Window.Resources>
     <ResourceDictionary x:Key="Resc">
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="StylesDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
        <my1:DirectionToImageConverter x:Key="DirectionToImageConverter"/>
    </ResourceDictionary>
</Window.Resources>
Community
  • 1
  • 1
Max
  • 1,810
  • 3
  • 26
  • 37