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

Selected value not stored in Data Context

3 Answers 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joel Robertson
Top achievements
Rank 1
Joel Robertson asked on 04 Nov 2009, 03:18 PM
Hi,

We are using rad combo box for binding the values. We are in the position to bind the values but while saving the values we are not able to get the RadCombo box selected value in the data context by using two way binding. please find the code below
<telerikInput:RadComboBox Margin="0 2 0 0" x:Name="cbState" DisplayMemberPath="StateName" 
      ItemsSource="{Binding States}" SelectedItem="{Binding StateHome,Mode=TwoWay}"   
       Height="10" IsEditable="False"  Background="White" FontSize="9">  
</telerikInput:RadComboBox> 
 
xaml.cs page code:  
 
 
 #region Declaration  
 private readonly DummyData data = new DummyData();  
 #endregion  
 
  public NurseQueue()  
        {             
            InitializeComponent();  
            cbState.DisplayMemberPath = "HomeState";  
        }  
 
 public class DummyData  
    {  
        private readonly List<State> states = new List<State> 
            {  
                  new State {StateName = "Texas"IsDefault = false},  
                  new State {StateName = "New York"IsDefault = false},  
                  new State {StateName = "Alaska"IsDefault = true}  
                    
            };  
 
        public List<State> States  
        {  
            get  
            {  
                return states;  
            }  
        }  
 
        public State HomeState  
        {  
            get  
            {  
                return States.First(StateName => StateName.IsDefault);  
            }  
        }  
    }  
    public class State  
    {  
        public string StateName { get; set; }  
        public bool IsDefault { get; set; }  
    }  
 
 

Thanks
Sreeraman

3 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 05 Nov 2009, 03:57 PM
Hello Joel,

I think that the code you've sent contains several errors. I already answered your support ticket and attached a simple application that works properly. Please, let's continue the conversation in just one place.

Best wishes,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Fábio
Top achievements
Rank 1
answered on 31 Dec 2010, 08:47 PM
Hi !
Could you please show the solution for this post ?

Best regards,

Fábio
0
Yana
Telerik team
answered on 06 Jan 2011, 04:12 PM
Hi Fábio,

Sorry for my late reply.

I've attached the modified code, please download it and give it a try.

Best wishes,
Yana
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
ComboBox
Asked by
Joel Robertson
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Fábio
Top achievements
Rank 1
Yana
Telerik team
Share this question
or