Question

Sample Data

UK
  -london
      -london 1
      -london --
      -london 100
  -Newcastle
      -Newcastle 1
      -Newcastle 2
      -Newcastle 3
  -liverpool
USA
  -New york
  -califonia
China
  -one
  -two

I have a radTreeListView with the sample structure above. Every selectable item in the radTreeListView has a checkbox that a user can check or unCheck to selected or deselect the item.

My requirement is to make sure the user can only select items under the same rootItem/Parent.

A user should not be able to select an item under UK and then another item under USA or China.

They can however select UK, London 1, Newcastle 3 and liverpool

I basically want to make sure that all selections made have the same rootParent.

And this is how am retrieving the selected items

 private void radTreeListView_SelectionChanged(object sender, SelectionChangeEventArgs e)
    {
        //Limit number of items that can be selected from the radTreeListView
        if (totalSelectedItems() > 3 && e.AddedItems.Count > 0)
        {
            radTreeListView.Unselect(e.AddedItems);
            radTreeListView.Rebind();
        }

        //Retrieve items selected from the radTreeListView 
        System.Collections.ObjectModel.ObservableCollection<object> selectedItems = radTreeListView.SelectedItems;
        StringBuilder userSelection = new StringBuilder();
        const string seperator = ", ";
        foreach (object item in selectedItems)
        {
            myDataclass myItems = (myDataclass)item;
            userSelection.Append(myItems.Name).Append(seperator);
        }
    }

I have tried code below but parent is returned null

 object parent = radTreeListView.ItemContainerGenerator.ContainerFromItem(radTreeListView.SelectedItem);
Was it helpful?

Solution

Ok, i made a report of the same issue and answer was provided this time around radTreeListView - allow selection of items only under same rootItem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top