wpf 任意控件绑定Command

发布时间 2023-11-20 20:52:40作者: 优学者

<Border Background="White"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="2">
<Border.InputBindings>
<MouseBinding Command="{Binding DataContext.BorderCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
CommandParameter="{Binding}"
MouseAction="LeftClick" />
</Border.InputBindings>
</Border>