开发者

How can I Hide the first row for UniformGrid Control?

开发者 https://www.devze.com 2023-01-23 21:31 出处:网络
UnifomGrid has loaded Data, I want to Hide the first row? How can I implement tha开发者_如何学JAVAt?I\'ve never worked with the UniformGrid so there might be a better solution for this but as far as

UnifomGrid has loaded Data, I want to Hide the first row?

How can I implement tha开发者_如何学JAVAt?


I've never worked with the UniformGrid so there might be a better solution for this but as far as I can tell the UniformGrid doesn't hold much information except how many rows and columns it currently have so therefore this is the only solution that I can think of.

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;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消