Bri*_*Lee 10 tableview xamarin xamarin.forms
我正在使用Xamarin.form制作应用程序.
我创建了tableview,它有三个来自xaml的部分.我想隐藏或删除最后一节(整个部分,带sectionTitle).
但不幸的是,Xamarin xaml不支持条件处理.(仅当元素具有isVisible属性但tableSection没有它时才有效)
我可以做任何选择吗?
谢谢.
hva*_*an3 19
是的,您可以动态删除一个部分执行以下操作:
XAML:
<TableView x:Name="Table">
<TableSection x:Name="Section">
<TextCell Text="something"/>
</TableSection>
<TableSection x:Name="Section2">
<TextCell Text="something2"/>
</TableSection>
</TableView>
Run Code Online (Sandbox Code Playgroud)
代码背后:
Table.Root.Remove(Section);
Run Code Online (Sandbox Code Playgroud)
-要么-
Table.Root.Remove(0); //If you know the index of the section
Run Code Online (Sandbox Code Playgroud)
如果您需要在某些时候将其添加回来,请务必将其存储在代码后面的变量中,然后再将其删除:
TableSection section = Table.Root[0];
Run Code Online (Sandbox Code Playgroud)
-要么-
TableSection section = Table.Root.IndexOf(Section);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4050 次 |
| 最近记录: |