This is a migrated thread and some comments may be shown as answers.

PropertyDefinition IsExpanded binding have no effect

3 Answers 106 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
rui
Top achievements
Rank 1
rui asked on 22 Jul 2015, 03:17 AM

I use a checkbox PropertyDefinition  which contains NestedProperties,  I want to achieve the checkbox and the expand keep the same status, when the checkbox is checked the nestedProperties expand and when the checkbox is unchecked the nestedProperties unexpand    the code is as follow

                <telerik:PropertyDefinition
                                            Binding="{Binding ​IsShowDetail}"
                                            IsExpanded="{Binding ​IsShowDetail}">
                    <telerik:PropertyDefinition.NestedProperties>
                        <telerik:PropertyDefinition Binding="{Binding Path=Name,
                                                                      Mode=TwoWay}"/>
                        <telerik:PropertyDefinition Binding="{Binding Path=Description,
                                                                      Mode=TwoWay}"/>
                    </telerik:PropertyDefinition.NestedProperties>
                </telerik:PropertyDefinition>

 The "IsShowDetail " is a bool property,  the "Binging "and "IsExpanded "both binding to this property

but the "IsExpanded "have no effect

what is the reason for this and how to achieve this effect?

thanks 

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 24 Jul 2015, 05:07 PM
Hi,

PropertyDefinition derives from DependencyObject. Thus it supports data binding, but it does not have a default binding source (DataContext). So that you have to defined the source for the IsExpanded binding explicitly. You can expose the assigned Item/ViewModel instance as a StaticResource and refer to it in the binding definition.
The "Binding" property works with data bindinng without specifying explicit source, because it gets assigned to the respective editor control, which generally derives from FrameworkElement and FrameworkElelement supports DataContext. RadPropertyGrid internally assigns the Item as a DataContext for its editors.

Regards,
Ivan Ivanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lakshman
Top achievements
Rank 1
answered on 28 May 2020, 12:43 PM

Hello @Ivan Need an example to bind the IsExpandedProperty and want to add few logical steps depending on expand or collapse of the dropdown of it.

 

Below is the code snippit what i had written:

public bool IsExpanded
        {
            set
            {
                isExpanded = value;
            }

            get
            {
                return isExpanded;
            }
        }

var tagProperty = new CollectionPropertyDefinition()

Binding myBinding = new Binding("IsExpanded");
myBinding.Source = this;
BindingOperations.SetBinding(tagProperty, CollectionPropertyDefinition.IsExpandedProperty, myBinding);

 

The setter need be triggered when dropdown is expanded or collapsed.

 

Thank You,

Lakshman Siddireddy

0
Vera
Telerik team
answered on 02 Jun 2020, 08:59 AM

Hi Lakshman,

In order to trigger the setter of IsExpanded property TwoWay binding have to be set like so:

 myBinding.Mode = BindingMode.TwoWay;

Let me know if you have any other issues.

Regards,
Vera
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
PropertyGrid
Asked by
rui
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Lakshman
Top achievements
Rank 1
Vera
Telerik team
Share this question
or