I can't get this to work.
I need to setup the columns for a datagrid dynamically. One of the columns is a DataGridTemplateColumns with a DoubleUpDown object (from this library)
I create the FrameworkElementFactory like this:
FrameworkElementFactory factory3 = new FrameworkElementFactory(typeof(DoubleUpDown));
factory3.SetValue(DoubleUpDown.ValueProperty, binding);
factory3.AddHandler(DoubleUpDown.ValueChangedEvent, new RoutedEventHandler(UnitsChanged));
public void UnitsChanged(object sender, RoutedEventArgs e)
{
//do stuff with e.OriginalSource
}
This throws an exception of type 'System.Windows.Markup.XamlParseException' when running the application. The problem is in the AddHandler method, if I comment that line it works fine, but obviously I need to attach an event there to do stuff when the value changes.
Can anyone help me, please? Thanks in advance
The handler type is invalid. You should use a RoutedPropertyChangedEventHandler: