c# - Editing dIfferent types of objects using different controls in Wpf Datagrid Column -


i need create wpf datagrid binding observablecollection dozen dictionary string name of property , object property value. every object different type boolean (checkbox), string (textbox), customclassobject (combobox or textbox), integer (textbox) or enum (combobox every value enum).

and needs populated dynamically.

i trying figure out last week hard.

do have idea how create such datagrid solve problem? how bind such list of objects pulled dictionary or whole dictionary datagrid allow user edit it?

should use datatemplate converters if possible, return right control corresponding value each object. or should create usercontrol consist bindable property object assign right control full field each value , bind contentcontrol?

i grateful every hint.

thanks

perhaps this:

public class myobjectlist : observablecollection<object> {     public myobjectlist()     {         add(new keyvaluepair<string, int>("key1", 1));         add(new keyvaluepair<string, string>("key2", "value2"));         add(new keyvaluepair<string, bool>("key3", true));         add(new keyvaluepair<string, double>("key4", 1.5));         add(new keyvaluepair<string, myenum>("key5", myenum.option3));         add(new keyvaluepair<string, mycustomclass>("key6", new mycustomclass(123)));     } }  public class mycustomclass {     int value;      public mycustomclass(int value)     {         this.value = value;     }     public override string tostring()     {         return string.format("mycustomclass {0}", value);     } }  enum myenum { option1, option2, option3 }; 

xaml:

    <datagrid margin="0" itemssource="{binding mode=oneway}">         <datagrid.datacontext>             <local:myobjectlist/>         </datagrid.datacontext>     </datagrid> 

result:

enter image description here


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -