Tôi có tài sản sau đây Temp2
: (UserControl của tôi thực hiện INotifyPropertyChanged)bộ mã XAML ItemsSource = "{Binding}" với mã đằng sau
ObservableCollection<Person> _Temp2;
public ObservableCollection<Person> Temp2
{
get
{
return _Temp2;
}
set
{
_Temp2 = value;
OnPropertyChanged("Temp2");
}
}
public event PropertyChangedEventHandler PropertyChanged = delegate { };
private void OnPropertyChanged(string propertyName)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
tôi cần phải tạo ra một listview động. Tôi có listview sau trong XAML:
<ListView
Name="listView1"
DataContext="{Binding Temp2}"
ItemsSource="{Binding}"
IsSynchronizedWithCurrentItem="True">
<ListView.View>
.... etc
Bây giờ tôi đang cố gắng để tạo listview cùng với C# như:
ListView listView1 = new ListView();
listView1.DataContext = Temp2;
listView1.ItemsSource = Temp2; // new Binding(); // ????? how do I have to implement this line
listView1.IsSynchronizedWithCurrentItem = true;
//.. etc
khi tôi cư listview với C# listview không được dân cư. tôi đang làm gì sai?
Không làm việc không biết tại sao? –