【问题标题】:WPF: Ideas to set an flag enum value for a single object using Binding MechanismWPF:使用绑定机制为单个对象设置标志枚举值的想法
【发布时间】:2010-09-28 19:40:32
【问题描述】:

例如,我有一个枚举...

    public enum TypeIdentifier {
            NotSet = 0,
            Type1= 1,
            Type2= 2,
            Type3= 3,
            Type4= 4,
            Type5= 5
        }

public class CommonObject
{

TypeIdentifier myTypeIdentifier {get; set;}
}

我有一个具有通用对象绑定的 WPF 用户控件。我有一个使用 3 次的通用对象,掩蔽为 5 个不同的用户控件(成员使用不同)。

我需要在 UserControl One 中包含隐藏值说 TypeIdentifier.Type1。我该怎么做。我只需要将对象成员设置为 TypeIdentifier.Type1 在 UserControl 中的任何控件。我不能在我的用户控件项目中直接引用上面的枚举..:-( 有什么帮助吗?

【问题讨论】:

    标签: c# wpf binding enums


    【解决方案1】:

    如果您不能引用枚举,那么您将不得不使用ints 和Enum.Parse(),可能隐藏在ValueConverter 中。

    【讨论】:

      猜你喜欢
      • 2010-10-12
      • 2012-08-19
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      • 2016-03-26
      • 1970-01-01
      • 2010-10-09
      相关资源
      最近更新 更多