I'm having a problem displaying a value in the combo box. One way binding works, but i would like to use 2 way binding.
Below is my code.
namespace CRMQuotes {publicclass Building : INotifyPropertyChanged {string _Series;publicstring Series {get { return _Series; }set {if (_Series != value) { _Series = value; OnPropertyChanged(Series); } } }public Building() { }///<summary>/// Setup the building specs and final pricing///</summary>///<param name="strSeries"></param>public Building(string strSeries) {this.Series = strSeries; }publicevent PropertyChangedEventHandler PropertyChanged;protectedvoid OnPropertyChanged(string propName) {if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propName)); } } } }
Then i pull the data out of CRM which works however nothing is displayed in my combo box.
BuildingSource.Add(new Building(retrievedBuilding[0].new_Series));
cboSeries.DataContext = BuildingSource.ElementAt(0).Series;
And finally here is my XAML code:
xmlns:data="clr-namespace:CRMQuotes" <UserControl.Resources><data:Buildingx:Key="Bldg"/></UserControl.Resources><ComboBoxHeight="23"HorizontalAlignment="Left"Margin="12,28,0,0"Name="cboSeries"VerticalAlignment="Top" <br/>Width="98"SelectionChanged="cboSeries_SelectionChanged" <br/>SelectedValue="{Binding Path=Series, Source={StaticResource Bldg}, Mode=TwoWay}"></ComboBox>
When i run the code it does break on the iNotify event. It assigns the value to "cboSeries.DataContext = BuildingSource.ElementAt(0).Series;" but it doesn't display it on my silverlight form.
Why??