Set Cell BackgroundColor on Cell Swipe Button Tap

2 posts, 0 answers
  1. Trevor
    Trevor avatar
    22 posts
    Member since:
    Feb 2017

    Posted 02 Nov Link to this post

    So I have a button that is revealed when a user swipes a cell. I then want to change the Cell BackgroundColor when the revealed button is tapped. I am having a tough time since the Button has no correlation to the cell the user swiped. I tried to implement a style trigger as I feel this would be the way to do it but I am not sure how to implement that with the RadListView. This is what I tried:

     

    <ContentView.Resources>
            <ResourceDictionary>
                <Style TargetType="dataControls:RadListView" x:Key="CellStyle">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ButtonText}"
                                     Value="Start">
                            <Setter Property="BackgroundColor"
                                    Value="White" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ButtonText}"
                                     Value="Complete">
                            <Setter Property="BackgroundColor"
                                    Value="Gray" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ResourceDictionary>
        </ContentView.Resources>
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    556 posts

    Posted 07 Nov Link to this post

    Hello, Trevor,

    You can use a custom ListView ItemTemplateSelector and return different templates based on a property of the business object. You can then change this property from the button inside the ItemSwipeContentTemplate and when you switch back to the standard view - the change will be applied. Please have a look at the attached sample where clicking the button changes the foreground color of the item.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top