显示xaf中的非持久对象列表

时间:2015-08-05 07:17:35

标签: c# listview xaf

我想使用xaf显示非持久对象的列表视图。我有一个非持久的课程。我想在弹出弹出窗口时将其显示为列表视图。到目前为止,我无法做到这一点。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

DevExpress支持中心提供了一个完整的示例:How to: Display a List of Non-Persistent Objects。你甚至可以run it online

解决方案的大部分内容是:

public class ShowDuplicateBooksController : ObjectViewController<ListView, Book> 
{
    public ShowDuplicateBooksController() 
    {
        PopupWindowShowAction showDuplicatesAction = 
            new PopupWindowShowAction(this, "ShowDuplicateBooks", "View");
        showDuplicatesAction.CustomizePopupWindowParams += showDuplicatesAction_CustomizePopupWindowParams;
    }

    void showDuplicatesAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) 
    {
        Dictionary<string, int> dictionary = new Dictionary<string, int>();
        foreach(Book book in View.CollectionSource.List) {
            if(!string.IsNullOrEmpty(book.Title)) {
                if(dictionary.ContainsKey(book.Title)) {
                    dictionary[book.Title]++;
                }
                else 
                    dictionary.Add(book.Title, 1);
            }
        }
        DuplicatesList duplicateList = new DuplicatesList();
        int duplicateId = 0;
        foreach(KeyValuePair<string, int> record in dictionary) {
            if (record.Value > 1) {
                duplicateList.Duplicates.Add(
                    new Duplicate() {
                        Id = duplicateId,
                        Title = record.Key, 
                        Count = record.Value });
                duplicateId++;
            }
        }
        e.View = Application.CreateDetailView(Application.CreateObjectSpace(), duplicateList);
        e.DialogController.SaveOnAccept = false;
        e.DialogController.CancelAction.Active["NothingToCancel"] = false;
    }
}

对于DevExpress的所有内容,您应首先尝试support center