UnifomGrid
已加载数据,我想隐藏第一行?
我该如何实现?
答案 0 :(得分:1)
我从来没有使用UniformGrid
所以可能有更好的解决方案,但据我所知UniformGrid
除了有多少行和列之外没有多少信息因此,这是我能想到的唯一解决方案。
private List<UIElement> GetElementsAtRow(int rowNumber)
{
List<UIElement> elementsAtRow = new List<UIElement>();
for (int i = 0; i < uniformGrid.Columns; i++)
{
if (i < uniformGrid.Children.Count)
{
elementsAtRow.Add(uniformGrid.Children[i] as UIElement);
}
}
return elementsAtRow;
}
private void HideFirstRow()
{
List<UIElement> elementsAtRow = GetElementsAtRow(0);
foreach (UIElement element in elementsAtRow)
{
// Or Hidden if you want row to remain but with no Visible children.
element.Visibility = Visibility.Collapsed;
}
}
private void ShowFirstRow()
{
List<UIElement> elementsAtRow = GetElementsAtRow(0);
foreach (UIElement element in elementsAtRow)
{
element.Visibility = Visibility.Visible;
}
}