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

ListView ViewCell ContextActions selected item background color

$
0
0

Hello,

i have the following listView created in xaml:

<ListView HorizontalOptions="FillAndExpand" x:Name="listView" ItemsSource="{Binding IzdelkiNaRacunu}" SeparatorVisibility="None" ItemSelected="OnItemSelected">
                         <ListView.ItemTemplate>
                          <DataTemplate>
                            <ctrls:ExtendedViewCell ShowSeparator="False" ShowDisclousure="False" BackgroundColor="#009BFA" SelectedBackgroundColor="#C9F1FE">
                                <ctrls:ExtendedViewCell.ContextActions>
                                    <MenuItem
                                        Text="Odstrani" 
                                        IsDestructive="True"
                                        Clicked="OnRemoveItemClicked"  
                                        CommandParameter="{Binding id}"/>
                                </ctrls:ExtendedViewCell.ContextActions>
                                <StackLayout Orientation="Vertical">
                                    <StackLayout Orientation="Horizontal" Padding="10,13,10,0" VerticalOptions="Center">
                                        <Label Text="{Binding naziv}" TextColor="Black" WidthRequest="200" FontSize="Small" />
                                        <Button Text="{Binding Kolicina}" WidthRequest="50" HeightRequest="15" TextColor="Black" BackgroundColor="Transparent" HorizontalOptions="Start"  
                                            FontSize="Small"
                                            CommandParameter="{Binding id}" 
                                            Clicked="OnTapped" />
                                        <Label Text="{Binding Popust}" WidthRequest="50" TextColor="Black" HorizontalOptions="Start"  FontSize="Small"/>
                                        <Label Text="{Binding CenaDDV}" WidthRequest="65" TextColor="Black" XAlign = "End"  FontSize="Small"/>
                                    </StackLayout>
                                    <BoxView HeightRequest="1" Color="#8CA5AE" VerticalOptions="EndAndExpand"/>
                                </StackLayout>
                            </ctrls:ExtendedViewCell>
                          </DataTemplate>
                         </ListView.ItemTemplate>
                        </ListView>

I used ExtendedViewCell from xlabs to which I added SelectedBackgroundColor property.

In ExtendedViewCellRenderer for IOS I added this:

cell.SelectedBackgroundView = new UIView {
                    BackgroundColor = extendedCell.SelectedBackgroundColor.ToUIColor(),
                };

And this works as long as I don't add ContextActions to ViewCell. In that case selected item background is rendered with default grey color.

So my question is how can I set the color for selected item and use context actions?


Viewing all articles
Browse latest Browse all 91519

Trending Articles