Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / DataGridVirtualizingQueryableCollectionViewSource Class
Members Example


In This Topic
    DataGridVirtualizingQueryableCollectionViewSource Class
    In This Topic
    The DataGridVirtualizingQueryableCollectionView class and its XAML proxy, the DataGridVirtualizingQueryableCollectionViewSource class, provide support for IQueryable data sources.
    Syntax
    'Declaration
     
    <TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
    <NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
    Public Class DataGridVirtualizingQueryableCollectionViewSource 
       Inherits DataGridVirtualizingCollectionViewSourceBase
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public class DataGridVirtualizingQueryableCollectionViewSource : DataGridVirtualizingCollectionViewSourceBase 
    Example
    The following example demonstrates how to bind to a data source that implements IQueryable (LINQ DataContext) and allow items to be edited, deleted, inserted, and refreshed.The following code provides the code-behind implementation of the CommitMode, CreatingNewItem, CommittingNewItem, CancelingNewItem, CommitItems, and RemovingItem events. The following code provides the code-behind implementation of the CommitMode, CreatingNewItem, CommittingNewItem, CancelingNewItem, CommitItems, and RemovingItem events.
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
       <Grid.Resources>
    
    
         <xcdg:DataGridVirtualizingQueryableCollectionViewSource x:Key="cvs_queryableSource"
                                                                 QueryableSource="{Binding Path=QueryableSource}"
                                                                 CommitMode="EditCommitted"
                                                                 CreatingNewItem="DataGridVirtualizingQueryableCollectionViewSource_CreatingNewItem"
                                                                 CommittingNewItem="DataGridVirtualizingQueryableCollectionViewSource_CommittingNewItem"
                                                                 CancelingNewItem="DataGridVirtualizingQueryableCollectionViewSource_CancelingNewItem"
                                                                 CommitItems="DataGridVirtualizingQueryableCollectionViewSource_CommitItems"
                                                                 RemovingItem="DataGridVirtualizingQueryableCollectionViewSource_RemovingItem" />
       </Grid.Resources>
    
       <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource cvs_queryableSource}}"
                             ItemScrollingBehavior="Deferred"
                             MaxGroupLevels="2"
                             MaxSortLevels="2"
                             IsDeleteCommandEnabled="True"
                             IsRefreshCommandEnabled="True">
          <xcdg:DataGridControl.Resources>
    
             <Style TargetType="{x:Type xcdg:Row}"
                    x:Key="RowHeightStyle">
                <Setter Property="Height"
                        Value="27" />
             </Style>
    
             <Style TargetType="{x:Type xcdg:DataRow}"
                    BasedOn="{StaticResource RowHeightStyle}" />
             <Style TargetType="{x:Type xcdg:InsertionRow}"
                    BasedOn="{StaticResource RowHeightStyle}" />
          </xcdg:DataGridControl.Resources>
    
          <xcdg:DataGridControl.View>
             <xcdg:TableView>
                <xcdg:TableView.FixedHeaders>
                   <DataTemplate>
                      <xcdg:InsertionRow />
                   </DataTemplate>
                </xcdg:TableView.FixedHeaders>
             </xcdg:TableView>
          </xcdg:DataGridControl.View>
    
          <xcdg:DataGridControl.Columns>
             <xcdg:Column FieldName="ProductID"
                          AllowSort="False"
                          AllowGroup="False" />
          </xcdg:DataGridControl.Columns>
       </xcdg:DataGridControl>
    </Grid>
    Public Partial Class Window1
                         Inherits Window
      Public Sub New
        Me.DataContext = Me
        InitializeComponent()
      End Sub
    
      ' QUERYABLE SOURCE
      Public Readonly Property QueryableSource As IQueryable
        Get
          If m_queryable Is Nothing Then
            m_northwind = New NorthwindDataContext()
            m_queryable = m_northwind.Products
          End If
          Return m_queryable
        End Get
      End Property
    
      Private m_northwind As NorthwindDataContext
      Private m_queryable As IQueryable
    
      ' QUERYABLE INSERTION SUPPORT
      Private Sub DataGridVirtualizingQueryableCollectionViewSource_CreatingNewItem( sender As Object, e As DataGridCreatingNewItemEventArgs )
        Dim productToInsert As New Product()
        e.NewItem = productToInsert
        m_northwind.Products.InsertOnSubmit( productToInsert )
        e.Handled = True
      End Sub
    
      Private Sub DataGridVirtualizingQueryableCollectionViewSource_CommittingNewItem( sender As Object, e As DataGridCommittingNewItemEventArgs )
        Try
          m_northwind.SubmitChanges()
        Catch e As Exception
          e.Cancel = True
        End Try
        e.Handled = True
      End Sub
    
      Private Sub DataGridVirtualizingQueryableCollectionViewSource_CancelingNewItem( sender As Object, e As DataGridItemHandledEventArgs )
        m_northwind.GetChangeSet().Inserts.Clear()
        e.Handled = True
      End Sub
    
      ' QUERYABLE EDIT SUPPORT
      Private Sub DataGridVirtualizingQueryableCollectionViewSource_CommitItems( sender As Object, e As CommitItemsEventArgs )
        Try
          m_northwind.SubmitChanges()
        Catch e As Exception
          m_northwind.GetChangeSet().Updates.Clear()
        Finally
          e.AsyncCommitInfo.EndCommit()
        End Try
      End Sub
    
      ' QUERYABLE DELETE SUPPORT
      Private Sub DataGridVirtualizingQueryableCollectionViewSource_RemovingItem( sender As Object, e As DataGridRemovingItemEventArgs )
        Try
          m_northwind.Products.DeleteOnSubmit( TryCast( e.Item, Product ) )
          m_northwind.SubmitChanges()
        Catch e As Exception
          m_northwind.GetChangeSet().Deletes.Clear()
          e.Cancel = True
        End Try
        e.Handled = True
      End Sub
    End Class
    public partial class Window1 : Window
    {
     public Window1()
     {
       this.DataContext = this;
       InitializeComponent();
     }
    
     // QUERYABLE SOURCE
     public IQueryable QueryableSource
     {
       get
       {
         if( m_queryable == null )
         {
           m_northwind = new NorthwindDataContext();
           m_queryable = m_northwind.Products;
         }
         return m_queryable;
       }
     }
    
     private NorthwindDataContext m_northwind;
     private IQueryable m_queryable;
    
     // QUERYABLE INSERTION SUPPORT
     private void DataGridVirtualizingQueryableCollectionViewSource_CreatingNewItem( object sender, DataGridCreatingNewItemEventArgs e )
     {
       Product productToInsert = new Product();
       e.NewItem = productToInsert;
       m_northwind.Products.InsertOnSubmit( productToInsert );
       e.Handled = true;
     }
    
     private void DataGridVirtualizingQueryableCollectionViewSource_CommittingNewItem( object sender, DataGridCommittingNewItemEventArgs e )
     {
       try
       {
         m_northwind.SubmitChanges();
       }
       catch
       {
         e.Cancel = true;
       }
       e.Handled = true;
     }
    
     private void DataGridVirtualizingQueryableCollectionViewSource_CancelingNewItem( object sender, DataGridItemHandledEventArgs e )
     {
       m_northwind.GetChangeSet().Inserts.Clear();
       e.Handled = true;
     }
    
     // QUERYABLE EDIT SUPPORT
     private void DataGridVirtualizingQueryableCollectionViewSource_CommitItems( object sender, CommitItemsEventArgs e )
     {
       try
       {
         m_northwind.SubmitChanges();
       }
       catch
       {
         m_northwind.GetChangeSet().Updates.Clear();
       }
       finally
       {
         e.AsyncCommitInfo.EndCommit();
       }
     }
    
     // QUERYABLE DELETE SUPPORT
     private void DataGridVirtualizingQueryableCollectionViewSource_RemovingItem( object sender, DataGridRemovingItemEventArgs e )
     {
       try
       {
         m_northwind.Products.DeleteOnSubmit( e.Item as Product );
         m_northwind.SubmitChanges();
       }
       catch
       {
         m_northwind.GetChangeSet().Deletes.Clear();
         e.Cancel = true;
       }
       e.Handled = true;
     }
    }
    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Data.CollectionViewSource
                Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase
                   Xceed.Wpf.DataGrid.DataGridVirtualizingCollectionViewSourceBase
                      Xceed.Wpf.DataGrid.DataGridVirtualizingQueryableCollectionViewSource

    Public Constructors
    Public Fields
     NameDescription
    Public Fieldstatic (Shared in Visual Basic)Identifies the QueryableSource dependency property.  
    Top
    Public Properties
     NameDescription
    Public PropertyGets a value indicating whether the detail descriptions are automatically created. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public PropertyGets a value indicating whether the foreign key descriptions are automatically created. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public PropertyGets a value indicating whether the item properties are automatically created. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public PropertyGets or sets a value indicating how automatic filtering of the data items will be performed. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public PropertyGets or sets a value representing when the CommitItems event will be raised. (Inherited from Xceed.Wpf.DataGrid.DataGridVirtualizingCollectionViewSourceBase)
    Public PropertyGets or sets the culture to use during sorting. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public PropertyGet or sets the default value of the CalculateDistinctValues property when a DataGridItemProperty has not explicitly set its value. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property (Inherited from System.Windows.DependencyObject)
    Public PropertyGets a collection of DataGridDetailDescription objects that provide information on the details that will be contained in a grid, including sorting, grouping, and child detail descriptions. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property (Inherited from System.Windows.Threading.DispatcherObject)
    Public PropertyGets or sets a value representing the constraint applied to the DistinctValues when automatically filtering data items. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property

    Gets or sets the mode that indicates when distinct values used by auto-filtering should be updated.

    (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public PropertyGets or sets a value indicating how filters entered into a FilterRow are applied. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.DependencyObject)
    Public PropertyGets the DataGridItemProperty objects that determine the characteristics of the items contained in the view. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public PropertyGets the type of the items contained in the collection view. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public PropertyGets a value representing the maximum amount of items that can be loaded in memory. (Inherited from Xceed.Wpf.DataGrid.DataGridVirtualizingCollectionViewSourceBase)
    Public PropertyGets a value representing the number of items that are contained in each page of data that is loaded in memory. (Inherited from Xceed.Wpf.DataGrid.DataGridVirtualizingCollectionViewSourceBase)
    Public PropertyGets or sets a value representing the percentage from the start or the end of a page that, when accessed, will cause the previous or next page to be queried and the items loaded in memory. (Inherited from Xceed.Wpf.DataGrid.DataGridVirtualizingCollectionViewSourceBase)
    Public PropertyGets the queryable source that will provide the data items.  
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Public PropertyGets or sets the collection from which the view is created. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Property (Inherited from System.Windows.Data.CollectionViewSource)
    Top
    Public Methods
    Extension Methods
     NameDescription
    Public Extension MethodOverloaded. 
    Top
    Public Events
     NameDescription
    Public Event

    Occurs after the AutoFilterValues of the DataGridItemProperty of a detail level changes.

    (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the EditItem method has been called to signal that the edit process of an item in the underlying data source is about to begin. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the CancelEdit >method has been called to signal that the edit process of an item in the underlying data source is about to be canceled. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the CancelNew method has been called to signal that the insertion process of a new item is about to be canceled. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when a page of data that contains edited items is about to be released from memory. This event must be handled when dealing with an editable grid. (Inherited from Xceed.Wpf.DataGrid.DataGridVirtualizingCollectionViewSourceBase)
    Public EventRaised when the CommitEdit method has been called to signal that modifications made to an item in the underlying data source are about to be committed. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the CommitNew method has been called to signal that a new item is about to be committed to the underlying data source. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the AddNew method has been called to signal that a new item is about to be created. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the distinct values need to be refreshed. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the BeginningEdit event to signal that the edit process of an item in the underlying data source has begun. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the CancelingEdit event to signal that the edit process of an item in the underlying data source has been canceled. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the CommittingEdit event to signal that the modifications made to an item in the underlying data source have been committed. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public Event (Inherited from System.Windows.Data.CollectionViewSource)
    Public EventRaised after the CreatingNewItem event to allow the new item to be initialized. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the RemovingItem event to signal that an item has been removed from the underlying data source. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the CancelingNewItem event to signal that the insertion process of a new item has been canceled. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the CommittingNewItem event to signal that a new item has been committed to the underlying data source. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised after the CreatingNewItem and InitializingNewItem events to signal that a new item has been created. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Public EventRaised when the Remove ora href="Xceed.Wpf.DataGrid~Xceed.Wpf.DataGrid.DataGridCollectionViewBase~RemoveAt.html">RemoveAt methods have been called to signal that an item is about to be removed from the underlying data source. (Inherited from Xceed.Wpf.DataGrid.DataGridCollectionViewSourceBase)
    Top
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also