I'm having a problem when I want to bind a control to a windowsFormsHost control. But, as we all know, the Child property is not DP, so I created a wrapper.
/// <summary> /// Bindable version of windows form hosts /// </summary> public class BindableWindowsFormsHost : WindowsFormsHost { /// <summary> /// Max value of the textbox /// </summary> public Control BindableChild { get { return (Control)GetValue(BindableChildProperty); } set { SetValue(BindableChildProperty, value); } } // Using a DependencyProperty as the backing store for Max. This enables animation, styling, binding, etc... public static readonly DependencyProperty BindableChildProperty = DependencyProperty.Register("BindableChild", typeof(Control), typeof(BindableWindowsFormsHost), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnBindableChildChanged))); /// <summary> /// Handles changes to the FlyoutWindowSize property. /// </summary> private static void OnBindableChildChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((WindowsFormsHost)d).Child = e.NewValue as Control; } }
e.NewValue receives the control that I want and installs it correctly, but I donβt see the change reflected. The child is installed, but does not see windowsFormsHost with the new control.
Does anyone have an idea?
Thanks and Regards, Kev84
Kev84 source share