Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wpf usercontrol,将按钮的命令参数绑定到父usercontrol_Wpf_Binding_User Controls - Fatal编程技术网

wpf usercontrol,将按钮的命令参数绑定到父usercontrol

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

我有一个WPF UserControl,其中包含一个remove按钮,我想将整个UserControl作为CommandParameter传递

当前绑定被设置为CommandParameter=“{binding RelativeSource={RelativeSource Self}}”,这为我提供了按钮,但我如何获得整个控件

有人能帮忙吗

干杯

安迪


标签
破解了它

<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}" 
    />