This is a migrated thread and some comments may be shown as answers.

How handle event for dynamic column

1 Answer 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ahmad
Top achievements
Rank 1
Ahmad asked on 18 Apr 2017, 04:22 AM
Hi,
I add a column to my grid dynamically:

FrameworkElementFactory fef = null;
var template = new DataTemplate();
fef = new FrameworkElementFactory(typeof(Button));
fef.AddHandler(Button.PreviewMouseLeftButtonUpEvent, new MouseButtonEventHandler(MainWindow_MouseLeftButtonUp), true);
template.VisualTree = fef;
var column = new GridViewDataColumn();
column.CellTemplate = template;
column.CellTemplate.Seal();
grid.Columns.Add(column);


private void MainWindow_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
 //...
}

but when I clicked the Button, no event raised.
how can I handle the Event?

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 20 Apr 2017, 11:20 AM
Hello Ahmad,

Please have a look at the following article from our documentation page - Add a button column. You should be able to add an event handler in both approaches shown.

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Ahmad
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or