WPF:默认情况下显示列表视图组已折叠

时间:2018-05-24 15:11:44

标签: c# wpf mvvm

我有按订单号码分组的列表视图项目。当用户打开页面时,他们希望看到项目已折叠(现在显示已展开)。此外,他们希望扩展他们喜欢的任何订单项。

        ICollectionView dataView = CollectionViewSource.GetDefaultView(EncumbranceEntriesList.ItemsSource);

        if (dataView != null && dataView.SortDescriptions.Count == 0)
        {
            dataView.SortDescriptions.Add(new SortDescription("PurchaseOrderDetail.PurchaseOrder.DisplayNumber", ListSortDirection.Ascending));
            dataView.SortDescriptions.Add(new SortDescription("PurchaseOrderDetail.TransactionDate", ListSortDirection.Ascending));
            dataView.SortDescriptions.Add(new SortDescription("EntryDate", ListSortDirection.Ascending));

            EncumbranceEntriesList.Group("PurchaseOrderDetail.PurchaseOrder.DisplayNumber");

        }

------ ---- XAML

    <abc:DetailsListView x:Name="EncumbranceEntriesList" Grid.Row="1"
            ItemsSource="{Binding CurrentEncumbranceJournalEntries}"
            SelectionMode="Extended" ShowGroupItemCount="True"
            IsSortingEnabled="False"
            abc:ListBoxExtensions.HasBindableSelectedItems="True">

<ListView.View>
                <abc:DetailsView>
                    <abc:DetailsViewColumn Header="PO #" Width="100"
                        IsInitiallyVisible="False" IsUserHidable="False"
                        DisplayMemberBinding="{Binding PurchaseOrderDetail.PurchaseOrder.DisplayNumber}"
                        SortPropertyName="PurchaseOrderDetail.PurchaseOrder.DisplayNumber"
                        GroupPropertyName="PurchaseOrderDetail.PurchaseOrder.DisplayNumber"/>
                    <abc:DetailsViewColumn Header="Line Item" Width="200"
                        DisplayMemberBinding="{Binding PurchaseOrderDetail.ShortItemDescription}"/>
                    <abc:DetailsViewColumn Header="Encumbrance Date" Width="120"
                        DisplayMemberBinding="{Binding EntryDate, StringFormat=\{0:d\}}"
                        SortPropertyName="EntryDate" DefaultSortDirection="Descending"/>

                              </abc:DetailsView>
            </ListView.View>
        </abc:DetailsListView>

0 个答案:

没有答案