This question tells me what to do in words, but I can't figure out how to write the code. :)
I want to do this:
<SomeUIElement>
<i:Interaction.Behaviors>
<ei:MouseDragElementBehavior ConstrainToParentBounds="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="DragFinished">
<i:InvokeCommandAction Command="{Binding SomeCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ei:MouseDragElementBehavior>
</i:Interaction.Behaviors>
</SomeUIElement>
But as the other question outlines, the EventTrigger doesn't work... I think it's because it wants to find the DragFinished
event on the SomeUIElement
instead of on the MouseDragElementBehavior
. Is that correct?
So I think what I want to do is:
- Write a behavior that inherits from
MouseDragElementBehavior
- Override the
OnAttached
method - Subscribe to the
DragFinished
event... but I can't figure out the code to do this bit.
Help please! :)
Here is what I implemented to solve your problem :
And then the XAML to call it like this....