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

Expand Nested Properties At Startup

17 Answers 318 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 04 Apr 2013, 02:23 PM
I've searched for this for a while.  Is there a way to expand/collapse nested properties via code-behind?  It would be nice to have all properties expanded by default in my program.

17 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 08 Apr 2013, 10:09 AM
Hello Andrew,

In order to achieve your goal, you can handle RadPropertyGrid's  Loaded event and execute the following code:

this.Dispatcher.BeginInvoke(new Action(() => { (sender as RadPropertyGrid).ChildrenOfType<RadToggleButton>().FirstOrDefault(b => b.Name == "PART_NestedPropertiesButton").IsChecked = true; }));

I believe that is what you are looking for.

All the best,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Chris
Top achievements
Rank 1
answered on 29 Aug 2013, 07:33 PM
I did the way you suggested, it works but before the expanded field shows, I got a dispatcher exception dialog (please see the attachment).  Any idea?
Thanks.
0
Ivan Ivanov
Telerik team
answered on 03 Sep 2013, 03:26 PM
Hi,

 You can try setting the IsExpanded property of PropertyDefinition on the occurrence of AutoGeneratingPropertyDefinition event. It is a relatively new property, which was introduced with Q2 2013.

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Chris
Top achievements
Rank 1
answered on 03 Sep 2013, 11:26 PM
Thanks, it works.
0
Alexandru
Top achievements
Rank 1
answered on 05 Feb 2015, 12:22 PM
Hi!

I have a property grid, and it has NestedPropertiesVisibility="Visible". I want to have all the children expanded by default, and for this i have edited the grid's template, and changed the flatTemplate like this:
 <DataTemplate x:Key="flatTemplate">
            <ItemsControl ItemsSource="{Binding Converter={StaticResource FlatItemSourceConverter}}" Style="{StaticResource ItemsControlStyle}" IsTabStop="False">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <telerik:PropertyGridField IsExpanded="True" Content="{Binding}" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding Visibility}"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>


I have added the isExpanded property to true. However, the whole application crushes, and the only difference is the IsExpanded property. 

I have the sample project, but cannot upload it in this post. How can I do this?

Can you help please?

Regards,
Alex
       

























0
Dimitrina
Telerik team
answered on 09 Feb 2015, 07:25 AM
Hello Alex,

Indeed, it is just allowed to add screenshots with the forum posts. You can open a new support thread and attach the sample solution there. 

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexandru
Top achievements
Rank 1
answered on 11 Feb 2015, 07:01 AM
How can I open a new support thread?
I get:
"Your license has expired or does not include dedicated support. Please visit Renewals and Upgrades or contact your license holder."

Anyway, I have renamed the archive as jpg, can you change please the extension back to zip, and extract tha project?

Regards,
Alex
0
Alexandru
Top achievements
Rank 1
answered on 11 Feb 2015, 08:58 AM
Hi!

I didn't attach the telerik libraries, but i'm using v2014.3.1202.40
0
Dimitrina
Telerik team
answered on 12 Feb 2015, 11:37 AM
Hello,

Thank you for providing a sample project. I was indeed able to reproduce the issue.

Is the change you refer to the only change you made when editing the template:
<DataTemplate x:Key="flatTemplate">
     <ItemsControl ItemsSource="{Binding Converter={StaticResource FlatItemSourceConverter}}" Style="{StaticResource ItemsControlStyle}" IsTabStop="False">
         <ItemsControl.ItemTemplate>
             <DataTemplate>
                 <telerik:PropertyGridField IsExpanded="True" Content="{Binding}" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding Visibility}"/>
             </DataTemplate>
         </ItemsControl.ItemTemplate>
     </ItemsControl>
</DataTemplate>
 
As it turns out once I commented the template of RadPropertyGrid as you have redefined it and I subscribed for the AutoGeneratingPropertyDefinition, setting the IsExpanded property of PropertyDefinition, it worked fine. Is it an option for you to use this approach instead? 


Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexandru
Top achievements
Rank 1
answered on 12 Feb 2015, 11:50 AM
Hi Dimitrina!

Thanks for your answer. I also used this approach, unsuccesfully.
The property grid I am having issues with contains collection editors, which I have also redefined to be able to costomize them. They also contain property grids, nested. I was able to use the event you mentioned to trigger a command instead, on all property grids, and the expand was working relatively fine, however:
  1. the grids flicker 3-4 seconds when expanding all properties, on all levels
  2. if the object binded to the primary grid is very complex (if it has a lot of children with lists of children with lists of children), these expansions will result in a strage exception, similar to the one mentioned above

I was hoping to be able to have all properties expanded by default. And I don't understand why setting this property, IsExpanded, to true, has such a strange behaviour. 

I also redefined the PropertyGridField, based on telerik xaml source code, until I reached the '+' toggle button, to eliminate any Visual effects, but still was not able to sort this out

Thanks,
Alex

0
Dimitrina
Telerik team
answered on 13 Feb 2015, 11:16 AM
Hello,

As it turns out we can currently suggest using the approach with expanding the PropertyDefinitions when the AutoGeneratingPropertyDefinition event is raised.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexandru
Top achievements
Rank 1
answered on 13 Feb 2015, 11:27 AM
Hi!

Ok, but is the only solution? If yes I'm dissapointed because as I mentioned before, this doesn't work well on complex objects. I can provide an example if you require

Regards,
Alex
0
Alexandru
Top achievements
Rank 1
answered on 13 Feb 2015, 11:28 AM
Hi!

Ok, but is this the only solution? If yes, I'm dissapointed, because as I've mentioned above, this doesn't work well on more complex objects. I can provide a sample if you require

Regards,
Alex
0
Dimitrina
Telerik team
answered on 13 Feb 2015, 12:14 PM
Hi Alex,

I am afraid we cannot suggest another way to achieve your goal. Please excuse us for the inconvenience.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexandru
Top achievements
Rank 1
answered on 16 Feb 2015, 09:04 AM
Hi!

Ok, I understand, but please tell me if in future versions of the PropertyGrid Control will this be fixed or will remain the same

Regards,
Alex
0
Dimitrina
Telerik team
answered on 16 Feb 2015, 02:07 PM
Hi,

I can also suggest you one alternative solution subscribing for the Loaded event of RadPropertyGrid.
For example:
private void grdPropr_Loaded(object sender, RoutedEventArgs e)
{
    grdPropr.PropertyDefinitions.SuspendNotifications();
    foreach (var item in grdPropr.PropertyDefinitions)
    {
        item.IsExpanded = true;
    }
 
    grdPropr.PropertyDefinitions.ResumeNotifications();
}

Please note you should additionally configure the control with:
RenderMode="Flat" 
as this is only supported in Flat mode.

Upon your request, I logged the suggestion as a Feature Request in our public Feedback Portal. You can vote for it and also follow its progress here:
Allow expanding nested properties at startup.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexandru
Top achievements
Rank 1
answered on 19 Feb 2015, 06:49 AM
Hi!

Thank you for your response, I managed to solve the problem by using RenderMode="Flat". This helps solving the exceptions which occured before.

Regards,
Alex
Tags
PropertyGrid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Chris
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Alexandru
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or