WPF では、この問題を解決するために MVVM パターンを使用していました。XPO オブジェクトは UI によって直接使用されず、代わりに ViewModel オブジェクトが必要なプロパティを公開して、バインディング シナリオで簡単に使用できるようにします。MVVM は WPF 固有のものですが、MVP パターンは非常に似ており、Windows フォームで簡単に使用できると思います。したがって、UI と XPO オブジェクトの間のアダプターとして機能する Presenter オブジェクトを作成できます。
public class DocumentPresenter
{
private Document _document;
public DocumentPresenter(Document document)
{
_document = document;
}
public string Title
{
get { return _document.Title; };
set { _document.Title = value; };
}
public string Extension
{
get { return _document.Extension; };
set { _document.Extension = value; };
}
public byte[] Data
{
get { return _document.Data; };
set { _document.Data = value; };
}
public int ImageIndex
{
get
{
// some logic to return the image index...
}
}
}
をオブジェクトDataSource
のコレクションに設定し、を「ImageIndex」に設定するだけです。DocumentPresenter
ImageIndexMember
免責事項:私は実際にMVPパターンを使用したことはなく、MVVMのみを使用したため、間違っている可能性があります...とにかく、あなたは私が推測する写真を手に入れます;)