赞
踩
- public class NotificationBase : INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
-
- public void NotifyPropertyChanged(string propertyName)
- {
- if (this.PropertyChanged != null)
- {
- this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
- [DataContract]
- public abstract class BaseModel : NotificationBase
- {
-
- }
public class PageBuildProductsModel : BaseModel
{
//产品列表
private List<ProductsModel> productslist;
public List<ProductsModel> ProductsList
{
get { return productslist; }
set
{
productslist = value;
NotifyPropertyChanged("ProductsList");
}
}
//选中产品
public ProductsModel CurrentProducts { get; set; }
public PageBuildProductsModel()
{
ProductsList = new List<ProductsModel>();
foreach (.....)
{
ProductsList.Add(......);
}
this.CurrentProducts = this.ProductsList[0];
}
private void Build(object obj)
{
//获取选中的值
MessageBox.Show(CurrentProducts.Queries);
}
}
<ComboBox ItemsSource="{Binding ProductsList}"
Width="100"
DisplayMemberPath="Name"
SelectedItem="{Binding CurrentProducts, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
注意:当前选项,绑定CurrentProducts
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。