Question

I have datagrid in wpf. When I do mouse-over on column header, There is one close button will appear.

I want to have some functionality so when I click on that button, whole column should be deleted.

I have wrote this.

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

I can see that RemoveColumnCommand is executed but it doesn't have index of column. How would I know on which column I clicked.

screenshot

Pls help me.

Thanks Dee

Was it helpful?

Solution

You can try to pass the column as CommandParameter via a binding. The index itself should not be needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top