I'm using Visual Studio 2022 preview 2.0 MAUI. I want to used a expander in MAUI, I have used Xamarin.CommunityToolkit.MauiCompat nuget. But I am seeing the exception System.Exception: 'Handler not found for view Xamarin.CommunityToolkit.UI.Views.Expander.
How can I resolve this issue in MAUI.
My UI is:
<behaviors:Expander>
<behaviors:Expander.Header>
<HorizontalStackLayout Margin="33,-10,22,10">
<Label FontAttributes="Bold" WidthRequest="230" VerticalOptions="Center" Text="Monday" TextColor="{DynamicResource Black}" FontSize="{DynamicResource AppFontSize_Default}"></Label>
<Image Margin="0,0,30,0" Source="plus.png" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand" WidthRequest="15" HeightRequest="20">
<Image.Triggers>
<DataTrigger TargetType="Image" Binding="{Binding Source={RelativeSource AncestorType={x:Type behaviors:Expander}}, Path=IsExpanded}" Value="True">
<Setter Property="Source" Value="plus.png" />
</DataTrigger>
</Image.Triggers>
</Image>
<RadioButton BackgroundColor="Transparent" BorderColor="{DynamicResource DefaultColor}"></RadioButton>
</HorizontalStackLayout>
</behaviors:Expander.Header>
<behaviors:Expander.ContentTemplate>
<DataTemplate>
<Label Text="{Binding CustomerNotes}" HorizontalOptions="StartAndExpand" TextColor="Black" FontSize="14" Padding="10,0,0,0"></Label>
</DataTemplate>
</behaviors:Expander.ContentTemplate>
</behaviors:Expander>
I have downloaded the nuget:
Also I have add handler on my MauiProgram.cs
page
// Register ALL handlers in the Xamarin Community Toolkit assembly
handlers.AddCompatibilityRenderers(typeof(Xamarin.CommunityToolkit.UI.Views.MediaElementRenderer).Assembly);
// Register just one handler for the control you need
handlers.AddCompatibilityRenderer(typeof(Xamarin.CommunityToolkit.UI.Views.MediaElement), typeof(Xamarin.CommunityToolkit.UI.Views.MediaElementRenderer));
I'm not sure how well the Xamarin Forms Community Toolkit works with MAUI. The Maui Community Toolkit is still in pre-release, but they have plans to add the Expander Control.
You can track the Expander proposal issue on Github.
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