Skip to content

Commit 86e7a23

Browse files
How to load child items on demand in wpf treeview
1 parent 0a38638 commit 86e7a23

26 files changed

+1462
-0
lines changed

LoadOnDemand/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
5+
</startup>
6+
</configuration>

LoadOnDemand/App.ico

4.19 KB
Binary file not shown.

LoadOnDemand/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application
2+
x:Class="LoadOnDemandDemo.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="clr-namespace:LoadOnDemandDemo"
6+
StartupUri="LoadOnDemand.xaml">
7+
<Application.Resources />
8+
</Application>

LoadOnDemand/App.xaml.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#region Copyright Syncfusion Inc. 2001 - 2011
2+
// Copyright Syncfusion Inc. 2001 - 2011. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Configuration;
12+
using System.Data;
13+
using System.Linq;
14+
using System.Windows;
15+
using Syncfusion.Licensing;
16+
17+
namespace LoadOnDemandDemo
18+
{
19+
/// <summary>
20+
/// Interaction logic for App.xaml
21+
/// </summary>
22+
public partial class App : Application
23+
{
24+
public App()
25+
{
26+
SyncfusionLicenseProvider.RegisterLicense(DemoCommon.FindLicenseKey());
27+
}
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Windows.Input;
3+
4+
namespace LoadOnDemandDemo
5+
{
6+
public class OnDemandCommand : ICommand
7+
{
8+
private Action<object> executeOnDemandLoading;
9+
private Func<object, bool> canExecuteOnDemandLoading;
10+
11+
public OnDemandCommand(Action<object> executeOnDemandLoading, Func<object, bool> canExecuteOnDemandLoading)
12+
{
13+
this.executeOnDemandLoading = executeOnDemandLoading;
14+
this.canExecuteOnDemandLoading = canExecuteOnDemandLoading;
15+
}
16+
17+
public event EventHandler CanExecuteChanged;
18+
19+
public bool CanExecute(object parameter)
20+
{
21+
return this.canExecuteOnDemandLoading(parameter);
22+
}
23+
24+
public void Execute(object parameter)
25+
{
26+
this.executeOnDemandLoading(parameter);
27+
}
28+
}
29+
}

LoadOnDemand/LoadOnDemand.xaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<Window
2+
x:Class="LoadOnDemandDemo.LoadOnDemand"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:LoadOnDemandDemo"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:skin="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
9+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
10+
Title="Load On Demand"
11+
Width="550"
12+
Height="600"
13+
skin:SfSkinManager.VisualStyle="MaterialLight"
14+
Icon="App.Ico"
15+
WindowStartupLocation="CenterScreen"
16+
mc:Ignorable="d">
17+
<Window.DataContext>
18+
<local:MusicInfoRepository />
19+
</Window.DataContext>
20+
<Grid>
21+
<syncfusion:SfTreeView
22+
x:Name="sfTreeView"
23+
Margin="10"
24+
AllowDragging="True"
25+
BorderBrush="LightGray"
26+
BorderThickness="1"
27+
ExpandActionTrigger="Node"
28+
FocusVisualStyle="{x:Null}"
29+
IsAnimationEnabled="True"
30+
ItemHeight="30"
31+
LoadOnDemandCommand="{Binding TreeViewOnDemandCommand}"
32+
ItemsSource="{Binding Menu}" >
33+
<syncfusion:SfTreeView.ItemTemplate>
34+
<DataTemplate>
35+
<Label
36+
VerticalContentAlignment="Center"
37+
Content="{Binding ItemName}"
38+
FocusVisualStyle="{x:Null}"
39+
FontSize="12" />
40+
</DataTemplate>
41+
</syncfusion:SfTreeView.ItemTemplate>
42+
</syncfusion:SfTreeView>
43+
</Grid>
44+
</Window>

LoadOnDemand/LoadOnDemand.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace LoadOnDemandDemo
17+
{
18+
/// <summary>
19+
/// Interaction logic for LoadOnDemand.xaml
20+
/// </summary>
21+
public partial class LoadOnDemand : Window
22+
{
23+
public LoadOnDemand()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{675472F3-FAEA-49BC-8639-4176D3B083DC}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>LoadOnDemandDemo</RootNamespace>
10+
<AssemblyName>LoadOnDemandDemo</AssemblyName>
11+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<Deterministic>true</Deterministic>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<PlatformTarget>AnyCPU</PlatformTarget>
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29+
<PlatformTarget>AnyCPU</PlatformTarget>
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="Syncfusion.SampleLayout.WPF">
39+
<SpecificVersion>False</SpecificVersion>
40+
</Reference>
41+
<Reference Include="Syncfusion.Shared.Wpf">
42+
<SpecificVersion>False</SpecificVersion>
43+
</Reference>
44+
<Reference Include="Syncfusion.SfTreeView.WPF" >
45+
<SpecificVersion>False</SpecificVersion>
46+
</Reference>
47+
<Reference Include="Syncfusion.SfSkinManager.WPF">
48+
<SpecificVersion>False</SpecificVersion>
49+
<Private>True</Private>
50+
</Reference>
51+
<Reference Include="Syncfusion.Themes.MaterialLight.WPF">
52+
<SpecificVersion>False</SpecificVersion>
53+
<Private>True</Private>
54+
</Reference>
55+
<Reference Include="System" />
56+
<Reference Include="System.Data" />
57+
<Reference Include="System.Xml" />
58+
<Reference Include="Microsoft.CSharp" />
59+
<Reference Include="System.Core" />
60+
<Reference Include="System.Xml.Linq" />
61+
<Reference Include="System.Data.DataSetExtensions" />
62+
<Reference Include="System.Net.Http" />
63+
<Reference Include="System.Xaml">
64+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
65+
</Reference>
66+
<Reference Include="WindowsBase" />
67+
<Reference Include="PresentationCore" />
68+
<Reference Include="PresentationFramework" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<ApplicationDefinition Include="App.xaml">
72+
<Generator>MSBuild:Compile</Generator>
73+
<SubType>Designer</SubType>
74+
</ApplicationDefinition>
75+
<Compile Include="ViewModel\MusicInfoRepository.cs" />
76+
<Compile Include="Command\OnDemandCommand.cs" />
77+
<Page Include="LoadOnDemand.xaml">
78+
<Generator>MSBuild:Compile</Generator>
79+
<SubType>Designer</SubType>
80+
</Page>
81+
<Compile Include="App.xaml.cs">
82+
<DependentUpon>App.xaml</DependentUpon>
83+
<SubType>Code</SubType>
84+
</Compile>
85+
<Compile Include="LoadOnDemand.xaml.cs">
86+
<DependentUpon>LoadOnDemand.xaml</DependentUpon>
87+
<SubType>Code</SubType>
88+
</Compile>
89+
</ItemGroup>
90+
<ItemGroup>
91+
<Compile Include="Model\MusicInfo.cs" />
92+
<Compile Include="Properties\AssemblyInfo.cs">
93+
<SubType>Code</SubType>
94+
</Compile>
95+
<Compile Include="Properties\Resources.Designer.cs">
96+
<AutoGen>True</AutoGen>
97+
<DesignTime>True</DesignTime>
98+
<DependentUpon>Resources.resx</DependentUpon>
99+
</Compile>
100+
<Compile Include="Properties\Settings.Designer.cs">
101+
<AutoGen>True</AutoGen>
102+
<DependentUpon>Settings.settings</DependentUpon>
103+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
104+
</Compile>
105+
<EmbeddedResource Include="Properties\Resources.resx">
106+
<Generator>ResXFileCodeGenerator</Generator>
107+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
108+
</EmbeddedResource>
109+
<None Include="Properties\Settings.settings">
110+
<Generator>SettingsSingleFileGenerator</Generator>
111+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
112+
</None>
113+
</ItemGroup>
114+
<ItemGroup>
115+
<None Include="App.config" />
116+
</ItemGroup>
117+
<ItemGroup>
118+
<Resource Include="App.ico" />
119+
</ItemGroup>
120+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
121+
<ItemGroup>
122+
<Reference Include="Syncfusion.Licensing" />
123+
</ItemGroup>
124+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadOnDemandDemo_2010", "LoadOnDemandDemo_2010.csproj", "{32C01585-2D4A-4D70-A995-83DEAD479CF6}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Debug-Xml|Any CPU = Debug-Xml|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
Release-Xml|Any CPU = Release-Xml|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Debug-Xml|Any CPU.ActiveCfg = Debug|Any CPU
17+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Debug-Xml|Any CPU.Build.0 = Debug|Any CPU
18+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
21+
{3BC5F7F2-64B9-4F32-934D-BA0026BA85E7}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
GlobalSection(ExtensibilityGlobals) = postSolution
27+
SolutionGuid = {83543171-DAA1-4E4D-8E1F-70EB2EFAF2A4}
28+
EndGlobalSection
29+
EndGlobal

0 commit comments

Comments
 (0)