Bind the TreeView control in xaml sample #228
-
I added the TreeView Control in Xaml sample. <Window.DataContext>
<vm:MainWindowViewModel />
</Window.DataContext>
<Grid ColumnDefinitions="*,200">
<DockControl FactoryType="{x:Type Factory}" InitializeLayout="True" InitializeFactory="True">
<RootDock x:Name="Root" Id="Root" IsCollapsable="False" DefaultDockable="{Binding #MainLayout}">
<ProportionalDock x:Name="MainLayout" Id="MainLayout" Orientation="Horizontal">
<ToolDock x:Name="LeftPane" Id="LeftPane" Proportion="0.25">
<Tool x:Name="SolutionExplorer" Id="SolutionExplorer" Title="Solution Explorer">
<TreeView Items="{Binding Children}" >
<TreeView.DataTemplates>
<TreeDataTemplate DataType="models:IImportRootItem" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Import --- " />
<TextBlock Text="{Binding Title}"/>
</StackPanel>
</TreeDataTemplate>
<TreeDataTemplate DataType="models:IGroupRootItem" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Title}"/>
</TreeDataTemplate> I'm seeing this error when running.
Can I do the Data Binding in Xaml code? I want to put the TreeView into the ToolDock |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Can you post full Window xaml? |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply.
|
Beta Was this translation helpful? Give feedback.
-
I also have the same problem, can't bind |
Beta Was this translation helpful? Give feedback.
Thank you for your reply.
This is full MainWindow.xaml
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="using:TreeViewDataBinding" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="TreeViewDataBinding.Views.MainWindow" xmlns:models="using:TreeViewDataBinding" Icon="/Assets/avalonia-logo.ico" Title="TreeViewDataBinding"> <Design.DataContext> <vm:MainWindowViewModel /> </Design.DataContext> <Grid ColumnDefinitions="*,200"> <DockControl FactoryType="{x:Type Factory}" InitializeLayout=…