如何隐藏或删除由xaml创建的特定tableSection(Xamarin.forms)? [英] How to hide or remove particular tableSection(Xamarin.forms) which created by xaml?

查看:114
本文介绍了如何隐藏或删除由xaml创建的特定tableSection(Xamarin.forms)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xamarin.form制作应用程序.

I'm making app with using Xamarin.form.

我创建了具有xaml的三个部分的tableview. 我想隐藏或删除最后一个部分(整个部分,带有sectionTitle).

I created tableview that has three sections from xaml. And I want to hide or remove last section (entire section, with sectionTitle).

但是不幸的是,Xamarin xaml不支持条件处理. (仅当元素具有isVisible属性但tableSection没有它时才有效)

But unfortunately, Xamarin xaml doesn't support conditional processing. (only works if element has isVisible property but tableSection does not have it)

我能做些什么选择吗?

谢谢.

推荐答案

是的,您可以执行以下操作来动态删除部分:

Yes you can remove a section dynamically doing the following:

XAML:

<TableView x:Name="Table">
    <TableSection x:Name="Section">
        <TextCell Text="something"/>
    </TableSection>
    <TableSection x:Name="Section2">
        <TextCell Text="something2"/>
    </TableSection>
</TableView>

后面的代码:

Table.Root.Remove(Section);

-或-

Table.Root.Remove(0); //If you know the index of the section

如果您需要在某个时候重新添加它,请确保将其存储在后面代码中的变量中,然后再将其删除,如下所示:

If you need to add it back at some point, be sure to store it in a variable in you code behind before removing it like so:

TableSection section = Table.Root[0];

-或-

TableSection section = Table.Root.IndexOf(Section);

这篇关于如何隐藏或删除由xaml创建的特定tableSection(Xamarin.forms)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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