Skip to content

Using collection view with mixed types elements ? (heterogeneous collection) #27235

Answered by stephenquan
bebenlebricolo asked this question in Q&A
Discussion options

You must be logged in to vote

What's wrong with setting your DataTemplate to a ContentView?

You can defined 3 ControlTemplates in a ResourceDictionary and you use one of the ControlTemplate as the default and you can switch on either of the other two with the use of DataTriggers.

<!-- MainPage.xaml -->
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="MauiCustomView.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:MauiCustomView"
    xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
    x:Name="this"
    x:DataType="local:MainPage"
    BindingContext="{Reference this}">
    <C…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bebenlebricolo
Comment options

@stephenquan
Comment options

@bebenlebricolo
Comment options

Answer selected by bebenlebricolo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants