Reputation: 452
My command binding is not fire, but it worked as expected with another button.
My Xaml,
<telerik:HierarchicalDataTemplate x:Key="TagTemplate" ItemsSource="{Binding Tags_CustmFldDetails.TagsList}" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding TagName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<telerik:RadRibbonButton Command="{Binding DataContext.Tags_CustmFldDetails.DeleteTags_CustmFldCommand}" CommandParameter="{Binding}" SmallImage="../Images/delete_icon.png" />
</StackPanel>
</telerik:HierarchicalDataTemplate>
Command for RadRibbonButton not firing,
Error is,
System.Windows.Data Error: BindingExpression path error: 'Tags_CustmFldDetails' property not found on 'ChurchHub.Server.ReqResp.DTO.PlannerTagSerializable' 'ChurchHub.Server.ReqResp.DTO.PlannerTagSerializable' (HashCode=55932620). BindingExpression: Path='Tags_CustmFldDetails.TagsList' DataItem='ChurchHub.Server.ReqResp.DTO.PlannerTagSerializable' (HashCode=55932620); target element is 'Telerik.Windows.Controls.RadTreeViewItem' (Name=''); target property is 'ItemsSource' (type 'System.Collections.IEnumerable')..
This command work perfectly in out side of this "HierarchicalDataTemplate".
Try using adding
Command="{Binding DataContext.Tags_CustmFldDetails.DeleteTags_CustmFldCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}
But nothing happened, same error.
"Tags_CustmFldDetails" is command hosted view model.
How to solve this ?
Upvotes: 0
Views: 386
Reputation: 452
Sorry... I just change Ancestor type. now its working.
In my button,
<telerik:RadRibbonButton Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Path=DataContext.Tags_CustmFldDetails.DeleteTags_CustmFldCommand}"
CommandParameter="{Binding}"
SmallImage="../Images/delete_icon.png"
/>
I change relative source binding.
Upvotes: 1