Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 检索集合并枚举选定值WPF属性网格_C#_Wpf_Collections_Enums_Propertygrid - Fatal编程技术网

C# 检索集合并枚举选定值WPF属性网格

C# 检索集合并枚举选定值WPF属性网格,c#,wpf,collections,enums,propertygrid,C#,Wpf,Collections,Enums,Propertygrid,我正在使用WPF PropertyGrid(http://www.codeplex.com/wpg)在我的项目中。 但是这个组件有一些问题 1) 我可以在组合框中显示我的IList集合。但我无法检索选定的值。如何获取所选值 2) 枚举会自动显示在combobox中,但我无法检索像#1这样的选定值 你能帮我吗 这是我的收藏品 public class Contact { // Other properties [TypeConverter(typeof(MyConverter))]

我正在使用WPF PropertyGrid(http://www.codeplex.com/wpg)在我的项目中。 但是这个组件有一些问题

1) 我可以在组合框中显示我的IList集合。但我无法检索选定的值。如何获取所选值

2) 枚举会自动显示在combobox中,但我无法检索像#1这样的选定值

你能帮我吗

这是我的收藏品

public class Contact {
// Other properties

    [TypeConverter(typeof(MyConverter))]
        public string Cities
        {
            get;
            set;
        }
}
这是我的课程

class MyConverter : TypeConverter
    {
        public override bool
        GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }
        public override StandardValuesCollection
        GetStandardValues(ITypeDescriptorContext context)
        {
            List<string> list = new List<string>();

            list.Add("Istanbul");
            list.Add("Ankara");
            list.Add("Izmir");

            StandardValuesCollection cols = new
            StandardValuesCollection(list);
            return cols;
        }
    }
class MyConverter:TypeConverter
{
公共覆盖布尔
GetStandardValuesSupported(ITypeDescriptorContext上下文)
{
返回true;
}
公共覆盖标准值集合
GetStandardValues(ITypeDescriptorContext上下文)
{
列表=新列表();
添加(“伊斯坦布尔”);
添加(“安卡拉”);
添加(“伊兹密尔”);
标准值收集列=新
标准值集合(列表);
返回cols;
}
}
当我将Contact类的实例设置为WPF PropertyGrid的实例属性时,我看不到任何combox。但是如果我将我的对象设置为.Net PropertyGrid,我可以看到这个解决方案工作得很好


所以我认为这个PG不支持TypeConverts,那么我能做什么呢?

WPF propertygrid支持TypeConverts吗?在Winforms PG中实现的方式是,您可以编写一个类型转换器,并将其作为属性添加到属性中。然后,TypeConverter可以指定StandardValuesCollection。因此,在对象中有一个属性,它接受一个值,而转换器指定可能值的集合。

WPF propertygrid是否支持类型转换器?在Winforms PG中实现的方式是,您可以编写一个类型转换器,并将其作为属性添加到属性中。然后,TypeConverter可以指定StandardValuesCollection。因此,在对象中有一个属性,它接受一个值,而转换器指定可能值的集合。

您是使用数据绑定还是直接在代码中填充网格?我是通过网格实例属性绑定数据感兴趣的用户还可以检查我已实现的解决方案-您使用的可能重复项数据绑定还是直接在代码中填充网格?我通过网格实例属性绑定数据感兴趣的用户还可以检查我实施的解决方案-可能与我现在检查的解决方案重复,我认为它不支持类型转换器:(我现在检查,我认为它不支持类型转换器:(