【问题标题】:Delete datagrid column programmatically以编程方式删除数据网格列
【发布时间】:2012-04-30 17:32:33
【问题描述】:

我在 wpf 中有数据网格。当我将鼠标悬停在列标题上时,会出现一个关闭按钮。

我想要一些功能,所以当我点击那个按钮时,应该删除整列。

这是我写的。

      <DataTemplate x:Key="AdornerDataTemplate">
    <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,0,0">
        <Button Content="X" Width="26" Height="26" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ctrls:RhinoDataGrid}}, Path=RemoveColumnCommand}" Background="{DynamicResource GridHeaderMouseOverBrush}"></Button>
    </Grid>

我可以看到 RemoveColumnCommand 已执行,但它没有列索引。我怎么知道我点击了哪一列。

请帮帮我。

谢谢 深

【问题讨论】:

    标签: wpf datagrid columnheader


    【解决方案1】:

    您可以尝试通过绑定将列作为CommandParameter 传递。应该不需要索引本身。

    【讨论】:

      猜你喜欢
      • 2012-07-05
      • 2011-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多