Created
April 27, 2012 01:44
-
-
Save jsonw23/2504956 to your computer and use it in GitHub Desktop.
Folder Tree WPF Control: Part 2 - Selection Events
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); | |
} | |
} | |
public event EventHandler SelectionChanged; | |
public FolderTree() | |
{ | |
InitializeComponent(); | |
Selection = new FolderTreeSelection(); | |
} | |
... | |
private void OnSelectionChanged(object sender, EventArgs args) | |
{ | |
if (SelectionChanged != null) | |
{ | |
SelectionChanged(sender, args); | |
} | |
} | |
} |
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 | |
{ | |
... | |
public event EventHandler Changed; | |
... | |
private void OnChanged() | |
{ | |
if (Changed != null) | |
{ | |
Changed(this, new EventArgs()); | |
} | |
} | |
} |
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 SelectionChanged="FolderTreeSelection_Changed" /> | |
</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
<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" | |
xmlns:ftcModel="clr-namespace:GeekJ.FolderTreeControl.Model;assembly=GeekJ.FolderTreeControl" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<ftc:FolderTree> | |
<ftc:FolderTree.Selection> | |
<ftcModel:FolderTreeSelection Changed="FolderTreeSelection_Changed" /> | |
</ftc:FolderTree.Selection> | |
</ftc:FolderTree> | |
</Grid> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment