【问题标题】:WPF grid XAML layoutWPF 网格 XAML 布局
【发布时间】:2010-12-06 23:52:07
【问题描述】:

我主要使用 XAML 编写我的 UI,没有所见即所得的编辑器。

在网格中你可以这样做:

  <TextBox  Grid.Column="0" Grid.Row="0" ...

在创建来自 HTML 背景的网格时,我一直在做:

<TextBox  Grid.Column="0" Grid.Row="0">
<Label Grid.Column="1" Grid.Row="0">

<TextBox  Grid.Column="0" Grid.Row="1">
<Label Grid.Column="1" Grid.Row="1">

但按列排序 XAML 似乎更整洁:

<TextBox  Grid.Column="0" Grid.Row="0">
<TextBox  Grid.Column="0" Grid.Row="1">

<Label Grid.Column="1" Grid.Row="0">
<Label Grid.Column="1" Grid.Row="1">

看起来更整洁。

我只是好奇,其他人是怎么做到的?

【问题讨论】:

    标签: wpf xaml layout grid


    【解决方案1】:

    这取决于您是否希望控件彼此重叠,这是重新排序时唯一的显着区别。

    在 XAML 中,控件在添加时按顺序排列(z-index),这意味着如果您先添加 &lt;TextBox&gt;,然后添加 &lt;Label&gt;,则 &lt;Label&gt; 可以位于 &lt;TextBox&gt; 的顶部,而不是反过来。

    但是,在您的情况下,按行然后按列然后按 z-index 排序添加它们会更好。

    我会这样做的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      • 2013-01-06
      • 2012-06-25
      • 2012-06-15
      • 1970-01-01
      • 1970-01-01
      • 2011-02-23
      相关资源
      最近更新 更多