0

DataGridColumnHeader事件MouseLeftButtonDown。我怎樣才能使用這個事件?SilverLight 4,DataGrid,DataGridColumnHeader,MouseLeftButtonDown事件

我如何加入DataGridColumnHeader與DataGridColumn?我見過

for Example: 
... 
    DataGridTextColumn TC; 
    TC = new DataGridTextColumn(); 
    TC.Header = "ID"; 
    TC.Binding = new Binding(); 
    TC.Binding.Converter = new MyCustomConverter(); 
    TC.Binding.ConverterParameter = 0; 

    // I need something like this: 
    TC.MouseLeftButtonDown += new event .... 
    // i need - when click on column header, my custom function will executed. 

    dataGrid.Columns.Add(TC); 

回答

0

最壞的代碼;)SRY ü應該使用的方法(回調)/λ確保滿足事件委託簽名來處理該事件

回調方法:

TC.MouseLeftButtonDown += MouseLeftButtonDownHandler; 
//define callback 
private void MouseLeftButtonDownHandler(object sender, MouseButtonEventArgs mouseButtonEventArgs) 
{ 
    //write ur logic here... 
} 

Lambda方法

TC.MouseLeftButtonDown += (sender, args) => {//write ur logic here} 
//where "sender" means the object raises the event(i.e. "TC"), args - object contains some helpfull information about the happened event(like "ClickCount", etc.). 

此鏈接將被用於:

Delegates

Events

相關問題