在运行时从堆栈面板中删除元素 [英] Remove elements from stackpanel at runtime

查看:51
本文介绍了在运行时从堆栈面板中删除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个StackPanel和内部网格.一些网格有0个孩子.

I have a StackPanel and inside grids. Some of the grids has 0 children. How to remove them at runtime?

推荐答案

您好,您可以使用以下代码行:

Hi Subscrbr, you can use this line of code:

yourStackPanel.Children.Clear(); //Removes all elements inside StackPanel

您的情况可能是这些代码行:

In your case may be these lines of code:

if (yourGrid.Children.Count < 1)
    yourStackPanel.Children.Remove(yourGrid);

希望有帮助.

此致.


这篇关于在运行时从堆栈面板中删除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆