Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

ListView with different Controls (Details)

$
0
0

I couldn't find an answer yet. I am using Xamarin.Forms with the prism Framework and i want to display different Controls for selected ListView Items. To do this, i think i have to bind a ContentView to the SelectedItem Property. The idea is to display the correct control conditionally based on the type of the "SelectedItem".

Simplified XAML:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="http://prismlibrary.com"
             prism:ViewModelLocator.AutowireViewModel="True"
             xmlns:controls="clr-namespace:ControlApp.Views.Controls;assembly=ControlApp"
             x:Class="ControlApp.Views.ItemPage"
             Title="{Binding Title}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="3*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <ListView Grid.Column="0"  ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}"></ListView>
        <ContentView Grid.Column="1">
            <controls:ItemControlA Item="{Binding SelectedItem}"></controls:ItemControlA>
            <controls:ItemControlB Item="{Binding SelectedItem}"></controls:ItemControlB>
            <controls:ItemControlC Item="{Binding SelectedItem}"></controls:ItemControlC>
        </ContentView>
    </Grid>
</ContentPage>

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>