Keep highlighting the cell when user deselect

excel selecting multiple cells turn off
why is excel selecting multiple cells when i click on one
excel keeps highlighting cells|
how to deselect a cell in excel 2016
excel deselect cells not working
how do i stop excel from selecting multiple cells in one click
excel selects multiple cells on mouse click
excel not selecting correct cell

I'm using Xamarin Forms ListView as a SideBar. How can I prevent users from deselecting cell? Or at least keep highlighting the cell when users deselect it. This is how I'm binding


                   <ListView x:Name="listView" SelectionMode="Single">
                        <ListView.ItemsSource>
                            <x:Array Type="{x:Type x:String}">
                                <x:String>Management</x:String>
                                <x:String>Information</x:String>
                                <x:String>Language</x:String>
                                <x:String>Settings</x:String>
                            </x:Array>
                        </ListView.ItemsSource>
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextCell Text="{Binding}" />
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

According to your description, when you select item from ListView, this item highlighting, you want to this item still highlighting when this item is not selected state. It seems that you want to select multiple item from ListView.

I do one sample, you can take a look:

 <ContentPage.Content>
    <StackLayout>
        <ListView
            ItemTapped="ListView_ItemTapped"
            ItemsSource="{Binding Items}"
            SelectionMode="Single">

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout BackgroundColor="{Binding background}" Orientation="Horizontal">
                            <Label
                                HorizontalOptions="StartAndExpand"
                                Text="{Binding DisplayName}"
                                TextColor="Fuchsia" />
                            <BoxView
                                HorizontalOptions="End"
                                IsVisible="{Binding Selected}"
                                Color="Fuchsia" />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage.Content>

public partial class Page10 : ContentPage
{
    public Page10 ()
    {
        InitializeComponent ();
        this.BindingContext = new MultiSelectItemsViewModel();
    }

    private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
    {
        Model m = e.Item as Model;

        if(m!=null)
        {
            m.Selected = !m.Selected;
            if(m.background==Color.White)
            {
                m.background = Color.BlueViolet;
            }
            else
            {
                m.background = Color.White;
            }
        }

    }
}

public class Model:ViewModelBase
{
    public string DisplayName { get; set; }
    private bool _Selected;

    public bool Selected
    {
        get { return _Selected; }
        set
        {
            _Selected = value;
            RaisePropertyChanged("Selected");
        }
    }
    private Color _background;
    public Color background
    {
        get { return _background; }
        set
        {
            _background = value;
            RaisePropertyChanged("background");
        }
    }
}

public class MultiSelectItemsViewModel
{
    public ObservableCollection<Model> Items { get; set; }


    public MultiSelectItemsViewModel()
    {
        Items = new ObservableCollection<Model>();
        Items.Add(new Model() { DisplayName = "AAA", Selected = false,background=Color.White });
        Items.Add(new Model() { DisplayName = "BBB", Selected = false , background = Color.White });
        Items.Add(new Model() { DisplayName = "CCC", Selected = false, background = Color.White });
        Items.Add(new Model() { DisplayName = "DDD", Selected = false, background = Color.White });
        Items.Add(new Model() { DisplayName = "EEE", Selected = false, background = Color.White });

    }


}

If my reply helps you, please remember to mark my reply as answer, thanks.

Update:

Don't allow user to unselect the selected item.

 private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
    {
        Model m = e.Item as Model;

        if(m!=null)
        {
            m.Selected = true;
            m.background = Color.Blue;


        }

    }

How-to Make Excel STOP Selecting Range/Extending Range , You can then do whatever you like with this range of cells highlighted. 2) You can select a starting cell with your mouse and then click and hold the left mouse key while on another cell or move the active cell with your arrow keys, Excel will deselect the highlighted 3) Use the F8 Key or Shift+F8 Key to select a range. After copying and pasting a cell (or cells) the original cell that I copied remains selected (with the dotted lines around it). The only way it will deselect is when I 1)close and reopen the workbook or 2) copy and paste another cellin which case it does the same thing to the new cell that I copied.

Depending on your needs, I've done something similar but with controls inside each row, like a checkbox. https://xamarinhelp.com/multiselect-listview-xamarin-forms/

Deselect a selection - Office Support, If you've already selected a cell, clicking on it again will deselect it. Keep in touch and stay productive with Teams and Microsoft 365, even when you're Sometimes when you're selecting multiple cells or ranges in Excel, you those cells, continue holding the Ctrl key and reselect those cells (for Mac, use the Cmd key). Keep users from selecting locked cells in Excel. Then, the user will be able to select a locked cell. Doing so will execute the macro, which will reset the property. The user will be able to

Use the SelectedItem property of the ListView. As long as SelectedItem property is not set back to null, the currently selected item will remain highlighted.

How to Deselect Cells in Microsoft Excel Without Starting Over, Selecting too many cells or highlighting the wrong range of cells is an Alternatively, hold down Shift and use the arrow keys to extend the� I just upgraded from Windows 7 to Windows 10 and have found typing excruciating. The cursor randomly selects and deselects within the text box. My writing gets cut off before I've finished typing.

Excel: Cell Selection and Deselection, Most regular Excel users have tried to select multiple cells or ranges and Once you finish the selection, there's no way to deselect the unwanted cells. and Excel will keep selecting additional cells until you stop pressing� A user of mine had this problem on 2007. It would select 2 cells in the same column. I emailed the excel doc to myself and a co-worker. It only selects one cell on my excel 2010. It selects 2 cells in the same row on my co-workers excel 2010. Changing the view zoom to something other than 100% solves the problem.

How to Deselect Cells in Excel (An Easy Way) � Trump Excel, Learn how to quickly deselect cells in Excel (specific cells or columns). highlight a range of cells and you accidentally end up selecting an extra row or column. One way to do this is to hold the Control key and then use your mouse to select� Deselect part of cells or ranges from selection with Kutools for Excel. If you need to deselect many cells or ranges from selection, the VBA above is not a good way. So we introduce the following trick, the Select Range Helper tools of Kutools for Excel. It can help you deselect any cell or range from selection easily and quickly.

Unselecting a single cell after highlighting a range, In Excel, if I highlight a range of cells, and then realise I have accidentally highlighted one I don't Hold down the CTRL key while clicking the cell you want to de-select. Here's a couple of links that may be of use to you: That's been the standard way to deselect in any Microsoft List control for two decades. Huh funny I have used this basically everytime I had to supress highlighting in a ListView. I think I even found this method of supressing in one of the Xamarin Samples.

Comments
  • You can also use a CollectionView with multiselect :) docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/…
  • You are taking it wrong. What I want is there is always 1 highlighted Item and just 1. User cant do anything to unhighlight it
  • @JonFlame, you mean that you can not disselect the selected item once you selected it?
  • That's what I want. I want user can not unselect the selected Item once they selected it
  • @JonFlame, If you don't allow user to unselect item once they select it, you can see my update, just change some code in ListView_ItemTapped event.
  • It's worked, thank you. But can we do this without binding anything?
  • I just want to use something available in ListView. I don't want to Bind anything into it
  • I tried it. It didn't work. It kept the SelectedItem but not the highlight