问题描述
请看如下代码,用的infragistics15.1wpfcontrol,xamproprtygrid.是不是控件有bug?颜色下拉显示正常,coretype不正常<Windowx:Class="IGWpfApplication1.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="522"Width="755"xmlns:ig="http://schemas.infragistics.com/xaml"Loaded="Window_Loaded"><Grid><ig:XamPropertyGridMargin="12,0,12,12"Name="xamPropertyGrid1"/>Grid>Window>usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;namespaceIGWpfApplication1{//////InteractionlogicforMainWindow.xaml///publicpartialclassMainWindow:Window{publicMainWindow(){InitializeComponent();}privatevoidWindow_Loaded(objectsender,RoutedEventArgse){DataClassdata1=newDataClass();data1.TrueOrFalse=true;data1.CoreType="Core2";data1.ColourType="Green";this.xamPropertyGrid1.SelectedObject=data1;}}}usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Linq;usingSystem.Text;namespaceIGWpfApplication1{publicclassDataClass:INotifyPropertyChanged{privatebool_trueOrFalse=false;privateString_coreType="";privateString_colourType="";publicboolTrueOrFalse{get{return_trueOrFalse;}set{_trueOrFalse=value;}}[TypeConverter(typeof(CoreTypeConverter))]publicStringCoreType{get{return_coreType;}set{_coreType=value;}}[TypeConverter(typeof(ColourTypeConverter))]publicStringColourType{get{return_colourType;}set{_colourType=value;}}#regionINotifyPropertyChangedMemberspubliceventPropertyChangedEventHandlerPropertyChanged;protectedvirtualvoidOnPropertyChanged(stringpropertyName){if(PropertyChanged!=null){PropertyChanged(this,newPropertyChangedEventArgs(propertyName));}}#endregion}publicclassCoreTypeConverter:StringConverter{publicoverrideboolGetStandardValuesSupported(ITypeDescriptorContextcontext){returntrue;}publicoverrideboolGetStandardValuesExclusive(ITypeDescriptorContextcontext){returntrue;}publicoverrideStandardValuesCollectionGetStandardValues(ITypeDescriptorContextcontext){List<string>list=DemodataClass.GetCoreList();returnnewStandardValuesCollection(list);}}publicclassColourTypeConverter:StringConverter{publicoverrideboolGetStandardValuesSupported(ITypeDescriptorContextcontext){returntrue;}publicoverrideboolGetStandardValuesExclusive(ITypeDescriptorContextcontext){returntrue;}publicoverrideStandardValuesCollectionGetStandardValues(ITypeDescriptorContextcontext){List<string>list=DemodataClass.GetColourList();returnnewStandardValuesCollection(list);}}publicstaticclassDemodataClass{//thefollowingcouldreturndaynamicvaluesfromdatabase.privatestaticList<string>CoreList=newList<string>(){"Core1","Core2","Core3"};privatestaticList<string>ColourList=newList<string>(){"Red","Green","Yellow"};//thefollowingcouldreturndaynamicvaluesfromdatabase.publicstaticList<string>GetCoreList(){returnCoreList;}//thefollowingcouldreturndaynamicvaluesfromdatabase.publicstaticList<string>GetColourList(){returnColourList;}}}
解决方案
解决方案二:
谁能帮看看?谢谢
解决方案三:
这看不出来什么,不知道你的XamPropertyGrid的某些属性是如何定义的
解决方案四:
谢谢斑竹duanzi_peng,有图,我觉得是这个控件有毛病。coreType错误显示的是颜色。如果去掉Colour上的converter,CoreType显示正常。这程序用WindowsFormPropertyGrid就两个都正常。