我想从
中的textBlock获取文本<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Name="dateCreateTextBlock" Text="{Binding Path=DateCreate, Converter={StaticResource ResourceKey=TimeConverter }, ConverterParameter=DateCreate, StringFormat={}{0:dd/MM/yyyy HH:mm:ss}}" Background="{x:Null}" Margin="3,6"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
我搜索了类似
的内容TextBlock tb = ((ContentPresenter)column.GetCellContent(row)).Content as TextBlock;
但它不起作用,我有tb = null;
答案 0 :(得分:0)
试试这个......
TextBlock tb = (TextBlock )GridName.Rows[((GridViewRow)((Control)sender).NamingContainer).RowIndex].FindControl("dateCreateTextBlock");