I wants get the out put from database into combo box,
retrieved data from the database but it's not bind into the combo box
all the values are stored into observable collection but it's not binding
here my Code
XAML
<StackPanel Orientation="Horizontal" DataContext="{Binding Path=LocationListModel, Mode=TwoWay}" >
<StackPanel Margin="5" >
<Label Content="Location Name"/>
<ComboBox Name="cmbLocation" Grid.Column="1" Grid.Row="1" Width="200" ItemsSource="{Binding LocationNameList}" DisplayMemberPath="LocationName" Loaded="cmbLocation_Loaded">
</ComboBox>
</StackPanel>
<StackPanel Margin="5">
<Label Content="Building Name"/>
<ComboBox Name="cmbBuilding" Width="200"/>
</StackPanel>
</StackPanel>
WPF
public class LocationListModel : paymentModel
{
//LocationEntity locationEntity = new LocationEntity();
private ObservableCollection<paymententity> LocationList = new ObservableCollection<paymententity>();
// public ObservableCollection<paymententity> LocationId = new ObservableCollection<paymententity>();
public ObservableCollection<paymententity> LocationNameList
{
get { return LocationList; }
set
{
LocationList = value;
base.RaisePropertyChangedEvent("LocationNameList");
}
}
public ObservableCollection<paymententity> LocationIdList
{
get;
set;
}
public void locationListModel()
{
PaymentEntity paymentEntity = new PaymentEntity();
PaymentBussiness paymentBussienss = new PaymentBussiness();
DataTable LocationNameList = paymentBussienss.GetLocationList();
foreach (DataRow row in LocationNameList.Rows)
{
var obj = new PaymentEntity()
{
LocationId = (int)row.ItemArray[0],
LocationName = (string)row.ItemArray[1]
};
LocationList.Add(obj);
}
base.RaisePropertyChangedEvent("LocationNameList");
}
}