Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1415
XamDateTimeInput in DataTemplate
posted

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..., 

Parents
  • 1500
    Offline posted

    Hello Patrick,

    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.

    Sincerely,

    Tihomir Tonev
    Associate Softawre Developer
    Infragistics

Reply Children