wpf usercontrol,将按钮的命令参数绑定到父usercontrol
我有一个WPF UserControl,其中包含一个remove按钮,我想将整个UserControl作为CommandParameter传递 当前绑定被设置为CommandParameter=“{binding RelativeSource={RelativeSource Self}}”,这为我提供了按钮,但我如何获得整个控件 有人能帮忙吗 干杯 安迪wpf usercontrol,将按钮的命令参数绑定到父usercontrol,wpf,binding,user-controls,Wpf,Binding,User Controls,我有一个WPF UserControl,其中包含一个remove按钮,我想将整个UserControl作为CommandParameter传递 当前绑定被设置为CommandParameter=“{binding RelativeSource={RelativeSource Self}}”,这为我提供了按钮,但我如何获得整个控件 有人能帮忙吗 干杯 安迪 标签 破解了它 <Button Grid.Column="2" Style="{DynamicResource C
标签
破解了它
<Button
Grid.Column="2"
Style="{DynamicResource CloseButton}"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding RelativeSource=
{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
Visibility="{Binding RemoveVisible}"
/>
<Button
Grid.Column="2"
Style="{DynamicResource CloseButton}"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding RelativeSource=
{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
Visibility="{Binding RemoveVisible}"
/>