放肆看

导航

 
<hc:Interaction.Triggers>
    <hc:EventTrigger EventName="PreviewMouseLeftButtonUp">
        <hc:EventToCommand
            Command="{Binding AddPointCommand}"
            EventArgsConverterParameter="{Binding ElementName=Img}"
            PassEventArgsToCommand="True">
            <hc:EventToCommand.EventArgsConverter>
                <converter:MouseEventArgs2PositionConverter />
            </hc:EventToCommand.EventArgsConverter>
        </hc:EventToCommand>
    </hc:EventTrigger>
</hc:Interaction.Triggers>
public class MouseEventArgs2PositionConverter : IEventArgsConverter
{
    public object Convert(object value, object parameter)
    {
        var e = (MouseButtonEventArgs)value;
        var ele = (IInputElement)parameter;
        var p = e.GetPosition(ele);
        return p;
    }
}

 

 

posted on 2024-04-29 11:33  放肆看  阅读(214)  评论(0编辑  收藏  举报