Xceed Toolkit Plus for WPF v4.6 Documentation
DataGridUnboundItemProperty Class
Members  Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace : DataGridUnboundItemProperty Class
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

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

Reference

DataGridUnboundItemProperty Members
Xceed.Wpf.DataGrid Namespace