开发者

WPF: Reset the positions of scatterviewitems?

开发者 https://www.devze.com 2022-12-30 19:08 出处:网络
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, r

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消