Thread is closed for posting
2 posts, 1 answers
  1. Rob
    Rob avatar
    12 posts
    Member since:
    Jan 2013

    Posted 08 Oct 2014 Link to this post


    I am trying to bind a RadDataForm DataField to a property in my model. I would like to use DisplayMemberPath and SelectedValuePath in order to display a "description" to the user, but store a record id to my model
    ex. Display "New York", but store "NY"

    The following is not correct, throws exception "Value does not fall within the expected range."
    What is correct way to implement this behavior using DisplayMemberPath and SelectedValuePath?

    Model has a property defined as follows
            // State
            private string _state;
            public string State
                get { return _state; }
                    if (_state != value)
                        _state = value;

    IGenericListFieldInfoProvider is defined as follows:

        public class StateInfoProvider : IGenericListFieldInfoProvider
            public IGenericListValueConverter ValueConverter
                get { return null; }
            public System.Collections.IEnumerable ItemsSource
                    List<StateInfo> states = new List<StateInfo>();
                    states.Add(new StateInfo() { State = "California", StateCode = "CA" });
                    states.Add(new StateInfo() { State = "New Jersey", StateCode = "NJ" });
                    states.Add(new StateInfo() { State = "New York", StateCode = "NY" });
                    return states;

    View is defined as follows:
                <telerikInput:RadDataForm x:Name="RadDataForm1"  ValidationMode="OnValueChanged" CommitMode="OnFieldValueChange" >
                        <telerikInput:DataField TargetProperty="State" Header="State">
                                    <telerikInput:RadListPicker DisplayMemberPath="State" SelectedValuePath="StateCode" />

  2. Answer
    Ves avatar
    2924 posts

    Posted 13 Oct 2014 Link to this post

    Hi Rob,

    In this case, you can use the default editor, created by RadDataForm -- namely the one that uses RadListPicker control, populated with the values returned by the IGenericListFieldInfoProvider. RadLIstPicker exposes the properties you need - DisplayMemberPath and SelectedValuePath. Here is an example:

    <telerikInput:DataField TargetProperty="State"  x:Name="stateField">
            <Style TargetType="telerikInput:RadListPicker">
                <Setter Property="PopupHeader" Value="State"/>
                <Setter Property="DisplayMemberPath" Value="State" />
                <Setter Property="SelectedValuePath" Value="StateCode" />

    Best regards,

    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.

Back to Top