0

Note: I have a ResourceDictionary and WPF Window (my View) and ViewModel, all declared within a WinForms application. Therefore I have no App.xaml.

I have the following converter declared:

Public Class DebugConverter
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
        Return value
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Return value
    End Function
End Class

And then I try loading a ResourceDictionary at runtime (which I specified the build action as Resource and not Page):

 m_rdGridDictionary = New ResourceDictionary()
 m_rdGridDictionary.Source = New Uri("pack://application:,,,/WPF/Helpers/GridResourceDictionary.xaml")

In the ResourceDictionary I have it declared as such:

<ResourceDictionary
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:cnv="clr-namespace:Positron.Cad.WindowGUI.WPFConverters">

     <cnv:DebugConverter x:Key="DebugConverter"/>
</ResourceDictionary>

But when I try loading the ResourceDictionary, it cannot find the converter:

Error

Would anyone know what is wrong with this scenario? They both exist in the same namespaces, so that shouldn't be the problem.

user2170838
  • 47
  • 1
  • 1
  • 8
  • 1
    Please add your code as text not as image and include the appropriate part of GridResourceDictionary.xaml (referencing the DebugConverter). A reference to the converter is probably wrong. http://stackoverflow.com/questions/4253554/xaml-binding-to-a-converter – IvanH May 08 '13 at 16:42
  • Can you post the code for where you're attempting to "load" the converter. – Tejas Sharma May 08 '13 at 16:42
  • I've updated my post, sorry for that, I had little time when I first posted... – user2170838 May 08 '13 at 17:38
  • Is DebugConverter in the same assembly with ResourceDictionary? Otherwise you need to specify assembly in "xmlns:cnv=..." too – Nikolay May 08 '13 at 18:22
  • Yes it's in the same project. – user2170838 May 08 '13 at 18:34

1 Answers1

2

Solved! The Build action had to be Page and not Resource.

user2170838
  • 47
  • 1
  • 1
  • 8