ComboBox not intializing with selected value.

2 posts, 0 answers
  1. Hazzard
    Hazzard avatar
    24 posts
    Member since:
    May 2006

    Posted 01 Nov 2011 Link to this post

    I am trying to not only populate the combobox within the gridview with just 2 values, but I want the first value to be displayed when the page loads. How do I accomplish that? As you can see in my xaml, I'm trying about everything I can think of.  Thank you.
    combo box not initialzing to first value

    <l:Collection x:Key="EMC_Classes">
        <!-- Collection<object> -->
        <l:EMC_Class ID="1" Class="A or B" />
        <l:EMC_Class ID="2" Class="A,B,C,D" />
    <l:ValueToItemConverter x:Key="EMCID2Class"
                        ItemsSource="{StaticResource EMC_Classes}"
                        DisplayMemberPath="Class" />
    <telerik:GridViewColumn Header="Class" Width="100" IsReadOnly="False" x:Name="ComboClass">
            <DataTemplate >
                <ComboBox FontSize="10"   Width="90" HorizontalAlignment="Center" 
                        ItemsSource="{StaticResource EMC_Classes}"

    public void GridLoaded(object sender, TypeLoadedEventArgs e)
       MyAppliedStandardsModels = new ObservableCollection<AppliedStandardsModel>();
       var emcClasses = new List<EMC_Class>();
       foreach (AppliedStandardsModel item in e.SType)
          rgvEMCTestPlans.ItemsSource = MyAppliedStandardsModels;
     public class EMC_Class
        public string Class { get; set; }
        public int ID { get; set; }
    private ObservableCollection<AppliedStandardsModel> _myAppliedStandardsModel;
    public ObservableCollection<AppliedStandardsModel> MyAppliedStandardsModels
        get { return _myAppliedStandardsModel; }
            _myAppliedStandardsModel = value;
  2. Maya
    Maya avatar
    4062 posts

    Posted 02 Nov 2011 Link to this post

    Hello Hazzard,

    You need to define DataMemberBinding of the column as otherwise this column will not know which is the property it corresponds to from the underlying data item. Consequently, it will not be able to display it. Another possible way would be to bind the SelectedValue property of the combo box, but in this way you will not be able to sort, filter and group.
    I will definitely recommend you to run through our online documentation considering columns, the way you have define them and how you can change their cell and cell edit templates.
    Still, let me know if you need any further assistance.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top