【问题标题】:Caliburn Micro Update RowDetails of a DatagridCaliburn Micro Update RowDetails of a Datagrid
【发布时间】:2012-09-13 18:20:31
【问题描述】:

让我解释一下我的问题。我正在使用 Caliburn Micro 并有一个数据网格,其中 ObservableCollection 被绑定为 Itemsource:

private static ObservableCollection<Models.GamesProperties> _dgGames;

public ObservableCollection<Models.GamesProperties> DgGames
{
    get { return _dgGames; }
    set
    {
        _dgGames = value;
        NotifyOfPropertyChange(() => DgGames);
    }
}

因此,当我从数据库加载数据时,集合将被填充并绑定到我的数据网格(称为 DgGames)

到目前为止一切都很好。我已经为每个 DataRow 定义了“DataRowDetails”。包含一个 ImageSource、一些 TextBlocks 等。上面提到的集合也包含那些 DataRowDetails。

我现在为对话窗口创建了另一个 View 和 ViewModel 以更改 DataRowDetails。它确实有效,但数据网格 (DgGames) 不会应用这些更改。它没有显示我对集合所做的任何更新。我错过了什么?

提前感谢那些可以帮助我的人。

如果您需要更多信息,请随时询问。

【问题讨论】:

    标签: binding datagrid refresh caliburn.micro rowdetails


    【解决方案1】:

    为了也看到网格中的动态修改,Models.GamesProperties 必须正确实施INotifyPropertyChanged。由于您使用的是 Caliburn,您可能希望从 PropertyChangedBase 派生它。

    【讨论】:

    • 嗯,我已经尝试从“PropertyChangedBase”派生它。向对象添加了“NotifyOfPropertyChange()”,但它无法正常工作。没有效果。
    • 不幸的是,您的解决方案是正确的。它首先不起作用,因为在我将集合绑定到我的数据网格之后,我使用了以下两行,这搞砸了我的PropertyChangedBaseDgGames.Items.SortDescriptions.Clear(); DgGames.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending)); 希望它是可读的。还没有习惯评论框。感谢@FelicePollano 的提示
    猜你喜欢
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-29
    • 2012-10-24
    • 2012-05-08
    • 1970-01-01
    相关资源
    最近更新 更多