We have IPAddressControl which is displayed on PropertyGrid through the use of DataTemplate. IPAddressControl has DependancyProperty called "IP". When we assign value to propertyGridItem.Value, it is reflected in IPAddressControl. But when we change value in IPAddressControl, that value is not set to "Value property" of propertyGridItem item. What should we do so that "Value Property" of propertyGridItem item is set?
Ex.
DataTemplate dataTemplate = new DataTemplate(); // DataTemple for Combo box
FrameworkElementFactory ipAddressFactory = new FrameworkElementFactory(typeof(IPAddressControl));
ipAddressFactory.SetBinding(IPAddressControl.IP, new Binding("Value") { RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) } });
ipAddressFactory.SetBinding(IPAddressControl.IsEnabledProperty, new Binding("IsEnabled") { Source = propertyGridItem });
dataTemplate.VisualTree = ipAddressFactory;
propertyGridItem.ValueTemplate = dataTemplate;
Ex.
DataTemplate dataTemplate = new DataTemplate(); // DataTemple for Combo box
FrameworkElementFactory ipAddressFactory = new FrameworkElementFactory(typeof(IPAddressControl));
ipAddressFactory.SetBinding(IPAddressControl.IP, new Binding("Value") { RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) } });
ipAddressFactory.SetBinding(IPAddressControl.IsEnabledProperty, new Binding("IsEnabled") { Source = propertyGridItem });
dataTemplate.VisualTree = ipAddressFactory;
propertyGridItem.ValueTemplate = dataTemplate;