wpf 任意控件绑定Command

<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>
 

posted @ 2023-11-20 20:46  优学者  阅读(307)  评论(0)    收藏  举报