Intersoft.Client.UI.Aqua.UXCollection Namespace > UXTreeView Class : BusyLatency Property |
<CategoryAttribute("Common Properties")> Public Property BusyLatency As Double
Dim instance As UXTreeView Dim value As Double instance.BusyLatency = value value = instance.BusyLatency
[CategoryAttribute("Common Properties")] public double BusyLatency {get; set;}
[CategoryAttribute("Common Properties")] public: property double BusyLatency { double get(); void set ( double value); }
For more advanced scenarios, UXTreeView can also completely delegate the child data retrieval process to your application's logic by setting the LoadOnDemandMode property to UseProcessedItem. This mode is ideal for performance-critical data applications where loading all hierarchical data is not feasible due to the data size. In such scenario, you may want to load only several levels of the data initially, then load the rest of the items on demand as they are being expanded.
UXTreeView is specifically designed to elegantly achieve this scenario using MVVM pattern implementation. UXTreeView exposes ExpandedItem property that you can bind in the ViewModel. This allows you to interact with the entity being expanded and write your own logic to retrieve the child items in the ViewModel. Once the child items become available, you assign the original entity to the ProcessedItem property to notify the control that the loading process is completed.
In this mode, a busy indicator will be automatically displayed in each expanded item during the loading progress. You can determine how soon the busy indicator should appear by setting the BusyLatency property to a value in seconds measurement. The default value is 0.1s.
The following code shows how to implement load on demand in UXTreeView with the LoadOnDemandMode property set to UseProcessedItem and BusyLatency set to 0.002. The example is implemented using MVVM pattern.
C# |
Copy Code
|
---|---|
public class CompanyEmployee : ModelBase { private String _name; public String Name { get { return this._name; } set { if (this._name != value) { this._name = value; OnPropertyChanged("Name"); } } } } |
C# |
Copy Code
|
---|---|
public class Company : ModelBase { private string _section; private ObservableCollection<CompanyEmployee> _employees; public string Section { get { return this._section; } set { if (this._section != value) { this._section = value; OnPropertyChanged("Section"); } } } public ObservableCollection<CompanyEmployee> Employees { get { return this._employees; } set { if (this._employees != value) { this._employees = value; OnPropertyChanged("Employees"); } } } public Company() { this.Employees = new ObservableCollection<CompanyEmployee>(); } } |
C# |
Copy Code
|
---|---|
public class CompanyViewModel : ViewModelBase { private ObservableCollection<Company> _companies; private object _expandedItem; private object _processedItem; public ObservableCollection<Company> Companies { get { return this._companies; } set { if (this._companies != value) { this._companies = value; OnPropertyChanged("Companies"); } } } public object ExpandedItem { get { return this._expandedItem; } set { if (this._expandedItem != value) { this._expandedItem = value; Company obj = value as Company; ObservableCollection<CompanyEmployee> data = new ObservableCollection<CompanyEmployee>(); //using thread if (obj != null && obj.Employees.Count == 0) { var t = new Thread(() => { try { Thread.Sleep(300); for (int i = 0; i < 20; i++) { data.Add(new CompanyEmployee() { Name = obj.Section + ", Employee " + i.ToString() }); } System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { obj.Employees = data; this.ProcessedItem = value; }); } catch { System.Diagnostics.Debug.WriteLine("Debug"); } }); t.Start(); } else this.ProcessedItem = value; OnPropertyChanged("ExpandedItem"); } } } public object ProcessedItem { get { return this._processedItem; } set { if (this._processedItem != value) { this._processedItem = value; OnPropertyChanged("ProcessedItem"); } } } public CompanyViewModel() { this.LoadData(); } private void LoadData() { this.Companies = new ObservableCollection<Company>(); this.Companies.Add(new Company() { Section = "Human Resource" }); this.Companies.Add(new Company() { Section = "Development and Training" }); this.Companies.Add(new Company() { Section = "Developer" }); this.Companies.Add(new Company() { Section = "Support" }); this.Companies.Add(new Company() { Section = "Project Manager" }); } } |
XAML |
Copy Code
|
---|---|
<Intersoft:UXPage> <Intersoft:UXPage.Resources> <ViewModel:CompanyViewModel x:Key="CompanyViewModel" /> </Intersoft:UXPage.Resources> <Grid x:Name="LayoutRoot"> <Grid.Resources> <Intersoft:HierarchicalDataTemplate x:Key="CompanyEmployeeTemplate" ItemsSource="{Binding Employees}"> <TextBlock Text="{Binding Name}" /> </Intersoft:HierarchicalDataTemplate> <Intersoft:HierarchicalDataTemplate x:Key="CompanyTemplate" ItemTemplate="{StaticResource CompanyEmployeeTemplate}" ItemsSource="{Binding Employees}"> <TextBlock Text="{Binding Section}" /> </Intersoft:HierarchicalDataTemplate> </Grid.Resources> <Intersoft:UXTreeView TreeExpandMode="Multiple" Height="300" IsLoadOnDemand="True" BusyLatency="0.002" LoadOnDemandMode="UseProcessedItem" ExpandedItem="{Binding ExpandedItem, Mode=TwoWay}" ProcessedItem="{Binding ProcessedItem, Mode=TwoWay}" ItemsSource="{Binding Companies}" EnableSlidingAnimation"False" DataContext="{StaticResource CompanyViewModel}" ItemTemplate="{StaticResource CompanyTemplate}"> </Intersoft:UXTreeView> </Grid> </Intersoft:UXPage> |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2