In this project, the code compiles and executes properly; however, there are two issues I need help resolving:
-
The VS2012 WPF designer does not work on this XAML file. It displays the message Design view is unavailable for x64 and ARM target platforms.
-
I receive the following message The name “EnumConverter” does not exist in the namespace “clr-namespace:VideoDatabase.Enums”. Again, this does not interfere with compiling or executing the project.
Here is the 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>
The EnumConverter is a public class in the VideoDatabase.Enums name space and is located in the current assembly. Here is a code snippet of the class:
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);
}
}
}
So far, I have checked the following:
- Confirmed the target framework is .NET Framework 4.5
- Confirmed the
EnumConverterclass is in the main assembly - If I comment out
<local:EnumConverter x:Key="enumConverter"/>the designer works.
Most likely have you set your build target platform to x64 bit only.
What happens then is that your output assembly is 64bit only, which the x86 based WPF designer can’t load.
Go to the project properties->
Build->Target Platformand set that toAny.EDIT:
If you have assemblies/code (in this case value converters) that needs to be accessed from the 32bit WPF designer, then you will have to separate them out from your otherwise 64bit assemblies.
I would be hard pressed to find any reason why value converters need to be in a 64bit DLL other than a hard dependency as in your case.
If that’s not possible for you, I think you will have to live with the fact that you can’t use the designer in your scenario.