zoukankan      html  css  js  c++  java
  • 在WPF中获取DataGridTemplateColumn模板定义的内容控件

    xaml格式描述:

    <DataGrid Name="dataGrid" Grid.Row="1" ItemsSource="{Binding}"  >
                <DataGrid.Columns>
                  <DataGridTemplateColumn Header="描述">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Expander x:Name="expander" Header="{Binding Describe}">
                                    <TextBlock Text="{Binding Path=Exception}" TextWrapping="Wrap" MinHeight="30"  MinWidth="250" />
                                </Expander>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>

    现在要获取expander控件,代码如下:

    int index = dataGrid.CurrentCell.Column.DisplayIndex;

    转载:http://blog.sina.com.cn/s/blog_541e699d0100wjs9.html

    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);

  • 相关阅读:
    struts1下载地址
    基础知识浮点数
    基础知识this[String]
    矩阵基础知识(二)
    矩阵基础知识(三)
    設計公司軟件開發需求分析流程
    動態調用js文件
    图片的淡入淡出的实现方法
    IIS7.5(经典/集成),IIS6,asp.net 4.0下配置Url映射(asp.net mvc)
    页面状态加载....
  • 原文地址:https://www.cnblogs.com/qq247039968/p/4062440.html
Copyright © 2011-2022 走看看