これを達成する別の方法は、DependencyObjectから派生した新しいXXXViewModelクラスを実装し、これをObservableCollectionに配置することです。この非常に良いMVVMの導入で、この外観のため
:http://blog.lab49.com/archives/2650は
は、そのようなクラスの例は次のようになります。ここ
public class EntryViewModel : DependencyObject
{
private Entry _entry;
public EntryViewModel(Entry e)
{
_entry = e;
SetProperties(e);
}
private void SetProperties(Entry value)
{
this.Id = value.Id;
this.Title = value.Title;
this.CreationTimestamp = value.CreationTimestamp;
this.LastUpdateTimestamp = value.LastUpdateTimestamp;
this.Flag = value.Flag;
this.Body = value.Body;
}
public Entry Entry
{
get {
SyncBackProperties();
return this._entry;
}
}
public Int64 Id
{
get { return (Int64)GetValue(IdProperty); }
set { SetValue(IdProperty, value); }
}
// Using a DependencyProperty as the backing store for Id. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IdProperty =
DependencyProperty.Register("Id", typeof(Int64), typeof(EntryViewModel), new UIPropertyMetadata(new Int64()));
}}
重要な事柄: - それはのDependencyObject から派生した - それはで動作しますWPFデータバインディングをサポートするDependencyProperties
br sargola
OK。私はINotifyPorpertyChangedインターフェイスを実装します。ありがとう –