WPF:重置 scatterviewitems 的位置?
我有一个散点视图,其中包含一些项目,我将其放置在方向和中心位置。 现在我希望能够在程序运行时在缩放、旋转和移动 scatterviewitems 后重置它们的位置。
目前我这样做:
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;
}
有更好的方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,不是真的。 :)
scatterview 没有开始或默认位置的概念 - 当首次添加项目时,它都是随机的(除了设置为 SV IIRC 的 20% 的大小)。唯一的方法就是像您一样,手动操作这些值。
我想您可以将此逻辑放入视图模型中,并将宽度、高度、中心和方向数据绑定到虚拟机上的属性。然后,虚拟机可以有一个重置方法或中继命令,将这些值恢复为某种默认值。不过,它本质上与您在代码隐藏中所做的相同。
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.