├── MauiTreeView ├── Resources │ ├── Images │ │ ├── item.png │ │ ├── blank.png │ │ ├── openglyph.png │ │ ├── folderopen.png │ │ ├── collpsedglyph.png │ │ ├── folderclosed.png │ │ └── dotnet_bot.svg │ ├── Fonts │ │ ├── OpenSans-Regular.ttf │ │ └── OpenSans-Semibold.ttf │ ├── AppIcon │ │ ├── appicon.svg │ │ └── appiconfg.svg │ ├── Raw │ │ └── AboutAssets.txt │ ├── Splash │ │ └── splash.svg │ └── Styles │ │ ├── Colors.xaml │ │ └── Styles.xaml ├── AppShell.xaml.cs ├── Properties │ └── launchSettings.json ├── App.xaml.cs ├── Sample │ ├── Models │ │ ├── Company.cs │ │ ├── Employee.cs │ │ └── Department.cs │ ├── Views │ │ ├── CompanyPage.xaml │ │ └── CompanyPage.xaml.cs │ ├── Helpers │ │ └── CompanyTreeViewBuilder.cs │ └── Services │ │ └── DataService.cs ├── Models │ ├── XamlItem.cs │ └── XamlItemGroup.cs ├── Platforms │ ├── Android │ │ ├── Resources │ │ │ └── values │ │ │ │ └── colors.xml │ │ ├── MainApplication.cs │ │ ├── AndroidManifest.xml │ │ └── MainActivity.cs │ ├── iOS │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ └── Info.plist │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ └── Info.plist │ ├── Windows │ │ ├── App.xaml │ │ ├── app.manifest │ │ ├── App.xaml.cs │ │ └── Package.appxmanifest │ └── Tizen │ │ ├── Main.cs │ │ └── tizen-manifest.xml ├── MainPage.xaml.cs ├── AppShell.xaml ├── App.xaml ├── MauiProgram.cs ├── Controls │ ├── ResourceImage.cs │ ├── ExpandButtonContent.cs │ ├── TreeView.cs │ └── TreeViewNode.cs ├── MainPage.xaml └── MauiTreeView.csproj ├── MauiTreeView.sln ├── .gitattributes └── .gitignore /MauiTreeView/Resources/Images/item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Images/item.png -------------------------------------------------------------------------------- /MauiTreeView/Resources/Images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Images/blank.png -------------------------------------------------------------------------------- /MauiTreeView/Resources/Images/openglyph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Images/openglyph.png -------------------------------------------------------------------------------- /MauiTreeView/Resources/Images/folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Images/folderopen.png -------------------------------------------------------------------------------- /MauiTreeView/Resources/Images/collpsedglyph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Images/collpsedglyph.png -------------------------------------------------------------------------------- /MauiTreeView/Resources/Images/folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Images/folderclosed.png -------------------------------------------------------------------------------- /MauiTreeView/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /MauiTreeView/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icebeam7/MauiTreeView/HEAD/MauiTreeView/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /MauiTreeView/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace MauiTreeView; 2 | 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /MauiTreeView/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /MauiTreeView/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace MauiTreeView; 2 | 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | 9 | MainPage = new AppShell(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /MauiTreeView/Sample/Models/Company.cs: -------------------------------------------------------------------------------- 1 | //S1 2 | namespace MauiTreeView.Sample.Models 3 | { 4 | public class Company 5 | { 6 | public int CompanyId { get; set; } 7 | public string CompanyName { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /MauiTreeView/Models/XamlItem.cs: -------------------------------------------------------------------------------- 1 | //0 images 2 | //1 3 | 4 | namespace MauiTreeView.Models 5 | { 6 | [Serializable] 7 | public class XamlItem 8 | { 9 | public string Key { get; set; } 10 | public int ItemId { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /MauiTreeView/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace MauiTreeView; 4 | 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace MauiTreeView; 4 | 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | -------------------------------------------------------------------------------- /MauiTreeView/Sample/Models/Employee.cs: -------------------------------------------------------------------------------- 1 | //S3 2 | namespace MauiTreeView.Sample.Models 3 | { 4 | public class Employee 5 | { 6 | public int EmployeeId { get; set; } 7 | public string EmployeeName { get; set; } 8 | public int DepartmentId { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MauiTreeView/Sample/Models/Department.cs: -------------------------------------------------------------------------------- 1 | //S2 2 | namespace MauiTreeView.Sample.Models 3 | { 4 | public class Department 5 | { 6 | public int DepartmentId { get; set; } 7 | public string DepartmentName { get; set; } 8 | public int ParentDepartmentId { get; set; } 9 | public int CompanyId { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /MauiTreeView/Models/XamlItemGroup.cs: -------------------------------------------------------------------------------- 1 | //2 2 | namespace MauiTreeView.Models 3 | { 4 | [Serializable] 5 | public class XamlItemGroup 6 | { 7 | public List Children { get; } = new (); 8 | public List XamlItems { get; } = new (); 9 | 10 | public string Name { get; set; } 11 | public int GroupId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Maui; 3 | using Microsoft.Maui.Hosting; 4 | 5 | namespace MauiTreeView; 6 | 7 | class Program : MauiApplication 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | 11 | static void Main(string[] args) 12 | { 13 | var app = new Program(); 14 | app.Run(args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace MauiTreeView; 5 | 6 | [Application] 7 | public class MainApplication : MauiApplication 8 | { 9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 10 | : base(handle, ownership) 11 | { 12 | } 13 | 14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 15 | } 16 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace MauiTreeView; 5 | 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace MauiTreeView; 5 | 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace MauiTreeView; 6 | 7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 8 | public class MainActivity : MauiAppCompatActivity 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /MauiTreeView/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace MauiTreeView; 2 | 3 | public partial class MainPage : ContentPage 4 | { 5 | int count = 0; 6 | 7 | public MainPage() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void OnCounterClicked(object sender, EventArgs e) 13 | { 14 | count++; 15 | 16 | if (count == 1) 17 | CounterBtn.Text = $"Clicked {count} time"; 18 | else 19 | CounterBtn.Text = $"Clicked {count} times"; 20 | 21 | SemanticScreenReader.Announce(CounterBtn.Text); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /MauiTreeView/Sample/Views/CompanyPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /MauiTreeView/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /MauiTreeView/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /MauiTreeView/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with you package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /MauiTreeView/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using MauiTreeView.Sample.Helpers; 2 | using MauiTreeView.Sample.Services; 3 | using MauiTreeView.Sample.Views; 4 | 5 | namespace MauiTreeView; 6 | 7 | public static class MauiProgram 8 | { 9 | public static MauiApp CreateMauiApp() 10 | { 11 | var builder = MauiApp.CreateBuilder(); 12 | builder 13 | .UseMauiApp() 14 | .ConfigureFonts(fonts => 15 | { 16 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 17 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 18 | }); 19 | 20 | builder.Services.AddSingleton(); 21 | builder.Services.AddSingleton(); 22 | builder.Services.AddTransient(); 23 | 24 | return builder.Build(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Tizen/tizen-manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | appicon.xhigh.png 7 | 8 | 9 | 10 | 11 | http://tizen.org/privilege/internet 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | 3 | // To learn more about WinUI, the WinUI project structure, 4 | // and more about our project templates, see: http://aka.ms/winui-project-info. 5 | 6 | namespace MauiTreeView.WinUI; 7 | 8 | /// 9 | /// Provides application-specific behavior to supplement the default Application class. 10 | /// 11 | public partial class App : MauiWinUIApplication 12 | { 13 | /// 14 | /// Initializes the singleton application object. This is the first line of authored code 15 | /// executed, and as such is the logical equivalent of main() or WinMain(). 16 | /// 17 | public App() 18 | { 19 | this.InitializeComponent(); 20 | } 21 | 22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /MauiTreeView/Sample/Views/CompanyPage.xaml.cs: -------------------------------------------------------------------------------- 1 | //S6 and S7 2 | using MauiTreeView.Sample.Services; 3 | using MauiTreeView.Sample.Helpers; 4 | 5 | namespace MauiTreeView.Sample.Views; 6 | 7 | public partial class CompanyPage : ContentPage 8 | { 9 | DataService service; 10 | CompanyTreeViewBuilder companyTreeViewBuilder; 11 | 12 | public CompanyPage(DataService service, CompanyTreeViewBuilder companyTreeViewBuilder) 13 | { 14 | InitializeComponent(); 15 | 16 | this.service = service; 17 | this.companyTreeViewBuilder = companyTreeViewBuilder; 18 | 19 | ProcessTreeView(); 20 | } 21 | 22 | private void ProcessTreeView() 23 | { 24 | var xamlItemGroups = companyTreeViewBuilder.GroupData(service); 25 | var rootNodes = TheTreeView.ProcessXamlItemGroups(xamlItemGroups); 26 | TheTreeView.RootNodes = rootNodes; 27 | } 28 | } -------------------------------------------------------------------------------- /MauiTreeView/Controls/ResourceImage.cs: -------------------------------------------------------------------------------- 1 | //3 2 | namespace MauiTreeView.Controls 3 | { 4 | public class ResourceImage : Image 5 | { 6 | public static readonly BindableProperty ResourceProperty = BindableProperty.Create(nameof(Resource), typeof(string), typeof(string), null, BindingMode.OneWay, null, ResourceChanged); 7 | 8 | private static void ResourceChanged(BindableObject bindable, object oldvalue, object newvalue) 9 | { 10 | var resourceString = (string)newvalue; 11 | var imageControl = (Image)bindable; 12 | 13 | //imageControl.Source = ImageSource.FromResource(resourceString, Assembly.GetAssembly(typeof(ResourceImage))); 14 | imageControl.Source = ImageSource.FromFile(resourceString); 15 | } 16 | 17 | public string Resource 18 | { 19 | get => (string)GetValue(ResourceProperty); 20 | set => SetValue(ResourceProperty, value); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/MacCatalyst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 1 8 | 2 9 | 10 | UIRequiredDeviceCapabilities 11 | 12 | arm64 13 | 14 | UISupportedInterfaceOrientations 15 | 16 | UIInterfaceOrientationPortrait 17 | UIInterfaceOrientationLandscapeLeft 18 | UIInterfaceOrientationLandscapeRight 19 | 20 | UISupportedInterfaceOrientations~ipad 21 | 22 | UIInterfaceOrientationPortrait 23 | UIInterfaceOrientationPortraitUpsideDown 24 | UIInterfaceOrientationLandscapeLeft 25 | UIInterfaceOrientationLandscapeRight 26 | 27 | XSAppIconAssets 28 | Assets.xcassets/appicon.appiconset 29 | 30 | 31 | -------------------------------------------------------------------------------- /MauiTreeView/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | 32 | 33 | -------------------------------------------------------------------------------- /MauiTreeView.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31611.283 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiTreeView", "MauiTreeView\MauiTreeView.csproj", "{57545D07-1EBF-4D83-8446-9C296256FBF4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {57545D07-1EBF-4D83-8446-9C296256FBF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {57545D07-1EBF-4D83-8446-9C296256FBF4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {57545D07-1EBF-4D83-8446-9C296256FBF4}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 17 | {57545D07-1EBF-4D83-8446-9C296256FBF4}.Release|Any CPU.ActiveCfg = Release|Any CPU 18 | {57545D07-1EBF-4D83-8446-9C296256FBF4}.Release|Any CPU.Build.0 = Release|Any CPU 19 | {57545D07-1EBF-4D83-8446-9C296256FBF4}.Release|Any CPU.Deploy.0 = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | GlobalSection(ExtensibilityGlobals) = postSolution 25 | SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /MauiTreeView/Controls/ExpandButtonContent.cs: -------------------------------------------------------------------------------- 1 | // 4 2 | namespace MauiTreeView.Controls 3 | { 4 | //set what icons shows for expanded/Collapsed/Leafe Nodes or on request node expand icon (when ShowExpandButtonIfEmpty true). 5 | public class ExpandButtonContent : ContentView 6 | { 7 | protected override void OnBindingContextChanged() 8 | { 9 | base.OnBindingContextChanged(); 10 | 11 | var node = BindingContext as TreeViewNode; 12 | bool isLeafNode = (node.ChildrenList == null || node.ChildrenList.Count == 0); 13 | 14 | //empty nodes have no icon to expand unless showExpandButtonIfEmpty is et to true which will show the expand 15 | //icon can click and populated node on demand propably using the expand event. 16 | if ((isLeafNode) && !node.ShowExpandButtonIfEmpty) 17 | { 18 | Content = new ResourceImage 19 | { 20 | Resource = isLeafNode ? "blank.png" : "folderopen.png", 21 | HeightRequest = 16, 22 | WidthRequest = 16 23 | }; 24 | } 25 | else 26 | { 27 | Content = new ResourceImage 28 | { 29 | Resource = node.IsExpanded ? "openglyph.png" : "collpsedglyph.png", 30 | HeightRequest = 16, 31 | WidthRequest = 16 32 | }; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MauiTreeView/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 11 | 12 | 17 | 18 |