Declined
Last Updated: 09 Jul 2019 13:06 by ADMIN
BDV
Created on: 19 Jun 2019 08:01
Category: UI for WPF
Type: Bug Report
0
telerik:RadListBox - multi selection includes an item that's not intended

See attached picture together with these steps.

  1. select a item in the list
  2. import multiple other items in one go -> the last imported item is marked as selected (this is OK), the previously selected item is no longer marked as selected (this is OK).
  3. SHIFT select the first item of the ones imported in step 2 -> the items between the last imported item and the first imported item are selected, but the item that was selected in step 1 is now also selected...

 

Thanks in advance!

Bart

 

8 comments
BDV
Posted on: 02 Jul 2019 14:18

ok, thanks for the info. We know enough for now.

Can I (or you) close this query?

Greetings,

Bart

ADMIN
Dimitar Dinev
Posted on: 02 Jul 2019 13:06
Hi Bart,

The most MVVM friendly approach is to create a custom command and in its OnExecute use the SelectionHelper class.
public static class ListBoxCommands
    {
        public static RoutedUICommand SelectItemCommand { get; private set; }
 
        static ListBoxCommands()
        {
            SelectItemCommand = new RoutedUICommand("SelectItem", "SelectItem", typeof(FrameworkElement));
 
            var selectItemCommandBinding = new CommandBinding(SelectItemCommand, OnSelectItemCommandExecuted);
            CommandManager.RegisterClassCommandBinding(typeof(FrameworkElement), selectItemCommandBinding);
        }
 
        private static void OnSelectItemCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var listBox = (RadListBox)sender;
            listBox.SelectionHelper.UpdateSelectionOnUserInteraction(e.Parameter);
        }
    }

You can then use the command like so:

<Button Grid.Column="0" Height="30" Command="local:ListBoxCommands.SelectItemCommand"
        CommandTarget="{Binding ElementName=listBox}"
        CommandParameter="{Binding Items[2]}">Select Item 3</Button>

In addition, I want to mention that you can also manipulate the SelectedItems through the ViewModel using the ListBoxSelectedItemsBehavior and its property SelectedItemsSourceYou can read more on the provided link.

Attached, you can find the updated project.

I hope this resolves your query.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Attached Files:
BDV
Posted on: 01 Jul 2019 12:45

Hi,

Do you have a way to change the selection that's compatible with MVVM?

As far as we can see SHIFT/CTRL is not compatible with programmatic selection changes?

Thanks,

B.

ADMIN
Dimitar Dinev
Posted on: 28 Jun 2019 15:00
Hi Bart,

I'm looking forward to your reply. Have a nice weekend.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
BDV
Posted on: 28 Jun 2019 08:12

Hi,

thanks for the info! From the user point of view this now indeed behaves as expected. I'll have a dev look at the solution on Monday.

Thanks again!

Bart

ADMIN
Dimitar Dinev
Posted on: 27 Jun 2019 15:13
Hello Bart,

Thank you for the detailed description and sample project.

The shift/ctrl selection works through the UI of the control and not through programmatic selection.

To achieve the desired behavior, you can simulate UI Selection by using the SelectionHelper class of the RadListBox. For your convenience I've modified the sample project in which I demonstrated this approach. I've removed the Command and added the following event handler:
private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.listBox.SelectionHelper.UpdateSelectionOnUserInteraction(this.listBox.Items[2]);
        }
Attached, I'm sending you the updated project. Please, review it and let me know if it delivered the desired result.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Attached Files:
BDV
Posted on: 26 Jun 2019 09:41

Hi,

please find attached a test app. To reproduce the issue, follow these steps:

  1. click on 'Item 4' in the list
  2. click the gray button 'Select item 3' to get Item 3 programmatically selected in the list. This clears the selection of Item 4 (this is as expected)
  3. now hold down the SHIFT key and click Item 1 in the list

--> result: Items 1, 2, 3, and 4 are selected

--> expected: Items 1, 2 and 3 are selected

 

Thanks,

Bart

Attached Files:
ADMIN
Vladimir Stoyanov
Posted on: 25 Jun 2019 15:38
Hello Bart,

Thank you for the provided picture and sample steps. 

May I ask you to elaborate on what you mean by "import multiple other items in one go"? Are you pasting the items, drag&dropping them or importing them in a different way? Can you share some sample xaml/code demonstrating the setup on your end? This will hopefully allow us to reproduce the behavior on our end and investigate it.

I am looking forward to your reply. 

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.