点击“间隙”,获取“间隙”旁边隐藏的减号按钮(本图片未显示出来)

private void TextBlock_MouseDown_2(object sender, MouseButtonEventArgs e)
{
ContentPresenter contentPres = (sender as FrameworkElement).TemplatedParent as ContentPresenter;
DataTemplate dTemplate = contentPres.ContentTemplate;
Button quesDesc = (Button)dTemplate.FindName("delete", contentPres)

.......

}

xaml

<ListView Name="listview" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="5" Background="#D8D8D8">
    <ListView.View>
        <GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}">
            <GridViewColumn Header="类型" Width="80">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <WrapPanel>
                            <TextBlock Text="{Binding Path=ItemType,Converter={StaticResource itemtypeConverter}}" MouseDown="TextBlock_MouseDown_2"></TextBlock>
                            <Button Name="delete" Visibility="Hidden" Content="-" Click="delete_Click_1"></Button>
                        </WrapPanel>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
              </GridViewColumn>
....
        </GridView>
    </ListView.View>
</ListView>

;

listview的gridview视图中,获取列中模板内的button按钮(找控件内的控件)的更多相关文章

  1. GridView控件RowDataBound事件中获取列字段值的几种途径

    前台: <asp:TemplateField HeaderText="充值总额|账号余额"> <ItemTemplate> <asp:Label ID ...

  2. PHP中获取数组中单列的值

    PHP中获取数组中单列的值如下: 利用PHP中的数组函数 array_column():返回数组中某个单列的值.(PHP 5.5+适用) 语法: array_column(array,column_k ...

  3. 记录一次bug解决过程:velocity中获取url中的参数

    一.总结 在Webx的Velocity中获取url中参数:$rundata.getRequest().getParameter('userId') 在Webx项目中,防止CSRF攻击(Cross-si ...

  4. 在SQL SERVER中获取表中的第二条数据

    在SQL SERVER中获取表中的第二条数据, 思路:先根据时间逆排序取出前2条数据作为一个临时表,再按顺时排序在临时表中取出第一条数据 sql语句如下: select top 1 * from(se ...

  5. js中获取URL中指定的查询字符串

    js中获取URL中指定的搜索字符串,主要利用location对象实现,废话少说,上代码. function getSearchString(key) { // 获取URL中?之后的字符 var str ...

  6. Flex中获取RadioButtonGroup中的RadioButton的值

    Flex中获取RadioButtonGroup中的RadioButton的值 1.设计源码 <?xml version="1.0" encoding="utf-8& ...

  7. 父窗口中获取iframe中的元素

    js 在父窗口中获取iframe中的元素 1. 格式:window.frames["iframe的name值"].document.getElementById("ifr ...

  8. 在iframe窗体内 获取父级的元素;;在父窗口中获取iframe中的元素

    在iframe中获取父窗口的元素 $(‘#父窗口中的元素ID’, parent.document).click(); 在父窗口中获取iframe中的元素 $(“#iframe的ID”).content ...

  9. 在弹框中获取foreach中遍历的id值,并传递给地址栏(方法2)

    1.php有时候我们需要再弹框中获取foreach中遍历的数据(例如id),在弹框中点击按钮并传递给地址栏跳转.那么应该怎么做呢.第二种方法. 2. 可以在弹框中给出一个input hidden 点击 ...

  10. 在弹框中获取foreach中遍历的id值,并传递给地址栏。

    1.php有时候我们需要再弹框中获取foreach中遍历的数据(例如id),在弹框中点击按钮并传递给地址栏跳转.那么应该怎么做呢. 2. 点击取现按钮,如果没有设置密码->弹框 3. 点击去设置 ...

随机推荐

  1. MySQL Group Replication-MGR集群

    简介 MySQL Group Replication(简称MGR)字面意思是mysql组复制的意思,但其实他是一个高可用的集群架构,暂时只支持mysql5.7和mysql8.0版本. 是MySQL官方 ...

  2. Nginx设置防止IP及非配置域名访问

    #设置IP或其它域名访问时返回500或304 server{ listen default; server_name _; ##标示空主机头 return ; } #设置IP或其它域名访问时重定向到w ...

  3. Python学习【02】Python基础

    一.Python内部执行过程 1.Python的后缀名可以是任意? print("hello,world")  保存成  .py / .txt / .sb / .aaa 都可以用在 ...

  4. 贝叶斯、朴素贝叶斯及调用spark官网 mllib NavieBayes示例

    贝叶斯法则   机器学习的任务:在给定训练数据A时,确定假设空间B中的最佳假设.   最佳假设:一种方法是把它定义为在给定数据A以及B中不同假设的先验概率的有关知识下的最可能假设   贝叶斯理论提供了 ...

  5. 【HQL】函数汇总

    背景 抽空整理一篇HQL函数及常用的小技巧 COALESCE COALESCE(T v1, T v2, -) 返回参数中的第一个非空值:如果所有值都为NULL,那么返回NULL

  6. go-001[常用命令]

    go env GOARCH="amd64"//这台机器的cpu 架构 GOBIN="/Applications/MAMP/htdocs/go/bin"  //工 ...

  7. SAML 2.0初始

    一.背景知识: SAML即安全断言标记语言,英文全称是Security Assertion Markup Language.它是一个基于XML的标准,用于在不同的安全域(security domain ...

  8. 树莓派3使用openSUSE Ports 42.3 驱动GPIO注意事项

    安装好opensuse 42.3以后,安装wiringPi库. 由于/proc/cpuinfo文件缺少“Hardware”信息,导致出现如下错误: Oops: Unable to determine ...

  9. 打包发布到Tomcat

    idea:      file-->project structure -->  Artifacts --> 点+号 web application exploded  from m ...

  10. java中PriorityBlockingQueue 和DelayedWorkQueue 区别

    java中PriorityBlockingQueue 和DelayedWorkQueue 区别