Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to have a list of element that it is collapsed depending of a Dynamic configuration.

I arrive to bind the list and collpase the element but it seems that the scrollbar is not correctly refresh because if I have only 20 elements (e.g 10 first and 10 last) on 100 elements, the scrollbar take some times (and it is display strange) to scrolldown.

The element are collapsed when we open the combobox perhaps the scrollbar is already created ?

I think that the scrollbar contains also the element hidden. How we can change this to contains only element displayed.

How I can do a scrollbar that is limited to the number of Element?

Here is a small video where you can see my problem (it can be more clear):

Probleme Scrollbar.wmv - Google Drive[^]

What I have tried:

I have create this combobox

<ComboBox
         ItemsSource="{Binding Path=List, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}"
         SelectedValue="{Binding Elements[0]}"
         SelectedValuePath="Value">
         <ComboBox.ItemTemplate>
            <DataTemplate>
               <WrapPanel>
                    <Image Source="{Binding UriIcon, Converter={StaticResource UriToBitmapImage}}" Stretch="None" />
               </WrapPanel>
            </DataTemplate>
         </ComboBox.ItemTemplate>
      </ComboBox>


Here is the style of collapsed element

<Style x:Key="ComboBoxEnableItem" TargetType="{x:Type ComboBoxItem}">
        <Setter Property="Visibility" Value="{Binding Path=IsEnabled, Converter={StaticResource b2v}}" />
    </Style>


here is the dropdownopen function :
private void ComboBox_DropDownOpened(object sender, EventArgs e)
        {

            foreach (BottomAreaDisplay element in App.CurrentImplement.Model.BottomAreas.BottomAreaEnumList)
            {
                if (App.CurrentImplement.Model.BottomAreas.ElementShallBeDisplayed(element.Value))
                    element.IsEnabled = true;
                else
                    element.IsEnabled = false;
            }
        }
Posted
Updated 11-Jul-21 21:15pm
v2
Comments
[no name] 12-Jul-21 14:21pm    
Instead of "collapsing", only load the relevant items in the first place. Then things will "line up". (The "selection changed" logic considers "items"; not "visibility"; you have to "scroll" yourself in certain cases)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900