このプロジェクトでは、コードは適切にコンパイルおよび実行されます。ただし、解決に役立つ2つの問題があります。
VS2012 WPFデザイナーは、このXAMLファイルでは機能しません。「デザインビューはx64およびARMターゲットプラットフォームでは使用できません」というメッセージが表示されます。
次のメッセージが表示されます。名前「EnumConverter」は名前空間「clr-namespace:VideoDatabase.Enums」に存在しません。繰り返しますが、これはプロジェクトのコンパイルや実行を妨げるものではありません。
XAMLは次のとおりです。
<Window x:Class="VideoDatabase.Views.SortingView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VideoDatabase.Enums"
Title="Sort and Filter" SizeToContent="WidthAndHeight" ResizeMode="NoResize"
Background="LightGray">
<Window.InputBindings>
<KeyBinding Gesture="Escape" Command="{Binding CloseWindowCommand}"/>
</Window.InputBindings>
<Window.Resources>
<!-- Next line generates Intellisene error; however, the code compiles and executes -->
<local:EnumConverter x:Key="enumConverter"/>
</Window.Resources>
はEnumConverter
VideoDatabase.Enums名前空間のパブリッククラスであり、現在のアセンブリにあります。クラスのコードスニペットは次のとおりです。
namespace VideoDatabase.Enums
{
public class EnumConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
if (Enum.IsDefined(value.GetType(), value) == false)
return DependencyProperty.UnsetValue;
object parameterValue = Enum.Parse(value.GetType(), parameterString);
return parameterValue.Equals(value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
return Enum.Parse(targetType, parameterString);
}
}
}
これまでのところ、私は以下をチェックしました:
- ターゲットフレームワークが.NETFramework4.5であることを確認しました
EnumConverter
クラスがメインアセンブリにあることを確認しました- コメントアウトする
<local:EnumConverter x:Key="enumConverter"/>
とデザイナー作品。