Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Converter declaration

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.

like image 371
Svetlana Krupalnik Avatar asked Mar 12 '26 00:03

Svetlana Krupalnik


1 Answers

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>
like image 151
Max Avatar answered Mar 15 '26 07:03

Max



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!