ListViewアイテムにHashSetをバインドしようとしています。私はここに自分のコードを文書化しました:ListView Item(C#、WPF)にHashSetをバインドします。
public class Person {
public string Name { get; set; }
public AddressList = new AddressList();
}
public class AddressList : HashSet<Addresses>
{
//
}
public class Addresses {
public string Streetname { get; set; }
public string City { get; set; }
}
public class PersonViewModel : INotifyPropertyChanged {
private Person _person;
public PersonViewModel(Person person)
{
_person= person;
}
public string Name
{
get { return _person.Name; }
set
{
_person.Name = value;
OnPropertyChanged("Name");
}
}
private void OnPropertyChanged(string property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
}
// This is how I add the DataContext: mainGrid.DataContext = _person //this is a PersonViewModel();
// This is how I bind the DataObjects to the GUI Elements: <TextBox Name="TxtBoxName" Text="{Binding Path=.Name, Mode=TwoWay}"/>
// How can I add in the same way a HashSet to a ListView Element in the WPF Gui? I tried something like {Binding Path=.Name, Mode=TwoWay}
誰でもその達成方法を教えてもらえますか?どうもありがとう! (そのことについて、または任意のItemsControl
)ListView
にコレクションをバインドする
乾杯
AddressesクラスのIEqualityComparerを追加しない限り、リストという単純なコレクションの代わりにHashSetを使用しないでください。 –
micahtan
しかし、HashSetは高速ではありませんか?私は実際には、特定のHashSet関数を必要としません( "有益な"ユニークなエントリ部分を除く).. –