dimanche 10 mai 2015

Get MousePosition in a Panel (when Mouse is over an other UIElement) to ViewModel

Again I have a probably simple problem:

I am trying to get the MousePosition in my Scrollviewer:

CurrentMousePosition = e.GetPosition((IInputElement)e.OriginalSource);

But the problem occures when my mouse is over an other UIElement - the source is the UIElement and not my Scrollviewer - "wrong" Position:

I would now that I could do a "IsHitTestVisible=flase" but I also need the HitTest of the Elements.

XAML:

<ScrollViewer>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseMove">
            <cmd:EventToCommand
                Command="{Binding Mode=OneWay, Path=MouseMoveCommand}"                   
                PassEventArgsToCommand="True"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Canvas>
        <ItemsControl ItemsSource="{Binding ItemsToDraw}">
            <!-- A lot of stuff -->
        </ItemsControl>
    </Canvas>
</ScrollViewer>

Thank you!

Aucun commentaire:

Enregistrer un commentaire