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

  • 相关阅读:
    转载:iOS开发的22个奇谲巧技
    解决pathForResource返回nil, 无法读取plist文件问题
    小项目三:登陆窗口
    小项目一: UIButton的使用
    转载:iOS 8 自适应 Cell
    转载:iOS 8 AutoLayout与Size Class自悟
    转载:总结iOS 8和Xcode 6的各种坑
    [转]Xcode6中如何添加pch文件
    UIButton和UIImageView的区别
    控件的属性
  • 原文地址:https://www.cnblogs.com/qq247039968/p/4062440.html
Copyright © 2011-2022 走看看