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

Empty cell on ListView

$
0
0

I am trying to create a ListView that bind a list of colors to a BoxView, it binds correctly, on item select the BoxView changes color, but the LisTView shows an empty cell, what am i doing wrong?

<ContentPage.Padding>
    <OnPlatform x:TypeArguments="Thickness" 
                iOS="10, 20, 10, 0" 
                Android="10, 0" 
                WinPhone="10, 0" />
</ContentPage.Padding>
<StackLayout>
    <ListView x:Name="listView" 
              SelectedItem="{Binding Source={x:Reference boxView}, 
                                    Path=Color, 
                                    Mode=TwoWay}">

        <ListView.ItemsSource>
            <x:Array Type="{x:Type Color}">
                <x:Static Member="Color.Aqua" />
                <x:Static Member="Color.Black" />
                <x:Static Member="Color.Blue" />
                <x:Static Member="Color.Fuchsia" />
                <x:Static Member="Color.Gray" />
                <x:Static Member="Color.Green" />
                <x:Static Member="Color.Lime" />
                <x:Static Member="Color.Maroon" />
                <Color>Navy</Color>
                <Color>Olive</Color>
                <Color>Pink</Color>
                <Color>Purple</Color>
                <Color>Red</Color>
                <Color>Silver</Color>
                <Color>Teal</Color>
                <Color>White</Color>
                <Color>Yellow</Color>
            </x:Array>
        </ListView.ItemsSource>
    </ListView>
    <BoxView x:Name="boxView" 
             Color="Lime" 
             HeightRequest="100" />
</StackLayout>

I also tried to add ítem template to the list view

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Label Text="{Binding .}"></Label>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate

Viewing all articles
Browse latest Browse all 204402

Trending Articles



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