This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace GeekJ.Examples.ContactForm.Models | |
{ | |
public class Contact | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public string Email { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace GeekJ.FolderTreeControl.Model | |
{ | |
public class Drive : FolderTreeItem | |
{ | |
private DriveInfo _driveInfo; | |
public DriveInfo DriveInfo | |
{ | |
get | |
{ | |
return _driveInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UserControl x:Class="GeekJ.FolderTreeControl.FolderTree" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
mc:Ignorable="d" | |
d:DesignHeight="300" d:DesignWidth="300" | |
Loaded="FolderTree_Loaded"> | |
<Grid> | |
<TreeView ItemsSource="{Binding Path=Drives}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TreeView ItemsSource="{Binding Path=Drives}" TreeViewItem.Expanded="FolderTree_Expanded"> | |
<TreeView.ItemContainerStyle> | |
<Style TargetType="TreeViewItem"> | |
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" /> | |
</Style> | |
</TreeView.ItemContainerStyle> | |
<TreeView.ItemTemplate> | |
<HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}"> | |
<TextBlock Text="{Binding Path=Label}" /> | |
</HierarchicalDataTemplate> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UserControl x:Class="GeekJ.FolderTreeControl.FolderTree" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:model="clr-namespace:GeekJ.FolderTreeControl.Model" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
mc:Ignorable="d" | |
d:DesignHeight="300" d:DesignWidth="300" | |
Loaded="FolderTree_Loaded" DataContextChanged="FolderTree_DataContextChanged"> | |
<UserControl.Resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="Demo.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:ftc="clr-namespace:GeekJ.FolderTreeControl;assembly=GeekJ.FolderTreeControl" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<ftc:FolderTree /> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace GeekJ.FolderTreeControl | |
{ | |
public partial class FolderTree : UserControl | |
{ | |
private FolderTreeSelection _selection = new FolderTreeSelection(); | |
public FolderTreeSelection Selection | |
{ | |
get { return _selection; } | |
set | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Add(FolderTreeItem folderTreeItem, bool include = true) | |
{ | |
if (folderTreeItem.SelectionItem == null && include) | |
{ | |
// node is checked for the first time, add a selection item | |
folderTreeItem.SelectionItem = new Item() { TreeItem = folderTreeItem, Include = include }; | |
items.Add(folderTreeItem.SelectionItem); | |
} | |
else if (folderTreeItem.SelectionItem != null && folderTreeItem.SelectionItem.Include != include) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class FolderTree : UserControl | |
{ | |
private FolderTreeSelection _selection; | |
public FolderTreeSelection Selection | |
{ | |
get { return _selection; } | |
set | |
{ | |
_selection = value; | |
_selection.Changed += new EventHandler(OnSelectionChanged); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FolderTreeSelection : ViewModelBase | |
{ | |
private Dictionary<Item, long> itemCounts = new Dictionary<Item, long>(); | |
public long FolderCount { | |
get | |
{ | |
return itemCounts.Sum(x => x.Value); | |
} | |
} |
OlderNewer