I want to make expandable tree view in android like below screen short Expandable List View . I have tried but i want it with explanation. Hope will get better solution.
Thanks in advance.
There is currently a PR for Xamarin to include this (see here )
For the time being, you can use ExpandableView NuGet which is quite simple:
<expandable:ExpandableView>
<expandable:ExpandableView.PrimaryView>
//{YOUR MAIN VIEW HERE}
</expandable:ExpandableView.PrimaryView>
<expandable:ExpandableView.SecondaryViewTemplate>
<DataTemplate>
//{YOUR DROP-DOWN MENU TEMPLATE HERE} you can use DataTemplateSelector too
</DataTemplate>
</expandable:ExpandableView.SecondaryViewTemplate>
</expandable:ExpandableView>
You can use Xamarin Community Toolkit package:
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
You have possibility to define a header, nest several expander, define the View as a Content or using a DataTemplate, define animations ( ExpandAnimationEasing
, CollapseAnimationEasing
)...
<xct:Expander IsEnabled="{Binding IsEnabled}" ExpandAnimationEasing="{x:Static Easing.CubicIn}"
CollapseAnimationEasing="{x:Static Easing.CubicOut}">
<xct:Expander.Header>
<Label Text="Nested expander" FontSize="30" FontAttributes="Bold"/>
</xct:Expander.Header>
<xct:Expander.ContentTemplate>
<DataTemplate>
<StackLayout Spacing="0" Margin="10" Padding="1" BackgroundColor="Black">
<BoxView HeightRequest="50" Color="White" />
<BoxView HeightRequest="50" Color="Red" />
<BoxView HeightRequest="50" Color="White" />
</StackLayout>
</DataTemplate>
</xct:Expander.ContentTemplate>
</xct:Expander>
The Expander control is known to show unwanted behavior when used in a ListView or CollectionView. At this time we recommend not using a Expander in one of these controls.
Nuget: https://www.nuget.org/packages/Xamarin.CommunityToolkit
Documentation: https://docs.microsoft.com/en-us/xamarin/community-toolkit/views/expander
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.