Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>
8 changes: 8 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="SfTreeGridDemo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SfTreeGridDemo"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace SfTreeGridDemo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Binary file added GetTreeNodeViewMouseDoubleClick.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Window x:Class="SfTreeGridDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SfTreeGridDemo"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="1000">
<Window.DataContext>
<local:ViewModel />
</Window.DataContext>
<Grid>
<syncfusion:SfTreeGrid Name="treeGrid"
AutoGenerateColumns="False"
AllowEditing="True"
ChildPropertyName="ReportsTo"
ParentPropertyName="ID"
ItemsSource="{Binding Employees}"
SelfRelationRootValue="-1"
AllowDraggingRows="True"
AllowDrop="True">
<syncfusion:SfTreeGrid.Columns>
<syncfusion:TreeGridTextColumn MappingName="FirstName" HeaderText="First Name" />
<syncfusion:TreeGridTextColumn MappingName="LastName" HeaderText="Last Name" />
<syncfusion:TreeGridCheckBoxColumn MappingName="IsSelected" HeaderText="Is Selected" />
<syncfusion:TreeGridTextColumn MappingName="ID" HeaderText="ID" />
<syncfusion:TreeGridTextColumn MappingName="Title" HeaderText="Title" />
<syncfusion:TreeGridCurrencyColumn MappingName="Salary" HeaderText="Salary" />
<syncfusion:TreeGridTextColumn MappingName="ReportsTo" HeaderText="Reports To" />
</syncfusion:SfTreeGrid.Columns>
</syncfusion:SfTreeGrid>
</Grid>
</Window>
44 changes: 44 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Syncfusion.UI.Xaml.TreeGrid;
using Syncfusion.UI.Xaml.TreeGrid.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SfTreeGridDemo
{

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.treeGrid.MouseDoubleClick += TreeGrid_MouseDoubleClick;
}

private void TreeGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var treeGridPanel = this.treeGrid.GetTreePanel();
// get the row and column index based on the pointer position
var rowColumnIndex = treeGridPanel.PointToCellRowColumnIndex(e.GetPosition(treeGridPanel));
if (rowColumnIndex.IsEmpty)
return;
var treeNodeAtRowIndex = treeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);

MessageBox.Show("TreeNode : " + treeNodeAtRowIndex.ToString());
}
}
}
105 changes: 105 additions & 0 deletions Model.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SfTreeGridDemo
{
public class EmployeeInfo : IDataErrorInfo, INotifyDataErrorInfo
{
int _id;
string _firstName;
string _lastName;
private string _title;
decimal _salary;
int _reportsTo;
bool isSelected;
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;

public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}

public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}

public bool IsSelected
{
get { return isSelected; }
set { isSelected = value; }
}

[Range(1, 2, ErrorMessage = "ID between 1 and 2 alone processed")]
public int ID
{
get { return _id; }
set { _id = value; }
}

public string Title
{
get { return _title; }
set { _title = value; }
}

public decimal Salary
{
get { return _salary; }
set { _salary = value; }
}

public int ReportsTo
{
get { return _reportsTo; }
set { _reportsTo = value; }
}

[Display(AutoGenerateField = false)]

public string Error => string.Empty;

public string this[string columnName]
{
get
{
if (!columnName.Equals("Salary"))
return string.Empty;
if (this.Salary < 10000 || this.Salary > 30000)
return "The 'Salary' field can range from 10000 to 30000 ";

return string.Empty;
}
}

[Display(AutoGenerateField = false)]

public bool HasErrors
{
get
{
return false;
}
}

private List<string> errors = new List<string>();
public IEnumerable GetErrors(string propertyName)
{
if (!propertyName.Equals("Title"))
return null;

if (this.Title.Contains("Management"))
errors.Add("Management is not valid ");

return errors;
}
}
}
55 changes: 55 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SfTreeGrid_MVVM")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SfTreeGrid_MVVM")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
63 changes: 63 additions & 0 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading