【发布时间】:2015-11-15 23:53:43
【问题描述】:
我的应用程序中有两个 ListView。 这是我的模型课
public class SurveyDetailViewModel : INotifyPropertyChanged
{
private int _RoomTypeId;
private string _RoomType;
public int RoomTypeId
{
get { return _RoomTypeId; }
set
{
_RoomTypeId = value;
NotifyPropertyChanged("RoomTypeId");
}
}
public string RoomType
{
get { return _RoomType; }
set
{
_RoomType = value;
NotifyPropertyChanged("RoomType");
}
}
public ObservableCollection<SurveyProductDetails> SurveyProductDetails { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class SurveyProductDetails : INotifyPropertyChanged
{
private Guid _RoomId;
private int _ProductTypeId;
private string _Title;
private string _Color;
private int _Quantity;
private int _QuantityInstalled;
private string _RoomDescription;
private string _ProductDescription;
private string _ProductSpecification;
public Guid RoomId
{
get { return _RoomId; }
set
{
_RoomId = value;
NotifyPropertyChanged("RoomId");
}
}
public int ProductTypeId
{
get { return _ProductTypeId; }
set
{
_ProductTypeId = value;
NotifyPropertyChanged("ProductTypeId");
}
}
public string Title
{
get { return _Title; }
set
{
_Title = value;
NotifyPropertyChanged("Title");
}
}
public string Color
{
get { return _Color; }
set
{
_Color = value;
NotifyPropertyChanged("Color");
}
}
public string ProductSpecification
{
get { return _ProductSpecification; }
set
{
_ProductSpecification = value;
NotifyPropertyChanged("ProductSpecification");
}
}
public string ProductDescription
{
get { return _ProductDescription; }
set
{
_ProductDescription = value;
NotifyPropertyChanged("ProductDescription");
}
}
public int Quantity
{
get { return _Quantity; }
set
{
_Quantity = value;
NotifyPropertyChanged("Quantity");
}
}
public int QuantityInstalled
{
get { return _QuantityInstalled; }
set
{
_QuantityInstalled = value;
NotifyPropertyChanged("QuantityInstalled");
}
}
public string RoomDescription
{
get { return _RoomDescription; }
set
{
_RoomDescription = value;
NotifyPropertyChanged("RoomDescription");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
我有一个 Observable Collection 对象
ObservableCollection<SurveyDetailViewModel> surveyDetail = new ObservableCollection<SurveyDetailViewModel>();
获取数据。我尝试将 Outer ListView 的 ItemSource 设置为surveyDetail
ItemsSource="{Binding surveyDetail}"
和内心这样的人
ItemsSource="{Binding surveyDetail.SurveyProductDetails}"
我也尝试过这个
ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=SurveyProductDetails}"
ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=surveyDetail.SurveyProductDetails}"
外部 ListView 工作正常,但内部 ListView 根本没有绑定。需要帮助我做错了什么。
【问题讨论】:
标签: listview windows-phone-8.1 windows-8.1 winrt-xaml