如何在表达式混合中将所有选定的元素向下移动n行?

发布于 2024-10-26 05:57:42 字数 396 浏览 2 评论 0原文

在 silverlight 中设计表单是一件痛苦的事情。 网格确实可以轻松地将内容向右或向左对齐,但是当您开始构建更复杂的形式时,它很快就会变得很糟糕。

(想想多列表单,在子用户控件中分隔表单的各个部分,并使用本地化标签,以便您需要将标签列设置为自动...)

我面临的一个特殊问题是当我需要插入一个新的表单中的行。

有什么办法可以选择所有 控制多行并移动 它们都向下 1 行吗?

现在,我必须检查每一行并将它们一行一行地向下移动。

如何有效地构建复杂的表单?我从工具包中了解了 DataForm 控件,但它处于“预览”质量,并且从我所读到的内容来看,当您需要自定义和构建多列表单时,它太不灵活了。

Designing forms in silverlight is a PAIN.
The grid does make it easy to align stuff right or left, but when you start building more complex forms, It quickly becomes a hell.

(Think multicolumns forms, separating parts of the form in sub-usercontrol, with Localized labels so that you need the label column to be set to Auto...)

One particular problem I face is when I need to insert a new row in a form.

Is there any way to select all the
controls on multiple lines and move
them all 1 row down?

Right now, I have to go through every line and move them down, one by one.

How do you effectively build complex forms? I know about the DataForm control from the toolkit, but it is in "preview" quality and from what I have read, it is too inflexible when you need to customize and build multiple-columns forms.

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

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

发布评论

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

评论(1

橙味迷妹 2024-11-02 05:57:56

是的,复杂的网格的改变可能会很烦人。这里有一些想法和想法供您参考。

如果您使用 Expression Blend 并使用画板中的蓝色条插入行或列,Blend 将尝试为您执行此操作。它取得了不同程度的成功,很大程度上取决于新行或列对齐线重叠的控件数量。为了获得最佳效果,请放大画板并在非常靠近上方行或左侧列的位置添加新的对齐线。

此时,您仍然需要进行大量清理工作,但 Grid.Row 和 Grid.Column 属性将被正确调整。更正行和列大小是我选择手动编辑 XAML 的少数几次之一,因此您可能会更快地手动修复这些值。

如果创建了奇怪的边距(通常如此),您可以一次选择所有受影响的属性并集体重置边距。

最好的建议可能是考虑使用不同的控件。如果您发现自己不断地重新排列网格的内容,也许使用 DockPanel 会更好。您可以通过添加停靠在顶部的元素(网格)并将行或列高度绑定到资源来实现类似网格的结果:

    <UserControl.Resources>
    <GridLength x:Key="StandardColumnHeight">32</GridLength>
</UserControl.Resources>

现在您可以将 ColumnDefinition 宽度绑定到静态资源,确保它们都具有相同的宽度(当然这也适用于列宽)。

<ColumnDefinition Width="{StaticResource StandardColumnHeight}"/>

如果您使用同一组 ColumnDefinition 定义每个后续 Grid(另一个快速 XAML 复制粘贴作业)。

最初设置可能需要一些额外的工作,但在 DockPanel 中插入新行是 XAML 顺序的简单问题,不需要那么多工作。

Yes, complex Grid's can be annoying to change. Here are a few thoughts and ideas for you.

If you use Expression Blend and insert the Row or Column using the Blue Bars in the Artboard, Blend will attempt to do this for you. It works with varying degrees of success, largely based on the amount of the control the new row or column snap lines overlaps. For the best results, zoom into the Artboard and add the new snap line very close to the row above or column to the left.

At this point you'll still have a lot of cleanup to do, but the Grid.Row and Grid.Column properties will be correctly adjusted. Correcting the row and column sizes is one of the few times I choose to manually edit the XAML, so you'll probably be faster fixing those values manually.

If odd Margins are created (as they often are) you can select all the affected properties at once and reset the Margins en masse.

Probably the best advice would be to consider using a different control. If you find yourself constantly rearranging the contents of a Grid, perhaps you would be better off with a DockPanel. You can achieve a Grid-like result by adding elements (Grids) docked to the Top and binding the row or column height's to a Resource:

    <UserControl.Resources>
    <GridLength x:Key="StandardColumnHeight">32</GridLength>
</UserControl.Resources>

Now you can bind the ColumnDefinition Width to the static resource ensuring they all have the same width (of course this could also work with column widths).

<ColumnDefinition Width="{StaticResource StandardColumnHeight}"/>

If you define each of the subsequent Grid's using the same set of ColumnDefinitions (another quick XAML copy-n-paste job).

This may be a little extra work to set up initially, but inserting a new row in your DockPanel is a simple matter of XAML order and would not require as much work.

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