It is necessary to find a specific named element in the CellTemplate of a GridViewColumn.
There is a GridViewColumn defined like this:
It is possible to find an element in a DataTemplate by getting the ContentPresenter where the DataTemplate is applied, and using the FindName method of the DataTemplate to find a specific element.
How can you find the ContentPresenter where the GridViewColumn CellTemplate is applied?
There is a GridViewColumn defined like this:
<GridViewColumn Header="column 1"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox x:Name="txtcontent"/> </DataTemplate> </GridViewColumn.CellTemplate></GridViewColumn>It is possible to find an element in a DataTemplate by getting the ContentPresenter where the DataTemplate is applied, and using the FindName method of the DataTemplate to find a specific element.
DataTemplate celltemplate = column.CellTemplate;ContentPresenter contentpresenter = ...TextBox txtbox = (TextBox)celltemplate.FindName("txtcontent", contentpresenter);How can you find the ContentPresenter where the GridViewColumn CellTemplate is applied?