【问题标题】:Grid Items to fill the screen ... xaml填充屏幕的网格项目... xaml
【发布时间】:2013-05-03 16:58:53
【问题描述】:

如何在 GridView 控件中设置网格项的大小,以便项自动 重新调整大小以填满屏幕。例如,如果有 2 个项目,每个项目将占据屏幕的一半,如果有 3 个项目,每个项目将占据第三个等等......谢谢

【问题讨论】:

  • 你是不是先问问谷歌先生和MSDN先生?

标签: c# xaml data-binding windows-store-apps winrt-xaml


【解决方案1】:

在列定义上使用ItemStyle.Width 属性。

如果你没有使用autogenerated列,来设置你感兴趣的列的宽度。

如果您使用动态生成的列,则需要在后面的代码中设置宽度。

请参阅以下内容:

protected void TextBox1_TextChanged (object sender, EventArgs e)
{
    Label1.Text = "";
    try
    {
      int colWidth = Int16.Parse(Server.HtmlEncode(TextBox1.Text));
      if (colWidth > 0)
      {
        for (int i = 0; i < GridView1.Columns.Count; i++)
        {
          GridView1.Columns[i].ItemStyle.Width = colWidth;
        }
      }
    }
    catch
    {
      Label1.Text = "An error occurred."
    }
}

查看此 MSDN:

http://msdn.microsoft.com/en-us/library/ms178296.aspx

参考链接:

http://forums.asp.net/t/1176980.aspx

【讨论】:

  • 感谢您的帮助。但是有没有办法在 Xaml 中为 Windows 商店应用程序做到这一点.. 我没有看到找到自动生成的以将其设置为 false ..
猜你喜欢
  • 1970-01-01
  • 2020-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-15
  • 2017-12-30
相关资源
最近更新 更多