如何一个方法响应多个控件
private void BarButtonItem_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { BarButtonItem barItem = sender as BarButtonItem; if(barItem == null) return; string groupName = barItem.Content as string; treeList.BeginDataUpdate(); foreach(Employee empl in view.SelectedRows) empl.GroupName = groupName; treeList.EndDataUpdate(); }
<dxg:TreeListView.RowCellMenuCustomizations> <dxb:BarButtonItem Content="Executive General and Administration" Glyph="/TreeListDemo;component/Images/Categories/Administration.png" ItemClick="BarButtonItem_ItemClick" /> <dxb:BarButtonItem Content="Sales and Marketing" Glyph="/TreeListDemo;component/Images/Categories/Sales.png" ItemClick="BarButtonItem_ItemClick" /> <dxb:BarButtonItem Content="Inventory Management" Glyph="/TreeListDemo;component/Images/Categories/Inventory.png" ItemClick="BarButtonItem_ItemClick" /> <dxb:BarButtonItem Content="Research and Development" Glyph="/TreeListDemo;component/Images/Categories/Research.png" ItemClick="BarButtonItem_ItemClick" /> <dxb:BarButtonItem Content="Manufacturing" Glyph="/TreeListDemo;component/Images/Categories/Manufacturing.png" ItemClick="BarButtonItem_ItemClick" /> <dxb:BarButtonItem Content="Quality Assurance" Glyph="/TreeListDemo;component/Images/Categories/Quality.png" ItemClick="BarButtonItem_ItemClick" /> </dxg:TreeListView.RowCellMenuCustomizations>
看到就应该明白了吧