Show Plus/Minus based on Property Value

3 posts, 0 answers
  1. Tim
    Tim avatar
    114 posts
    Member since:
    Aug 2011

    Posted 04 Dec 2011 Link to this post

    Hello!

    I want to use some kind of dynamic loading using the RadTreeListView; so when the control gets loaded only the first level is loaded and when the user expands one item, its corresponding items should be loaded. Unfortunately there is no plus sign to expand when the item has not any elements yet! What I need is some kind of property, for example, HasChildren and based on that property there should be a plus sign or not. Otherwise I have to work with dummy items and I think that solution is not very clean and elegant. So I tried to use the HierarchyExpandButtonStyle but without luck - nothing is displayed when there are no child elements yet. How can something like that be achieved? Can one use the HierarchyExpandButtonStyle? Any workarounds?

    A BIG, BIG thanks in advance,
    Tim.
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Dec 2011 Link to this post

    Hi Tim,

     You can use IsExpandable property of TreeListViewRow to achieve your goal. With the official Q3 2011 binding is not supported to this property (you can use RowLoaded to set it explicitly) however with our upcoming latest build (later Today) you will be able to use is in style selectors and setter property value binding (Silverlight 5/WPF). Here is an example with StyleSelector:

               <telerik:RadTreeListVIew.RowStyleSelector>
                    <telerik:ConditionalStyleSelector>
                        <telerik:StyleRule Condition="ShipCountry = 'France'">
                            <Style TargetType="telerik:TreeListViewRow">
                                <Setter Property="IsExpandable" Value="True" />
                            </Style>
                        </telerik:StyleRule> 
                        <telerik:StyleRule Condition="ShipCountry != 'France'">
                            <Style TargetType="telerik:TreeListViewRow">
                                <Setter Property="IsExpandable" Value="False" />
                            </Style>
                        </telerik:StyleRule>
                    </telerik:ConditionalStyleSelector>
                </telerik:RadTreeListVIew.RowStyleSelector>

    Greetings,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Tim
    Tim avatar
    114 posts
    Member since:
    Aug 2011

    Posted 05 Dec 2011 Link to this post

    Hi Vlad,

    thanks a lot for your answer and your example! Silverlight 5 - for my taste - is a little bit too beta; does anyone know something about the final release date? So with Silverlight 4 and the current Telerik release, I have to use the RowLoaded event? I'll give it a try...

    Thanks again and all the best,
    Tim.
Back to Top