StackPanel同时有点击事件与Command:MouseBinding用了LeftClick之后只能用PreviewMouseLeftButtonDown,不加preview都会有一个不运行

<StackPanel Orientation="Horizontal" PreviewMouseLeftButtonDown="Button_Click" Cursor="Hand">
    <StackPanel.InputBindings>
        <MouseBinding Gesture="LeftClick" Command="{Binding CreateProjectCommand}" CommandParameter="{Binding CurrentUser}" />
    </StackPanel.InputBindings>
    <Image Source="/Images/IndexCreateProject.png" Width="16" Height="16" VerticalAlignment="Center"/>
    <Label Content="{DynamicResource Res_P_CreateProject}" FontSize="12" Foreground="White" VerticalAlignment="Center"/>
</StackPanel>

按钮同时有点击事件与command:Command与Click就行了

<Button Content="{DynamicResource Res_P_CreateProject}" Background="White"
 	HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" 
 	Command="{Binding CreateProjectCommand}" 
 	CommandParameter="{Binding CurrentUser}"   
 	Click="Button_Click" />
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐