zoukankan      html  css  js  c++  java
  • listview的gridview视图中,获取列中模板内的button按钮(找控件内的控件)

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

    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>

    ;

  • 相关阅读:
    定时器
    SysTick
    13.看门狗
    12.FSMC
    11.中断
    ##HTML行内块元素好迷啊!!
    ##HTML基础
    ##CS3动画效果
    ##管家婆项目(tools层)
    ##管家婆项目(app层)
  • 原文地址:https://www.cnblogs.com/ykgbk/p/10690108.html
Copyright © 2011-2022 走看看