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

FrameworkElementFactory, AddHandler doesn't work ...

1 Answer 275 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pasquale Zirpoli
Top achievements
Rank 1
Pasquale Zirpoli asked on 24 Jul 2012, 09:47 AM
Seems that AddHandler for a FrameworkElementFactory won't work, event are never called ...

here follows the test code

foreach (var c in radGridViewTest.Columns)

            {


                        var factory = new FrameworkElementFactory(typeof(Button), "myButton");

                        factory.SetValue(CursorPropertyCursors.Hand); // OK

                        factory.SetBinding(ContentPropertynew Binding(string.Format("[{0}]"4))); //OK

                        c.CellTemplate= new DataTemplate();

                        

                        var mh = new RoutedEventHandler(onClick);

                        factory.AddHandler(Button.ClickEventmh,true); // won't work ...

                        c.CellTemplate.VisualTree = factory;

                        c.CellTemplate.Seal();
            }


1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 24 Jul 2012, 10:20 AM
Hi,

This is a known issue in WPF. Please, refer to the attached project that demonstrates it out of the RadControls context. The recommended approach in such cases is to use DataTemplates that are initialized in XAML.

Greetings,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Pasquale Zirpoli
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or