使用枚举从类设计时间数据 [英] Design Time Data from Class with Enums

查看:85
本文介绍了使用枚举从类设计时间数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了blend来创建一个类的设计时数据xml文件。然而,我的类中有一个枚举,设计时数据xml只有枚举的文本值 - 这似乎没有实际效果。我的枚举到文本转换器在运行时与实际的
类datacontext一起正常工作 - 但在设计器中却没有。该类的其他字符串属性没有问题绑定到设计器。

I've used blend to create a design time data xml file from a class. My class however has an enum in it and the design time data xml just has the text value of the enum - this doesn't seem to actually work. My enum to text converter works fine with actual class datacontext at run time - but not in the designer. Other string properties of the class have no problem binding to the designer.

我搜索过并搜索过但未发现是否支持此内容。

I have searched and searched without finding out if this is supported or not.

如果我的班级已定义公开枚举 - 应该在设计时数据绑定中工作吗?

If my class has an public enum defined - should that work in design time data binding?

public enum MyEnum {enum1 = 0,enum2,enum3}

public enum MyEnum { enum1 = 0, enum2, enum3 }

class MyClass {public MyEnum EnumProperty ; }

class MyClass { public MyEnum EnumProperty; }

由blend生成的xml具有EnumProperty =" enum2"

xml generated by blend has EnumProperty="enum2"

但是它作为字符串对象传递给我的转换器 - 而不是枚举。

but that gets passed to my converter as a string object - not an enum.

我在这里遗漏了什么吗?

Am I missing something here?

推荐答案

还没弄清楚如何使用枚举在设计数据.xml文件中 - 但提出了一个解决方案 - 更改viewmodel以使用int值而不是实际枚举。如果失败,我发现以下

链接
- 并意识到我可以放弃.xml文件,只需创建我的视图模型类的设计实例使用。

Haven't figured out how to use enums in the design data .xml file - but came up with one solution - change the viewmodel to use an int value instead of the actual enum. Failing that I found the following link - and realized that I could give up on the .xml file and just create a design instance of my view model class to use.

但是,如果我错过了一些在设计数据中实际使用枚举值的方法,我仍然很好奇。

However, I am still curious if I missed some way to actually use enum values in design data.


这篇关于使用枚举从类设计时间数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆