如何防止VS WPF设计器在工具箱中的每个对象上放置边距 [英] How can I prevent the VS WPF designer putting margins on every object from the toolbox

查看:75
本文介绍了如何防止VS WPF设计器在工具箱中的每个对象上放置边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将控件从工具箱拖到Visual Studio 2008 WPF设计图面上时,它会根据我放置控件的位置和默认大小来设置边距。

When I drag a control from the toolbox on to the Visual Studio 2008 WPF design surface, it sets a margin based on where I dropped it and a default size.

有什么方法可以防止VS设置这些吗?当我将一个控件放到堆栈面板上时,我希望它流入面板中的现有控件。

Is there any way to prevent VS setting those? When I drop a control on a stackpanel I want it to flow in to the existing controls in the panel.

谢谢!

推荐答案

我从未找到防止这种情况的方法。我只是键入XAML。

I've never found a way to prevent this. I just type the XAML instead.

EDIT

我写了以上内容近三年前。同时,似乎在设计时的体验也变得更好了。

I wrote the above nearly three years ago. In the meantime, it would appear that the design-time experience has gotten a lot better.

尽管如果您拖放,设计师仍然会添加硬编码的边距,有一些方法可以消除这些空白,而无需手工完成。

While the designer still adds hard-coded margins if you drag-and-drop, there are ways to remove those margins without having to do it by hand.

这里是一篇文章的链接,该文章说明了如何使用Visual Studio 2010中的设计工具进行排版无需输入任何XAML即可生成表格。 (尽管标题是WPF。)

Here's a link to an article that illustrates how to use design tools in Visual Studio 2010 to lay out a form without having to type any XAML. (Despite the title, it's about WPF.)

文章的第一部分显示了硬编码像素,但是我链接到第二部分,显示了如何

The first part of the article shows hard-coded pixels, but I've linked to the second part that shows how to lay out the controls without that hard coding.

Windows窗体开发人员的布局技术

这篇关于如何防止VS WPF设计器在工具箱中的每个对象上放置边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆