在这个项目中,代码 正确编译和执行 ;但是,我需要帮助解决两个问题:
这是 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 命名空间中的公共(public)类,位于当前程序集中。这是该类的代码片段: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);
}
}
}
到目前为止,我已经检查了以下内容:
EnumConverter
类(class)在主大会<local:EnumConverter x:Key="enumConverter"/>
设计师的作品。 最佳答案
您很可能已将构建目标平台设置为仅 x64 位。
然后发生的事情是您的输出程序集只有 64 位,基于 x86 的 WPF 设计器无法加载。
进入项目属性-> Build->Target Platform
并将其设置为 Any
.
编辑:
如果您有需要从 32 位 WPF 设计器访问的程序集/代码(在本例中为值转换器),那么您必须将它们与其他 64 位程序集分开。
我很难找到为什么值转换器需要位于 64 位 DLL 中的任何原因,而不是像您的情况那样的硬依赖。
如果这对你来说是不可能的,我认为你将不得不忍受你不能在你的场景中使用设计器的事实。
关于wpf - WPF 中不存在另一个名称的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14415854/