Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4155
How to get my ShowCommand command bind correctly in XamDataTree?
posted
<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>
Parents
  • 35319
    Verified Answer
    posted

    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.

    DataTree_Button_MVVM.zip
Reply Children