Search code examples
wpfxamldata-binding

XAML don´t know the Resource folder


I tried to set up a Icon in XAML from the Resources.resx but it cant find the resources.

Code:

....
xmlns:resx="clr-namespace:Admin_Overwatch.Properties"
Title="MainWindow" Height="400" Width="600" Icon="{x:Static
resx:Resources.TitelLogomRand1}">

Error: "The name "Resources" doesen´t exist in the namespace...."

The courious thing is that in the autoformat it finds every icon in the Resources file. I have Rebuild it without any success and tried a new Resource folder also with no success.

Why doesn´t it find the Folder(s) ?

Edit: I tried this tutorial also without any success, I got the same error, it can´t find the resources.... http://social.technet.microsoft.com/wiki/contents/articles/22420.binding-to-resources-resx-files-in-xaml.aspx


Solution

  • The Answer was to use the Assembly in addition to the normal clr:

    xmlns:resx="clr-namespace:Admin_Overwatch.Properties;assembly=Admin-Overwatch"
    xmlns:local="clr-namespace:Admin_Overwatch;assembly=Admin-Overwatch"
    

    The Assembly name can be found by Right Click on the Project name under Properties --> Application.

    But the important part is that it is not possible to load the pictures from the resx in wpf that goes only in win forms.

    see here: How to use Resources.resx to link images