question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CheckComboBox Lose Tags While Scrolling In Larg List

See original GitHub issue

Describe the bug When using Large List With CheckComboBox After Specific Items Count, we start losing some tags, while we scrolling

I think this happens due to the rendering behavior of the visual tree.

To Reproduce Steps to reproduce the behavior:

<hc:CheckComboBox
    FontSize="19"
    VerticalAlignment="Center"
    x:Name="ChBoxList"
/>

in code behind

var ls = new List<string>();
for (int i = 0; i < 1000; i++)
{
    ls.Add($"[{i}] Rand ELM");
}

this.ChBoxList.ItemsSource = ls;

Expected behavior Tags should not disappear

Screenshots HC_ISSUE_8

I added the order to notice caching/buffer behavior So, if we select item Number 50 And 90 and we Scroll To 120 We Will Lose Item Number 50, but 120 not yet.

Environment (please complete the following information):

  • .net: [e.g. 4.7.2]
  • IDE Rider 2020.3
  • Version 3.0.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
AlBannaTechnocommented, Dec 19, 2020

The problem occurs because of this line https://github.com/HandyOrg/HandyControl/blob/e5a94c877aaab8d43f6438ae6962cf2364013ef3/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs#L232

I know that we need to get the template from the current CheckComboBoxItem to have a unified design, But the problem with ItemContainerGenerator is caching mechanism: virtualization,

So we have two solutions

  • first : good for GPU Performance, But not for CPU Performance, Also have some issues with prmitive types and this is to implement thing like
private List<CheckComboBoxItem> _latestPopulatedItems = new List<CheckComboBoxItem>();

/// 

// _panel.Children.Clear();

    foreach (var item in SelectedItems)
            {
                if (ItemContainerGenerator.ContainerFromItem(item) is CheckComboBoxItem checkComboBoxItem)
                {
                    if (_latestPopulatedItems.Contains(checkComboBoxItem))
                    {
                        continue;
                    }
                    
                    _latestPopulatedItems.Add(checkComboBoxItem);
                    
                    var tag = new Tag
                    {
                        Style = TagStyle,
                        Tag = checkComboBoxItem
                    };

                    tag.SetBinding(ContentControl.ContentProperty, new Binding(DisplayMemberPath) { Source = item });
                    _panel.Children.Add(tag);
                }
            }

// then here iterate over _latestPopulatedItems to remove items that do not exist in SelectedItems
// but this will introduce an issue when comparing primitive types, except we used references or unsafe code,
// and we can not force developers to use that
  • Second: Bad For GPU If items collection is very large, Good For CPU, One Line Implementation. just stop virtualization VirtualizingPanel.IsVirtualizing="False"
<hc:CheckComboBox
    FontSize="19"
    VerticalAlignment="Center"
    x:Name="ChBoxList"
VirtualizingPanel.IsVirtualizing="False"
/>

The Second Solution is the best One, But This Should be Documented For Such Scenario

0reactions
NaBiancommented, Sep 3, 2022

closed in 7519c7e

Read more comments on GitHub >

github_iconTop Results From Across the Web

CheckComboBox loses values when scrolled out of view
IsVirtualizing=False to the ListView control, you will see that CheckComboBox controls retain their values throughout the scrolling/resizing.
Read more >
combobox loses selected value while scrolling listview
If 'SelectionChanged' event of combobox fires while scrolling ListView, then it means the combo box has the focus still. If you are able...
Read more >
Infinite scroll and "Select all"
We do this in several places within our application. Select All should mean select all, not select visible as that isn't generally useful....
Read more >
Large List in Alert/Confirm with Scroll
I am making a custom component with a repeating panel and a couple of buttons below to be shown in an alert as...
Read more >
Xceed wpf toolkit. I'm coding in C# and WPF (XAML). Well it
When I first installed the toolkit, the components did not appear in the ... @Clemens DateTimePicker has separate dates and times with dropdown...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found