
Hi,
We are applying combo template on our propertyGridItem (an instance of PropertyGridPropertyItem class) as:With above code when we close the dialog (having propertycontrol), the dialog is not getting garbage collected, we observed that if we comment below line then it works fine:
could you please let us know what are we missing here, any alternative or what are our options to clear this type of binding on dialog close.
Thanks and Regards,
Balaram
We are applying combo template on our propertyGridItem (an instance of PropertyGridPropertyItem class) as:
DataTemplate dataTemplate = new DataTemplate(); // DataTemple for Combo box
FrameworkElementFactory parentFactory = new FrameworkElementFactory(typeof(Grid));
FrameworkElementFactory childFactoryTxtBox = new FrameworkElementFactory(typeof(TextBox));
childFactoryTxtBox.SetBinding(TextBox.TextProperty, new Binding("Value") { RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) }, Mode = BindingMode.TwoWay, ValidatesOnExceptions = true, NotifyOnValidationError = true });
Binding comboBinding = new Binding("ItemCollection");
FrameworkElementFactory cmbBoxFactory = new FrameworkElementFactory(typeof(ComboBox));
cmbBoxFactory.SetBinding(ComboBox.ItemsSourceProperty, comboBinding);
cmbBoxFactory.SetBinding(ComboBox.SelectedItemProperty, new Binding("Value") { RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) } });
parentFactory.AppendChild(childFactoryTxtBox);
parentFactory.AppendChild(cmbBoxFactory);
dataTemplate.VisualTree = parentFactory;
propertyGridItem.ValueTemplate = dataTemplate;
cmbBoxFactory.SetBinding(ComboBox.SelectedItemProperty, new Binding("Value") { RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) } });
Thanks and Regards,
Balaram