Hey. I have got a XDG with a field of type KeyValuePair<Guid, string>.
The DataSource is xml, which causes the problem, that a string (the value of the xml element) needs to be parsed into the KeyValuePair. How do i tell the XDG to use an appropriate TypeConverter?
Would be great, if i could provide my own TypeConverter, because then i could put just the Guid into the xml and select the correct Pair from another Dictionary.
The particular application is that i display a xamComboBox for the user which shows only the values. Since i need to create the fields of the XDG dynamically, i add the Combobox by looping over the Fields and adjust the style as follows.
Dictionary<Guid, string> myDictionary = ... foreach (var field in xamDataGrid1.RecordManager.Current.FieldLayout.Fields) { if (field.DataType == typeof(KeyValuePair<Guid, string>)) { Style style = new Style(typeof(XamComboEditor)); style.Setters.Add(new Setter(XamComboEditor.ItemsSourceProperty, myDictionary)); style.Setters.Add(new Setter(XamComboEditor.DisplayMemberPathProperty, "Value")); field.Settings.EditorType = typeof(XamComboEditor); field.Settings.EditorStyle = style; } }
That works fine, the problem is that the DataSource is xml and the Elements that describe the Key (or KeyValuePairs if necessary) are not used... Thanks for help.
EDIT
Ok, actually i put the xml first into a DataSet which I bind than to the XDG. So the problem is not how to tell the XDG the right TypeConverter to intepret the element of the xml, but how to tell this to the DataSet. So this is probably not the right forum. Sorry for that, however maybe someone knows the answer?!
Hi Frank,
I haven't heard back from you and I'm wondering if there is anything further I can help with regarding this question.
If so, please feel free to contact me.
This is a little off the topic but I did find a couple of links that might be helpful.
http://bytes.com/topic/c-sharp/insights/914243-load-dataset-datatable-2d-array-objects
http://stackoverflow.com/questions/4463833/how-does-a-dataset-know-how-to-parse-elements-from-xml-files