Question

This is an age old problem of interactive elements inside interactive elements, but I want a ScatterViewItem to contain other surface interactive elements such as a SurfaceButton or SurfaceCheckBox. I've got all my elements in there and they react to taps etc. The problem is that I only get the normal ScatterView behavior once I click on an area that does not contain a control.

Is there an elegant solution to allow dragging even when the contact is on a SurfaceButton or SurfaceCheckbox?

e.g.

<s:ScatterView >    
    <Grid Width="200" Height="200">
        <s:SurfaceButton />
    </Grid>
</s:ScatterView>
Was it helpful?

Solution

After asking the same question on the surface community forums, the response was that this is consistent with all WPF control behavior. For instance if you add interactive elements to a list box, the ListBox will not react to interactions when the mouse is over the button.

If anyone else comes across this problem, it is probably best to solve this problem through the design of the control rather than trying to hack this behavior together. Control behavior should remain consistent from one app to another and one control to another.

OTHER TIPS

you can 'hack' this behavior in by listening to ContactLeave events on one of the child controls and in that, call contact.Capture( scatterviewitem). this will tell the svi to take over listening to and responding to the contact. however, it is going to result in behavior inconsistent with other parts of Surface and may be confusing. it's also inconsistent even with itself... this makes it possible to switch from inner control to SVI without lifting your finger but the user still has to lift their finger to switch back to the inner control.

To solve this problem, it is important to distinguish between preview und non-preview events:

http://eightyeightpercentnerd.blogspot.com/2008/06/wpf-preview-vs-non-preview-events.html

So you can decide which event you want to listen to.

However as a general advice, it is always a good idea to set the Handled Flag of an event to true, if it shouldn't be routed any further.

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