如何使用 Blend 创建基本网格

发布于 2024-11-18 16:01:58 字数 407 浏览 2 评论 0原文

我是一名正在尝试掌握 Blend 的开发人员。我一直使用 Blend 来搞乱控件模板等,但我正在尝试掌握使用它进行基本 UI 设计的窍门,因为我认为它可能比在 Visual Studio 中手动键入 XAML 更快一些。

现在我只是想创建一个基本的网格,但我看到了两种默认行为,我希望有人可以告诉我如何更改。

1)当我将鼠标悬停在设计图面之外时,我会看到临时的黄线出现,当我单击时,新的网格列/行将位于该位置。问题是新创建的行设置为 0.2297* 等高度,如何让 Blend 附加常规高度(如 250)?

2)忽略1),一旦我有一些行和列,当我将按钮或组合框等拖到其中一个单元格上时,它会恰好将其放置在我释放鼠标的位置,而添加一些大边距以将其放置在那里。是否可以告诉 Blend 将控件放入单元格中,而保留边距?

I'm a developer who's trying to get the hang of Blend. I've always used Blend to mess with control templates and such, but I'm trying to get the hang of using it for basic UI design, since I figure it's probably a bit faster than typing the XAML up manually in Visual Studio.

Right now I'm just trying to create a basic Grid, but I'm seeing two default behaviors that I'm hoping someone can show me how to change.

1) When I hover my mouse outside of the design surface, I see the temporary yellow line to show up, where the new Grid Column / Row will be when I click. The problem is that the newly created rows are set to heights like 0.2297* How do I get Blend to attach regular heights, like 250?

2) Ignoring 1), once I have some rows and columns, when I drag a button, or combo box, etc, onto one of the cells, it drops it exactly where I release the mouse, while adding some large margins to position it there. Is it possible to tell blend to just drop the control into the cell, and leave the margins alone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

永不分离 2024-11-25 16:01:58

网格很棒,但需要一些尝试才能在 Blend 中熟练使用它们。这里有一些帮助您入门的提示(我在我的书的第 4 章中详细介绍了这一点)。

1) 当您使用对齐线创建行和列时,Blend 会自动使它们相对(星形)大小,这就是您所看到的行为。要将行/列样式更改为固定(像素)大小,请单击所需行和列左侧和顶部的挂锁图标。然后,在 XAML 中编辑值,或者可以单击挂锁附近(但不是挂锁上)来选择行或列。这将在“属性”面板中打开尺寸属性。

2)简短的回答是“否”。当您在单元格中绘制元素时,Blend 始终会添加边距,除非您小心地将它们绘制到边框。这太困难且耗时,所以我只是确保将其绘制在目标单元格内的某个位置。现在,我可以右键单击该元素并选择“自动调整大小 > 填充”,该元素将填充单元格:无边距,宽度和高度设置为自动,水平和垂直对齐方式设置为拉伸。 [FWIW,解决这个问题是我对 Blend 的第一个功能请求。]

我希望这会有所帮助。

Grids are awesome but it takes a bit of play to get proficient at working with them in Blend. Here are some tips to get you started (I cover this in detail in chapter 4 of my book).

1) When you use the snap lines to create rows and columns Blend automatically makes them relative (Star) sized, which is the behavior you are seeing. To change the row/column style to fixed (Pixel) sizes, click on the Padlock icons to the left and top of the desired rows and columns. Then, either edit the values in XAML or you can click near (but not on) the padlock to select the row or column. This will open the sizing properties in the Properties panel.

2) The short answer is "No". Blend will always add Margins when you draw the element in a cell unless you take care to draw them to the borders. This is too difficult and time consuming, so I just make sure I draw it somewhere inside my target cell. Now I can right-click the element and select "Auto Size > Fill" and the element will fill up the cell: no Margins, Width and Height set to Auto, and Horizontal and Vertical Alignments set to Stretch. [FWIW, addressing this is my number one feature request for Blend.]

I hope this helps.

三寸金莲 2024-11-25 16:01:58

回答第 1 点)Blend 正在创建比例网格,以便当您增大或缩小网格而不是绝对网格时,列保持相同的相对宽度。因此,如果您想要绝对网格宽度,则必须手动编辑值。

我发现在 Blend 中创建基本表单然后在文本编辑器中调整值更容易 - 无论是在 Visual Studio 中还是在 Blend 本身中。

至于第2点)我刚刚尝试过这一点,只要在放置按钮时单击网格上的列/行内部,它就会按预期将其添加到网格的正确列/行中。选择按钮,然后双击网格内部 - 这应该在您单击的位置但在网格中添加一个默认大小的按钮。 (如果我能看到你在做什么,那就容易多了)。

To answer point 1) Blend is creating proportional grids so that the columns remain the same relative widths when you grow or shrink the grid rather than absolute grids. So if you want absolute grid widths you'll have to go in and edit the values by hand.

I find that it's easier to create the basic form in Blend and then tweak the values in the text editor - either in Visual Studio or Blend itself.

As for point 2) I've just tried this and as long as I click inside the column/row on the grid when placing a button it adds it to the correct column/row of the grid as expected. Select the button and then just double click inside the grid - this should add a button of default size where you clicked, but in the grid. (It would be much easier if I could see what you were doing).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文