Question

I am kinda new to WPF4 / C# / SDK Surface 2.0. I am trying to have a ScatterView containing several objects (symbolised by rectangles, triangles and other shapes) that I could link together.

I just began my projet and I studied the different Surface Samples provided on MSDN website. One of them explain how to explicitly or implicitly add a ScatterViewItem to a ScatterView.

The sample is working well, I handled my event like the sample suggest and I am currently trying an other Handler:

AddObject.Click += new RoutedEventHandler(AddObject_Click);
AddObject.TouchDown += new EventHandler<TouchEventArgs>(AddObject_TouchDown);

I am doing the exact same thing in AddObject_Click and in AddObject_TouchDown :

private void AddObject_Click(object sender, RoutedEventArgs e)
{
    numObject++;
    ScatterViewItem item = new ScatterViewItem();
    item.Width = 100;
    item.Height = 60;
    item.Background = SurfaceColors.Accent1Brush;
    item.Content = "Object " + numObject.ToString();
    item.Orientation = 0;

    myScatterView.Items.Add(item);
}

private void AddObject_TouchDown(object sender, TouchEventArgs e)
{
    numObject++;
    ScatterViewItem item = new ScatterViewItem();
    item.Width = 100;
    item.Height = 60;
    item.Background = SurfaceColors.Accent2Brush;
    item.Content = "Object " + numObject.ToString();
    item.Orientation = 0;

    myScatterView.Items.Add(item);
}

I used the Input Simulator to simulate TouchEvents on my screen. If both of the methods are uncommented, it is always the first one which is called by the program. And when I comment the first one (and its related handler), nothing is going on and I cannot understand why.

Does someone have an idea about my problem ?

Was it helpful?

Solution

What is the type of AddObject? Is it a button? If so then Click event is fired with both mouse and touch. However the TouchDown event will never fire as the button already handles this event internally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top