Datagrid刷新组/排序collectionview

时间:2012-12-28 14:05:08

标签: wpf datagrid collectionview

我想刷新我的数据网格,但刷新后,我在组内的排序不再正确...

<XmlDataProvider x:Key="SmsData" XPath="/response/conv/">
</XmlDataProvider>

<local:RowColorConverter x:Key="RowColorConverter" />

<CollectionViewSource x:Key="SmsView"  Source="{StaticResource SmsData}" >
    <CollectionViewSource.SortDescriptions>
        <scm:SortDescription PropertyName="date" Direction="Descending" />
        <scm:SortDescription PropertyName="time" Direction="Descending" />

    </CollectionViewSource.SortDescriptions>

    <CollectionViewSource.GroupDescriptions>
        <dat:PropertyGroupDescription PropertyName="recipient" />

    </CollectionViewSource.GroupDescriptions>
</CollectionViewSource>

我调用了一个引用刷新方法的按钮:

...

CollectionViewSource cvs = FindResource("SmsView") as  CollectionViewSource;
cvs.View.Refresh();

dataGrid1.Items.Refresh();


xdp = FindResource("SmsData") as XmlDataProvider;
xdp.Document = doc;

0 个答案:

没有答案