Note that there are some explanatory texts on larger screens.

plurals
  1. POMVVM Light EventToCommand Not Working with CaptureMouse
    text
    copied!<p>I'm having some trouble with the EventToCommand not behaving as I would expect with CaptureMouse.</p> <p>I have a ResizeGrip that I've defined several EventToCommand's on:</p> <pre><code>&lt;ResizeGrip Name="ResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE"&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="MouseLeftButtonDown"&gt; &lt;cmd:EventToCommand Command="{Binding ResizeStartCommand}" PassEventArgsToCommand="True" /&gt; &lt;/i:EventTrigger&gt; &lt;i:EventTrigger EventName="MouseLeftButtonUp"&gt; &lt;cmd:EventToCommand Command="{Binding ResizeStopCommand}" PassEventArgsToCommand="True" /&gt; &lt;/i:EventTrigger&gt; &lt;i:EventTrigger EventName="MouseMove"&gt; &lt;cmd:EventToCommand Command="{Binding ResizeCommand}" PassEventArgsToCommand="True" /&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;/ResizeGrip&gt; </code></pre> <p>The handling functions are set in the constructor of the class:</p> <pre><code>ResizeStartCommand = new RelayCommand&lt;MouseButtonEventArgs&gt;( (e) =&gt; OnRequestResizeStart(e)); ResizeStopCommand = new RelayCommand&lt;MouseButtonEventArgs&gt;( (e) =&gt; OnRequestResizeStop(e)); ResizeCommand = new RelayCommand&lt;MouseEventArgs&gt;( (e) =&gt; OnRequestResize(e), param =&gt; CanResize); </code></pre> <p>And finally I do all my logic to resize:</p> <pre><code>void OnRequestResizeStart(MouseButtonEventArgs e) { bool r = Mouse.Capture((UIElement)e.Source); Console.WriteLine("mouse down: " + r.ToString()); } void OnRequestResizeStop(MouseButtonEventArgs e) { ((UIElement)e.Source).ReleaseMouseCapture(); _canResize = false; } void OnRequestResize(MouseEventArgs e) { Console.WriteLine("mouse move"); } bool CanResize { get { return _canResize; } } </code></pre> <p>The OnRequestResizeStart &amp; OnRequestResizeStop commands are working fine, and the OnRequestResize works... but only when I am actually over the ResizeGrip. It does not appear that the CaptureMouse is not actually sending all the mouse events to the ResizeGrip.</p> <p>Is this a limitation of the EventToCommand, or does something special need to occur?</p> <p>Thanks for any help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload