Click here to Skip to main content
15,918,404 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am facing the issue with Binding the Slected Item with my WPF Combo. Follwing is the code -

XAML Code:

<
SQL
<ComboBox Grid.Row="3"   Grid.Column="1" Margin="0,13,272,13" ItemsSource="{Binding Path=PersonTiers, Mode=TwoWay}" SelectedValue="{Binding Path=SelectedPersonTier, Mode=TwoWay}" SelectedValuePath="Content"/>



View Model Code
C#
public List<string> PersonTiers
   {
       get
       {
           List<string> lstPersonTiers = new List<string>();
           string[] TierArray = Globalization.TierString.Split(',');
           foreach (var item in TierArray)
           {
               lstPersonTiers.Add(item);

           }
           return lstPersonTiers;
       }

   }
   private string _selectedPersonTier;

   public string SelectedPersonTier
   {
       get { return //What should I write here ?.ToString(); }
       set
       {
           if (_selectedPersonTier != value)
           {
               _selectedPersonTier = value;
               this.OnPropertyChanged("SelectedPersonTier");
           }
       }
   }


I am able to get the Combo List , but not the Selected Item . Please help .
Posted
Updated 15-Apr-13 4:03am
v2

1 solution

_selectedPersonTier should be returned in your get for the property SelectedPersonTier. So the get should appear as follows:
C#
get { return _selectedPersonTier; }


That should fix the selected item issue as well.

Regards,
SeniorCrispy.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900