|
Use Flexible TreeView in WPF project
Sunday, 18 December 2011
Though Flexible TreeView is a WinForms component, it can be easily used in the WPF project right now by using WinForms controls host facility with the help of WindowsFormsHost class. At the same time all rich Flexible TreeView functionality is available to you as in the WinForms version. For example, below there is the sample of XAML which creates a treeview with the column and a text node control in it, and also adds the root and child node: <Window x:Class="FTVWpfTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ftv="clr-namespace:ARMSoft.FlexibleTreeView;assembly=ARMSoft.FlexibleTreeView" xmlns:col="clr-namespace:ARMSoft.FlexibleTreeView.Column;assembly=ARMSoft.FlexibleTreeView" xmlns:nodectrl="clr-namespace:ARMSoft.FlexibleTreeView.NodeControls;assembly=ARMSoft.FlexibleTreeView" xmlns:nodes="clr-namespace:ARMSoft.FlexibleTreeView.Nodes;assembly=ARMSoft.FlexibleTreeView" Title="MainWindow" Height="350" Width="525"> <Grid> <WindowsFormsHost> <ftv:FlexibleTreeView x:Name="tree" NodeExpanding="tree_NodeExpanding"> <ftv:FlexibleTreeView.Columns> <col:TreeColumn Text="test" Id="0" Width="150" /> </ftv:FlexibleTreeView.Columns> <ftv:FlexibleTreeView.NodeControls> <nodectrl:NodeTextBox ColumnId="0" DataFieldName="Text" /> </ftv:FlexibleTreeView.NodeControls> <ftv:FlexibleTreeView.Nodes> <nodes:Node Text="XAML node"> <nodes:Node.Nodes> <nodes:Node Text="XAML sub-node"/> </nodes:Node.Nodes> </nodes:Node> </ftv:FlexibleTreeView.Nodes> </ftv:FlexibleTreeView> </WindowsFormsHost> </Grid> </Window> Please, note that the event handlers (NodeExpanding in the sample above) are added in XAML as easily as for the native WPF control. At the moment we are working on porting Flexible TreeView to WPF and when the native WPF version is available you will be able to replace the current wrapper with native control by simply deleting some lines in XAML.
|
|