<igDT:XamDataTree Name="Reports" ItemsSource="{Binding ReportList}" NodeLineVisibility="Visible" Height="Auto" MaxHeight="300" BorderThickness="0" Width="Auto" MaxWidth="{Binding ElementName=ReportsExpander, Path=ActualWidth, Converter={StaticResource WidthMinusScrollConverter}}" > <igDT:XamDataTree.GlobalNodeLayouts> <igDT:NodeLayout Key="ReportFolder" TargetTypeName="ReportFolder" DisplayMemberPath="FolderName" /> <igDT:NodeLayout Key="Report" TargetTypeName="Report" DisplayMemberPath="DisplayName"> <igDT:NodeLayout.ItemTemplate> <DataTemplate> <Button Style="{StaticResource LinkButton}" Command="{Binding ShowReportCommand}" CommandParameter="{Binding}" > <StackPanel Orientation="Horizontal" > <Image Source="/Resources/Icons/report.png"/> <TextBlock Text="{Binding Data.DisplayName}" Style="{StaticResource MenuTB}" /> </StackPanel> </Button> </DataTemplate> </igDT:NodeLayout.ItemTemplate> </igDT:NodeLayout> </igDT:XamDataTree.GlobalNodeLayouts> </igDT:XamDataTree>
Hi Travis,
Thank you for your post. I have been looking into your issue and it occurs because the XamDataTree control and the NodeLayout control do not have the same DataContext. This is why your binding does not work. My suggestion is to use Source for your binding like e.g.:
<Button Command="{Binding Source={StaticResource vm}, Path=ShowReportCommand}">
I am attaching a sample application(DataTree_Button_MVVM.zip) that shows this approach.
Let me know, if you need any further assistance on this matter.
I ended up using
Command="{Binding Node.Manager.NodeLayout.Tree.DataContext.ShowReportCommand}"
since i haven't used binding like your example throughout my application at all. It seems to work this way.
Thank you for your feedback. I am glad that you have managed to resolve your issue.