wpfpixelsensescatterview

WPF: Reset the positions of scatterviewitems?


I have a scatterview with some items in it which I place with Orientation und Center. Now I want to have the possibility to reset the positions of the scatterviewitems after scaling, rotating and moving them, while the program is running.

At the moment I do it this way:

private void Reset_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)

{

       item1.Center = new Point(150,150);
        item1.Orientation = 15;
        item1.Width = 100;
        item1.Height = 150;

}

Is there a better way to do it?


Solution

  • No, not really. :) The scatterview does not have a concept of a start or default position - it's all randomized when items are first added (except size which is set to 20% of the SV IIRC). The only way to do it is as you do, by manipulating the values manually.

    I guess that you could put this logic in the a viewmodel and databind the width, height, center and orientation to properties on the VM. The VM could then have a reset method or relaycommand that restores the values to some sort of default. It's essentially the same as you're doing in code-behind though.