Expand Nested Properties At Startup

18 posts, 1 answers
  1. Andrew
    Andrew avatar
    28 posts
    Member since:
    Mar 2013

    Posted 04 Apr 2013 Link to this post

    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.
  2. Answer
    Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 08 Apr 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Chris
    Chris avatar
    23 posts
    Member since:
    May 2011

    Posted 29 Aug 2013 Link to this post

    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.
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 03 Sep 2013 Link to this post

    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 >>
  6. Chris
    Chris avatar
    23 posts
    Member since:
    May 2011

    Posted 03 Sep 2013 Link to this post

    Thanks, it works.
  7. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 05 Feb 2015 Link to this post

    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
           

























  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 09 Feb 2015 Link to this post

    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.

     
  9. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 11 Feb 2015 in reply to Dimitrina Link to this post

    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
  10. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 11 Feb 2015 in reply to Alexandru Link to this post

    Hi!

    I didn't attach the telerik libraries, but i'm using v2014.3.1202.40
  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Feb 2015 Link to this post

    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.

     
  12. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 12 Feb 2015 in reply to Dimitrina Link to this post

    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

  13. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Feb 2015 Link to this post

    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.

     
  14. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 13 Feb 2015 in reply to Dimitrina Link to this post

    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
  15. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 13 Feb 2015 in reply to Dimitrina Link to this post

    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
  16. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Feb 2015 Link to this post

    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.

     
  17. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 16 Feb 2015 in reply to Dimitrina Link to this post

    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
  18. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Feb 2015 Link to this post

    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.

     
  19. Alexandru
    Alexandru avatar
    16 posts
    Member since:
    Nov 2012

    Posted 19 Feb 2015 in reply to Dimitrina Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready