Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

CollectionView SelectedItem Color #5622

@psp589

Description

@psp589

Description

When no BackgroundColor is set to ItemTemplate, the SelectedItem shows a Orange background color, when you set a BackgroundColor in ItemTemplate, then SelectedItem has the same color than the rest of the items and you could not Identify the SelectedItem.
It would be appreciated also being able to set the BackgroundColor / BorderColor of selectedItem instead of just a orange color.

Steps to Reproduce

Having this XAML

<ContentPage>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <CollectionView Grid.Column="0" 
                            SelectionMode="Single"
                            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                            ItemsSource="{Binding ObservableCollectionTest}">
                <CollectionView.ItemsLayout>
                    <GridItemsLayout Orientation="Vertical" />
                </CollectionView.ItemsLayout>
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Grid BackgroundColor="Wheat">
                            <Label Text="{Binding}"></Label>
                        </Grid>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
                
            </CollectionView>
            <Label Grid.Column="1"
                   Text="{Binding SelectedItem}" />
        </Grid>
    </ContentPage>

With this data in the Model

public static string SelectedItemPropertyName() { return nameof(SelectedItem); }
        private string _SelectedItem;
        public string SelectedItem
        {
            get
            {
                return _SelectedItem;
            }
            set
            {
                _SelectedItem = value;
                RaisePropertyChanged();
            }
        }
        public static string ObservableCollectionTestPropertyName() { return nameof(ObservableCollectionTest); }
        private ObservableCollection<string> _ObservableCollectionTest = new ObservableCollection<string>(new List<string>() { "Test1", "test2", "test3" } );
        public ObservableCollection<string> ObservableCollectionTest
        {
            get
            {
                return _ObservableCollectionTest;
            }
            set
            {
                _ObservableCollectionTest = value;
                RaisePropertyChanged();
            }
        }
SelectedItem = ObservableCollectionTest[1];

Expected Behavior

SelectedItem having a different background color or at least a border color

Actual Behavior

It looks like the rest of the items

Basic Information

  • Version with issue: 4.0.0.232914-pre6

  • IDE: Visual Studio Community 2017 version 15.9.9

  • Platform Target Frameworks:

    • Android: 8.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions