Search code examples
wpfxamlbindingtelerikrowdetailstemplate

TreeListView.RowDetailsTemplate new for each row


Im close to my solution but i cant figure out my last step. I have a RowDetailsTemplate for each row in a RadTreeListView. My Probplem is I can figure out how to bind it. Im binding it to CurrentSelected but now evrytime I click on a other row the RowDetailsTemplate changes ofcourse. MY XAML is to big to post it so I ll show some examples.

            <RadTreeListView Name="positionenDataGrid"
                                     HierarchyColumnIndex="3"
                                     ItemsSource="{Binding Path=Model.ModelChildList}"
                                  SelectedItem="{Binding Path=CurrenPosition}">
                    <RadTreeListView.ChildTableDefinitions>
                        <TreeListViewTableDefinition ItemsSource="{Binding PositionChildList}" />
                    </RadTreeListView.ChildTableDefinitions>

                    <RadTreeListView.Columns>
                        <columns:CustomToggleButtonColumn x:Name="ExpanderColumn" Header="DetailView" DataMemberBinding="{Binding IsPositionExpanded}" ToggleButtonVisibility="{Binding Path=CanHavePositionen}"/>


                    </RadTreeListView.Columns>
                    <RadTreeListView.RowDetailsTemplate>
                        <DataTemplate>

                            <Views:DetailPositionView HorizontalAlignment="Left" />

                        </DataTemplate>
                    </RadTreeListView.RowDetailsTemplate>
                </RadTreeListView>

Example of Binding in DetailPositionView;:

Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Views:ParentView}}, Path=DataContext.CurrenPosition.Number}"

If I open two RowDetailsTemplates at the same time they have both the same Content because I bind on the SelectedItem. The question now is: How can I give them each Data of each Row without SelectedItem?


Solution

  • DataContext of your DetailPositionView is the row data. So just doing

    Value="{Binding Number}" 
    

    will do the trick