【问题标题】:How to reference in XAML a dependent property in another assembly which is based on enum in 3rd assembly如何在 XAML 中引用另一个程序集中基于第三个程序集中枚举的依赖属性
【发布时间】:2018-09-12 20:57:11
【问题描述】:

我在程序集 A 中有一个 WPF 窗口,它引用程序集 B 中的一个依赖属性。这个依赖属性值是一个位于程序集 C 中的枚举。

如果我偶然在程序集 B 中创建了依赖属性的值枚举,我可以很好地引用这些值,但是当我出于设计目的尝试将其移动到另一个程序集时,我遇到了 XAML 错误“成员 'ConnectionMode' 是无法识别或无法访问。”

枚举(在程序集 C 中):

public enum ConnectionMode { Slanted, Square }

属性(在程序集 B 中):

    private static readonly DependencyProperty ConnectionModeProperty = DependencyProperty.RegisterAttached(
        "ConnectionMode",
        typeof(TreeConnectionMode),
        typeof(TreeContainerProperties),
        new FrameworkPropertyMetadata(
            TreeConnectionMode.SlantedLines,
            FrameworkPropertyMetadataOptions.AffectsRender));
    public static void SetConnectionMode(TreeContainer target, TreeConnectionMode value) => target.SetValue(ConnectionModeProperty, value);
    public static TreeConnectionMode GetCheckedBackground(TreeContainer target) => (TreeConnectionMode)target.GetValue(ConnectionModeProperty);

控制中的 XAML 引用:

 TreeContainer:TreeContainerProperties.ConnectionMode="SlantedLines"

【问题讨论】:

    标签: c# wpf enums


    【解决方案1】:

    我错误地认为我遇到了代码问题。但问题与 VisualStudio 给我的 XDG0012 错误有关。如果您将 CPU 从 Any 更改为任何特定值,它就会出现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-09
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 2015-10-21
      相关资源
      最近更新 更多