Hello all.
I'm having some trouble with the EventToCommand not behaving as I would expect with CaptureMouse.
I have a ResizeGrip that I've defined several EventToCommand's on:
<ResizeGrip Name="ResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<cmd:EventToCommand Command="{Binding ResizeStartCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeftButtonUp">
<cmd:EventToCommand Command="{Binding ResizeStopCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="MouseMove">
<cmd:EventToCommand Command="{Binding ResizeCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ResizeGrip>
The handling functions are set in the constructor of the class:
ResizeStartCommand = new RelayCommand<MouseButtonEventArgs>(
(e) => OnRequestResizeStart(e));
ResizeStopCommand = new RelayCommand<MouseButtonEventArgs>(
(e) => OnRequestResizeStop(e));
ResizeCommand = new RelayCommand<MouseEventArgs>(
(e) => OnRequestResize(e),
param => CanResize);
And finally I do all my logic to resize:
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; } }
The OnRequestResizeStart & 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.
Is this a limitation of the EventToCommand, or does something special need to occur?
Thanks for any help!