Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Button inside ListView

$
0
0

Hi all,

I think I have found a possible bug on Xamarin Forms (android): when you add a button to a ListView ViewCell, the selectedItem binding property stops working on Android (it still works on iOS).

Sample XAML code (including the Button, selectedItem stops working):

<ListView ItemsSource="{Binding Events}" SelectedItem="{Binding DetailItem, Mode=TwoWay}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Label Grid.Column="0" Text="{Binding Title}" />
                                <Button Grid.Column="1" Text="Show People" Clicked="OnShowPeopleGoingButtonClick" />
                            </Grid>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

If I remove Button from ListView, SelectedItem Binding works:

<ListView ItemsSource="{Binding Events}" SelectedItem="{Binding DetailItem, Mode=TwoWay}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Label Grid.Column="0" Text="{Binding Title}" />
                            </Grid>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Is this a known bug?

Thanks,

Daniel


Viewing all articles
Browse latest Browse all 89864

Trending Articles



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