wpf combobox bind
Cześć Usiłuję powiązać listę <> z comboboxem.
<ComboBox Margin="131,242,275,33" x:Name="customer" Width="194" Height="25"/>
public OfferEditPage()
{
InitializeComponent();
cusmo = new CustomerViewModel();
DataContext = this;
Cusco = cusmo.Customer.ToList<Customer>();
customer.ItemsSource = Cusco;
customer.DisplayMemberPath = "name";
customer.SelectedValuePath = "customerID";
customer.SelectedValue = "1";
}
Nie jestem Błąd, ale Combobox jest zawsze pusty. Cusco jest własnością mojej listy. Nie mam pojęcia, co jest nie tak z tym kodem. Możesz mi pomóc?
Pozdrawiam
public class Customer
{
public int customerID { get; set; }
public string name { get; set; }
public string surname { get; set; }
public string telnr { get; set; }
public string email { get; set; }
public string adress { get; set; }
}
to jest klasa klientów, która jest moim modelem.
public class CustomerViewModel
{
private ObservableCollection<Customer> _customer;
public ObservableCollection<Customer> Customer
{
get { return _customer; }
set { _customer = value; }
}
public CustomerViewModel()
{
GetCustomerCollection();
}
private void GetCustomerCollection()
{
Customer = new ObservableCollection<Customer>(BusinessLayer.getCustomerDataSet());
}
}
a to jest ViewModel.