Xceed Toolkit Plus for WPF v5.1 Documentation
Xceed.Wpf.DataGrid.Toolkit Assembly / Xceed.Wpf.DataGrid Namespace / DataGridUnboundItemProperty Class
Members Example


In This Topic
    DataGridUnboundItemProperty Class
    In This Topic
    Represents an "unbound" item property whose values can be appended to a data item.
    Syntax
    'Declaration
     
    <DebuggerDisplayAttribute("Name = {Name}")>
    Public Class DataGridUnboundItemProperty 
       Inherits DataGridItemPropertyBase
    'Usage
     
    Dim instance As DataGridUnboundItemProperty
    [DebuggerDisplay("Name = {Name}")]
    public class DataGridUnboundItemProperty : DataGridItemPropertyBase 
    Remarks
    Unbound data can be "appended" to a data item through the use of unbound item properties, which are represented by the DataGridUnboundItemProperty class. Unlike unbound columns, which can be used to display non-data related information such as a label or controls that allow some sort of action to be carried out, unbound item properties can be used to provide additional data, such as calculated columns (see Example).
    Example
    The following example demonstrates how to use an unbound item property to display a calculated value. In this example, the total value of the units in stock.
    Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>
         <xcdg:DataGridCollectionViewSource x:Key="cvs_products"
                                            Source="{Binding Source={x:Static Application.Current}, Path=Products}">
    
            <xcdg:DataGridCollectionViewSource.ItemProperties>
    
              <xcdg:DataGridUnboundItemProperty Name="TotalUnitsValue"
                                                DataType="{x:Type sys:Double}"
                                                QueryValue="DataGridUnboundItemProperty_QueryValue" />
            </xcdg:DataGridCollectionViewSource.ItemProperties>
         </xcdg:DataGridCollectionViewSource>
    
         <local:CurrencyConverter x:Key="currencyConverter" />
    
      </Grid.Resources>
      <xcdg:DataGridControl x:Name="OrdersGrid"
                            ItemsSource="{Binding Source={StaticResource cvs_products}}">
         <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="TotalUnitsValue"
                         Title="Total Inventory">
               <xcdg:Column.CellContentTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Converter={StaticResource currencyConverter}}" />
                  </DataTemplate>
               </xcdg:Column.CellContentTemplate>
            </xcdg:Column>
    
            <xcdg:Column FieldName="Photo"
                         Visible="False" />            
         </xcdg:DataGridControl.Columns>
      </xcdg:DataGridControl>
    </Grid>
    The following code provides the implementation of the QueryValue event in which the unbound value will be calculated and returned.
    Private Sub DataGridUnboundItemProperty_QueryValue( ByVal sender As Object, ByVal e As DataGridItemPropertyQueryValueEventArgs )
    
      Dim System.Data.DataRowView As row = TryCast( e.Item, System.Data.DataRowView )
      If Not row Is Nothing Then
        If( row( "UnitsInStock" ) <> DBNull.Value ) Then
          e.Value = CDouble( CInt( row( "UnitsInStock" ) ) * CDec( row( "UnitPrice" ) )
        End If
      End If
    End Sub
    The following code provides the implementation of the QueryValue event in which the unbound value will be calculated and returned.
    private void DataGridUnboundItemProperty_QueryValue( object sender, DataGridItemPropertyQueryValueEventArgs e )
    {
     System.Data.DataRowView row = e.Item as System.Data.DataRowView;
     if( row != null )
     {
       if( row[ "UnitsInStock" ] != DBNull.Value )
       {
         e.Value = ( double )( ( short )row[ "UnitsInStock" ] * ( decimal )row[ "UnitPrice" ] );
       }
     }
    }
    Inheritance Hierarchy

    System.Object
       Xceed.Wpf.DataGrid.DataGridItemPropertyBase
          Xceed.Wpf.DataGrid.DataGridUnboundItemProperty

    Public Constructors
     NameDescription
    Public ConstructorOverloaded.   
    Top
    Public Properties
     NameDescription
    Public PropertyGets or sets a value indicating whether distinct values are to be calculated for the property. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the converter to convert values to and from the corresponding field in the underlying data source. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the culture in which to evaluate the converter. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the parameter to pass to the converter. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the property's data type. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the IEqualityComparer that is used to compare the equality of the item property's distinct values. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the IComparer that is used to sort the item property's distinct values. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or set the DataGridForeignKeyDescription that represents a foreign key constraint or enumeration. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the IComparer used when sorting groups by the result of a statistical function. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the result property name of the statistical function by whose values the groups will be sorted. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public Property (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets a value indicating whether the property is readonly. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public Property (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets a value indicating the maximum number of distinct values to calculate. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the name of a property in a DataGridCollectionView. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets a value indicating whether the value of the IsReadOnly property is ignored when new data items are inserted. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the custom data comparer that will be used to sort the values of the data-grid item property's associated column. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public Property (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public PropertyGets or sets the property's title. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Top
    Public Methods
     NameDescription
    Public MethodRetrieves the current value of the property for the specified component. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public MethodSets the current value of the property for the specified component. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Top
    Protected Methods
     NameDescription
    Protected MethodOverridden.   
    Protected Method

    Initializes a new instance of the DataGridItemProperty class specifying the name and title of the property, its value path, indicating whether it is read only, if the corresponding cell can be edited when a new item is being inserted, and if it represents a sub relationship.

    (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Protected MethodOverridden.   
    Top
    Public Events
     NameDescription
    Public Event
    Raised for each data item to allow the unbound value to be committed, if required.  
    Public EventRaised when the value of a property changes. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public EventRaised to allow custom distinct values to be provided. (Inherited from Xceed.Wpf.DataGrid.DataGridItemPropertyBase)
    Public EventRaised for each data item in the underlying data source and allows unbound values to be provided for each item through the Value property received in the event arguments.  
    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