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
EnumConverter
class is in the main assembly - If I comment out
<local:EnumConverter x:Key="enumConverter"/>
the designer works.