在WPF中获取DataGridTemplateColumn模板定义的内容控件
(2011-11-26 12:47:59)
标签:
控件获取描述模板定义templatecolumnit |
分类: WPF |
xaml格式描述:
<DataGrid Name="dataGrid" Grid.Row="1"
ItemsSource="{Binding}"
现在要获取expander控件,代码如下:
int index = dataGrid.CurrentCell.Column.DisplayIndex;
DataGridTemplateColumn templeColumn = dataGrid.Columns[index] as DataGridTemplateColumn;
if(templeColumn == null) return;
object item = dataGrid.CurrentCell.Item;
FrameworkElement element =
templeColumn.GetCellContent(item);
Expander expander=
templeColumn.CellTemplate.FindName("expander", element);

加载中…