This is a migrated thread and some comments may be shown as answers.

Setting RadCombobox ItemsSource at runtime for EditorTemplate

1 Answer 84 Views
This is a migrated thread and some comments may be shown as answers.
Mano Sadeh
Top achievements
Rank 1
Mano Sadeh asked on 09 Oct 2014, 01:01 AM

We are trying to use RadPropertyGrid for a configurable application where we don't know the objects at design time. At runtime we are using PropertyDefinition for each field. This is working well except when we need to create a RadComboBox and assign the ItemsSource at runtime. This is the function to create the "Generic" DataTemplate and the only question we have is how to set the ItemsSource on the newly created RadComboBox (it is the codedValueDomain parameter).


private DataTemplate GetDataTemplate(Esri.ArcGISRuntime.Data.FieldInfo fieldInfo, CodedValueDomain codedValueDomain)
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.Append("<DataTemplate ");
    stringBuilder.Append("xmlns='' ");
    stringBuilder.Append("xmlns:x='' ");
    if (codedValueDomain != null)
        stringBuilder.Append(string.Format(@"<telerik:RadComboBox Name=""comboBox"" SelectedValue=""{{Binding Attributes[{0}], Mode=TwoWay}}"" DisplayMemberPath=""Value"" SelectedValuePath=""Key"" HorizontalAlignment=""Stretch"" />", fieldInfo.Name));
    else if (fieldInfo.Type == FieldType.Integer || fieldInfo.Type == FieldType.Double || fieldInfo.Type == FieldType.SmallInteger || fieldInfo.Type == FieldType.Single)
        stringBuilder.Append(string.Format(@"<telerik:RadNumericUpDown Value=""{{Binding Attributes[{0}], Mode=TwoWay}}"" HorizontalAlignment=""Stretch""/>", fieldInfo.Name));
    else if (fieldInfo.Type == FieldType.Date)
        stringBuilder.Append(string.Format(@"<telerik:RadDateTimePicker SelectedValue=""{{Binding Attributes[{0}], Mode=TwoWay}}"" HorizontalAlignment=""Stretch"" InputMode=""DatePicker""/>", fieldInfo.Name));
        stringBuilder.Append(string.Format(@"<telerik:RadMaskedTextInput Value=""{{Binding Attributes[{0}], Mode=TwoWay}}"" TextMode=""PlainText"" Mask="""" HorizontalAlignment=""Stretch""/>", fieldInfo.Name));
    DataTemplate dataTemplate = System.Windows.Markup.XamlReader.Parse(stringBuilder.ToString()) as DataTemplate;
    return dataTemplate;

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 13 Oct 2014, 11:09 AM
Hi Mano,

Have you tried specifying a proper Binding for the RadComboBox.ItemsSource? In that case you should also ensure it will be correctly resolved. For the purpose, you can try defining your ViewModel as a StaticResource and then set it as a Source for the Binding of child RadGridView. You can also check the Binding.Source Property as a reference.


Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Mano Sadeh
Top achievements
Rank 1
Answers by
Telerik team
Share this question