Applying combo template issue

Ribbon for WPF Forum

Posted 14 years ago by Balaram Barange
Version: 10.1.0523
Avatar
Hi,

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;
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:

cmbBoxFactory.SetBinding(ComboBox.SelectedItemProperty, new Binding("Value") { RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) } });
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

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bala,

I'm assuming you meant to post this in the PropertyGrid for WPF forum. Either way, could you please put together a small sample project the reproduces the issue and email it over to our support address.


Actipro Software Support

The latest build of this product (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.