0

: ResourceDictionary と WPF ウィンドウ (私のビュー) と ViewModel があり、すべてWinFormsアプリケーション内で宣言されています。したがって、App.xaml はありません。

次のコンバーターを宣言しています。

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

次に、実行時に ResourceDictionary をロードしてみます (ビルド アクションをページではなくリソースとして指定しました)。

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

ResourceDictionary では、次のように宣言しています。

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

しかし、ResourceDictionary を読み込もうとすると、コンバーターが見つかりません。

エラー

このシナリオの何が問題なのか誰にも分かりませんか? どちらも同じ名前空間に存在するため、問題にはなりません。

4

1 に答える 1

2

解決しました!Build アクションは、Resource ではなく Page である必要がありました。

于 2013-05-08T19:04:14.527 に答える