2012-04-30 118 views
0

我有wpf中的datagrid。當我在列標題上進行鼠標懸停時,會出現一個關閉按鈕。以編程方式刪除datagrid列

我想要一些功能,所以當我點擊那個按鈕時,整個列應該被刪除。

我寫了這個。

 <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執行,但它並沒有列的索引。我怎麼知道我點擊了哪一列。

screenshot

請幫助我。

感謝 迪

回答

0

您可以嘗試通過結合柱通過爲CommandParameter。索引本身不應該被需要。