I'm dynamically creating a XamDateTimeInput field within a DataTemplate - programmatically managing the properties in C#.
How do I wire up the ValueChanged event? i don't see this as a property within ValueInput, but its accessible in XAML
var date = new FrameworkElementFactory(typeof(XamDateTimeInput)); var valueBinding = GetDataItemBinding(col); date.SetValue(ValueInput.ValueProperty, valueBinding); date.SetValue(ValueInput.FormatProperty, "MM/dd/yyyy"); date.SetValue(ValueInput.ValueTypeProperty, typeof(string)); date.AddHandler(ValueInput.ValueChangedEvent...,
Glad to hear it worked out!.
Thank you for using Infragistics components.
This worked great Thank you for the quick response!
Hello Patrick,
My bad on this, the correct one is RoutedPropertyChangedEventHandler<T>
date.AddHandler(XamDateTimeEditor.ValueChangedEvent, new RoutedPropertyChangedEventHandler<object>(ValueChangedHandler));
This one passes the old and new values of a value change.
Sincerely,
Tihomir TonevAssociate Software DeveloperInfragistics
Awesome thank you!
I'm seeing a "System.ArgumentException: 'Handler type is not valid.'" when using the code above.
Any ideas?
Thank you for reaching out.
AddHandler method expects RoutedEvent while ValueChanged is not registered as such. If you would like to use XamDateTimeInput you will need to extend the class and add the routed event.
Since this control is planned for retirement, we recommend using XamDateTimeEditor instead. This is a newer control having this routed event already defined, so you will be able to use it immediately:
var date = new FrameworkElementFactory(typeof(XamDateTimeEditor)); date.AddHandler(XamDateTimeEditor.ValueChangedEvent, new RoutedEventHandler(ValueChangedHandler));
private void ValueChangedHandler(object sender, RoutedEventArgs e) { }
Should you have any further questions, please let me know.
Tihomir TonevAssociate Softawre DeveloperInfragistics