我有一个在 XAML 中定义了 RowDefinitions 的网格,在代码中转到快照 View 时我需要更改它,到目前为止我只能弄清楚如何通过以下方式删除它们:
RowDefinitionCollection defs = mainGrid.RowDefinitions;
defs.RemoveAt(0);
defs.RemoveAt(0);
本质上,我需要删除快照 View 中的所有定义(上面的代码有效),然后需要使第一行的高度为 140,第二行在返回快照 View 后为“*”。我将如何添加具有这些特征的定义?
请您参考如下方法:
简单
RowDefinitionCollection rdc = mainGrid.RowDefinitions;
rdc.Clear();
rdc.Add(new RowDefinition() { Height = new GridLength(140) });
rdc.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
