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

Combo Box in DataForm - Selected Value Never shows on Load

2 Answers 84 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 30 Jan 2012, 08:58 PM
Hi..
I have the following ComboBox in a DataForm and in the Edit Template.  The value shows fine in the Read Only Template. But when I Bind the current values does not show and is not selected. The value SUBTYPE has a corresponding value in the Item Source. The dropdown displays the correct values and I can make a selection. But when loaded the ComboBox is blank and the value not selected.
Any idea what I'm doing wrong?   thanks!!!!!!!!!!!!!!!!!!!!

     <telerik:RadComboBox x:Name="comboSubType" Margin="5,0,0,0"  Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" IsEnabled="True" HorizontalAlignment="Left" CanAutocompleteSelectItems="true"
                                                    ItemsSource ="{Binding SubCategories_Filtered,Source={StaticResource ViewModel}}"
                                                    SelectedValue="{Binding SubType, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                                    SelectedValuePath="SubCategory1" 
                                                    DisplayMemberPath="SubCategory1" 
                                                    Style="{StaticResource RadComboBoxStyle}" Loaded="comboSubType_Loaded"
                                                    Height="30" Width="200" >


                                </telerik:RadComboBox>

SubCategories_Filtered looks like this

   private List<SubCategory> _filteredsubcatgories;
        public List<SubCategory> SubCategories_Filtered
        {
            get
            {
                if (_filteredsubcatgories == null)
                {
                    this.SubCategories_Filtered = new List<SubCategory>();


                }


                return _filteredsubcatgories;
            }
            set
            {
                _filteredsubcatgories = value;
                this.RaisePropertyChanged("SubCategories_Filtered");
            }
        }


and this...

 [MetadataTypeAttribute(typeof(SubCategory.SubCategoryMetadata))]
    public partial class SubCategory
    {


        // This class allows you to attach custom attributes to properties
        // of the SubCategory class.
        //
        // For example, the following marks the Xyz property as a
        // required property and specifies the format for valid values:
        //    [Required]
        //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
        //    [StringLength(32)]
        //    public string Xyz { get; set; }
        internal sealed class SubCategoryMetadata
        {


            // Metadata classes are not meant to be instantiated.
            private SubCategoryMetadata()
            {
            }


            public string Category { get; set; }


            public int ID { get; set; }


            public string SubCategory1 { get; set; }
        }
    }

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 31 Jan 2012, 04:54 PM
Hi Jon,

Do you experience this behavior only on loading ? Can you select an item from the combo box when editing? Generally, such a behavior may be caused by the fact that the value to be displayed as selected is not available at the time RadComboBox tries to find it (at the initial moment).  

Greetings,
Maya
the Telerik team

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

0
Jon
Top achievements
Rank 1
answered on 31 Jan 2012, 05:00 PM
Thanks.. yes that appears to be issue..
The value is not available when loading...  The item source is null and not loaded.
I changed the code and it works now...thanks for the response.
Tags
DataForm
Asked by
Jon
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jon
Top achievements
Rank 1
Share this question
or