I'm making app with using Xamarin.form.
I created tableview that has three sections from xaml. And I want to hide or remove last section (entire section, with sectionTitle).
But unfortunately, Xamarin xaml doesn't support conditional processing. (only works if element has isVisible property but tableSection does not have it)
Is there any option I can do?
Thanks.
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>
Code Behind:
Table.Root.Remove(Section);
-OR-
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];
-OR-
TableSection section = Table.Root.IndexOf(Section);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With