Search code examples
c#wpftouchsurface

ScatterViewItem manipulation event handlers not being called


I am developing a WPF Surface touchscreen based application which makes use of ScatterViewItem controls.

When using touch input, all manipulations work well: rotation, scaling, translation.

Unfortunately, when I try to execute some code when the manipulations happen, for example the following code in the C# codebehind, nothing happens.

ManipulationDelta += myItemManipulationDelta;

private void myItemManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
        Application.Current.Shutdown(); //just to see if it's even happening
}

I have tried adding similar handlers to ManipulationStarting and ManipulationStarted with no success.

Update: As the answer suggested, I have attempted the following, without success:

public partial class MyControl: ScatterViewItem
{
//constructor for custom control

    private void MainWindow_ManipulationDelta2(object sender, ManipulationDeltaEventArgs e)
    {
         Application.Current.Shutdown();
    }

    private void MainWindow_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    {
        // normal handling of the event.
    }

    public MyControl()
    {
        ManipulationDelta += MainWindow_ManipulationDelta2;
        ManipulationDelta += MainWindow_ManipulationDelta;
        // more stuff ...
    }
}

Solution

  • So turns out I had to actually register a ContainerManipulationDelta event inside my custom ScatterViewItem based control in order for the event to fire correctly. Now everything works as expected.