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

IsLoadOnDemand animation

3 Answers 136 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lauren Nickerson
Top achievements
Rank 1
Lauren Nickerson asked on 11 Aug 2010, 02:14 AM
Hello, I'm just wondering if there's a way to access the animation that happens when IsLoadOnDemandEnabled is set to true. The thing is that I found out that is not possible to use the IsLoadOnDemand functionality when binding the RadTreeViewItems through the RadTreeView ItemsSource property, so I'm wondering if there's another way to show said animation. Ideally it would be through binding something like:

<Style TargetType="{x:Type telerik:RadTreeViewItem}">
    <Setter Property="ShowLoadingAnimation" Value="{Binding IsLoading}" />
</Style>

Doing it this way, I wouldn't have to do anything in the code, and also would make all the RadTreeViewItems bind the IsLoading property to whatever they use to show the animation.

If it's not possible that way, let me know which other alternatives do I have. 

And just so we're clear, this is the animation I'm talking about:

http://www.screencast.com/users/CarloToribio/folders/Jing/media/28659147-3a7c-4cbe-afab-e1555e0c6f4a

Thanks!

3 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 13 Aug 2010, 09:44 AM
Hi Lauren Nickerson,

The loading animation can be controlled with the IsLoadingOnDemand - setting this property together with IsLoadOnDemandEnabled to "True" will show the animation. Normally if IsLoadOnDemandEnabled = true is set on the TreeView the animation will start automatically. It will stop automatically as well when items are added to the TreeViewItem that is loading. If no items are available, it can be turned off by setting IsLoadOnDemandEnabled = false (on the item).

Can you elaborate a little on the issue you have with binding the TreeView?

Load-on-demand should easily work with a databound TreeView.

All the best,
Miroslav
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Lauren Nickerson
Top achievements
Rank 1
answered on 14 Aug 2010, 12:04 AM
It seems like it doesn't work, unless I'm doing something wrong. I have a DataBound RadTreeView and the LoadOnDemand event does not fire, and I can never see the loading animation. Take a look at the code below, I'm creating 2 Crowd objects each with a List of People, then I bind the objects to a RadTreeView which has its IsLoadOnDemandEnabled property set to false, and is subscribed to the treeView_LoadOnDemand event handler, treeView_LoadOnDemand never gets fired. I put a breakpoint there and the code never hits it.
 Let me know.

Thanks.

C#

using System.Collections.Generic;
using System.Windows;
 
namespace LoadOnDemandTests
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
 
            Crowd crowd1 = new Crowd("Singers", new List<Person>()
            {
                new Person("Jim Morrison"),
                new Person("Robert Plant"),
                new Person("Roger Waters"),
                new Person("Ozzy Osbourne")
            });
 
            Crowd crowd2 = new Crowd("Guitarists", new List<Person>()
            {
                new Person("Jimmy Page"),
                new Person("Slash"),
                new Person("Tonny Iommi"),
                new Person("Kirk Hammet")
            });
 
            this.DataContext = new List<Crowd>() { crowd1, crowd2 };
        }
 
        private void treeView_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
  // breakpoint here
        }
    }
 
    public class Crowd
    {
        public string CrowdId { get; set; }
        public List<Person> People { get; set; }
 
        public Crowd(string crowdId, List<Person> people)
        {
            this.People = people;
            this.CrowdId = crowdId;
        }
 
        public override string ToString()
        {
            return this.CrowdId;
        }
    }
 
    public class Person
    {
        public string Name { get; set; }
 
        public Person(string name)
        {
            this.Name = name;
        }
 
        public override string ToString()
        {
            return this.Name;
        }
    }
}

XAML

<Window x:Class="LoadOnDemandTests.Window1"
    xmlns:local="clr-namespace:LoadOnDemandTests"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    Title="Window1"
    Height="401"
    Width="626">
    <Window.Resources>
        <HierarchicalDataTemplate DataType="{x:Type local:Crowd}" ItemsSource="{Binding People}">
            <Label Content="{Binding CrowdId}" />
        </HierarchicalDataTemplate>
    </Window.Resources>
    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <telerik:RadTreeView x:Name="treeView" Grid.Row="0" ItemsSource="{Binding}" IsLoadOnDemandEnabled="True" LoadOnDemand="treeView_LoadOnDemand" />
    </Grid>
</Window>
0
Hristo
Telerik team
answered on 18 Aug 2010, 04:54 PM
Hi Lauren Nickerson,

You are doing it right. The animation is fired when you press the expand arrow on second level. You can't see the animation when expanding the first level because each element of that level already has its children. However if you hit the arrow on some of the persons on second level, the animation will start and you shall hit the breakpoint.

I'm attaching a project representing a slightly modified version of your code.

Best wishes,
Hristo Milyakov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Lauren Nickerson
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Lauren Nickerson
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or