Xceed DataGrid for WPF v7.2 Documentation
FindFromChild(DataGridContext,DependencyObject) Method
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > Cell Class > FindFromChild Method : FindFromChild(DataGridContext,DependencyObject) Method
The DataGridContext to which the child belongs.
The DependencyObject for which to find the parent cell.
Finds the parent cell for the specified dependency object.
Syntax
'Declaration
 
Public Overloads Shared Function FindFromChild( _
   ByVal dataGridContext As DataGridContext, _
   ByVal child As DependencyObject _
) As Cell
'Usage
 
Dim dataGridContext As DataGridContext
Dim child As DependencyObject
Dim value As Cell
 
value = Cell.FindFromChild(dataGridContext, child)
public static Cell FindFromChild( 
   DataGridContext dataGridContext,
   DependencyObject child
)

Parameters

dataGridContext
The DataGridContext to which the child belongs.
child
The DependencyObject for which to find the parent cell.

Return Value

The parent cell of the child.
Example

All examples in this topic assume that the grid is bound to the Products table of the Northwind database, unless stated otherwise

The following example demonstrates how to use an unbound column to display a button that, when clicked, will display an editor through which the corresponding data item can be edited.The following code provides the implementation of the Button_Click event. The ProductsEditorWindow derives from Window and allows the data item to be edited. The code for the ProductsEditorWindow is not provided.The following code provides the implementation of the Button_Click event. The ProductsEditorWindow derives from Window and allows the data item to be edited. The code for the ProductsEditorWindow is not provided.
<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}" />

  </Grid.Resources>
  <xcdg:DataGridControl x:Name="OrdersGrid"
                        ItemsSource="{Binding Source={StaticResource cvs_products}}">
     <xcdg:DataGridControl.Columns>

       <xcdg:UnboundColumn FieldName="EditRowColumn"
                           Width="30"
                           MinWidth="30"
                           MaxWidth="30">
          <xcdg:UnboundColumn.CellContentTemplate>
             <DataTemplate>
                <Button Click="Button_Click"
                        Content="..." />
             </DataTemplate>
          </xcdg:UnboundColumn.CellContentTemplate>
       </xcdg:UnboundColumn>
        <xcdg:Column FieldName="Photo"
                     Visible="False" />
     </xcdg:DataGridControl.Columns>
  </xcdg:DataGridControl>
</Grid>
Private Sub Button_Click( ByVal sender As Object, ByVal e As RoutedEventArgs )
  Dim cell As Cell = Cell.FindFromChild( TryCast( sender, DependencyObject ) )

  Dim editor As New ProductsEditorWindow( TryCast( DataGridControl.GetParentDataGridControl( cell ).GetItemFromContainer( cell.ParentRow ), DataRowView ) )

  editor.ShowDialog()
End Sub
private void Button_Click( object sender, RoutedEventArgs e )
{
  Cell cell = Cell.FindFromChild( sender as DependencyObject );

  ProductsEditorWindow editor = new ProductsEditorWindow( DataGridControl.GetParentDataGridControl( cell ).GetItemFromContainer( cell.ParentRow ) as DataRowView );

  editor.ShowDialog();
}
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

Cell Class
Cell Members
Overload List