I have a ListBox with many display objects, each of which can be of variable height, depending on the number of values that each object has. Check out my previous question that has been answered.
Many objects have a height of 5 lines, while others are 1. The scroll bar in the ListBox does not seem to be like this, possibly due to virtualization. While you scroll through the scroll, the thumb on the scroll bar will change its size based on how many elements are actually inserted at this current time. This makes the thumb very large at times and very small at other times.
Since this ListBox is also contained in TabControl, when switching from one tab to another, the ListBox will often move to another section when you return to it.
Any ideas how to solve a problem like this?
Additional Information:
Disabling virtualization resolves the issue of scrolling, although at the cost of a slower initial display. However, resizing the ListBox with the contents inside causes some serious lagging when resizing horizontally (vertical is good), which I believe is related to changing the width of the template and requires redrawing for each element:
<DataTemplate DataType="{x:Type xmlset:Variable}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border BorderThickness="1,0,0,1" BorderBrush="Black">
<TextBlock Margin="2,2,0,2" Text="{Binding Path=Identifier.Name, Mode=OneWay}"/>
</Border>
<ItemsControl IsTabStop="False" Grid.Column="1" ItemsSource="{Binding Path=Values, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderThickness="1,0,0,1" BorderBrush="Black">
<TextBlock Margin="2,2,0,2" Text="{Binding Path=Optimization, Mode=OneWay}"/>
</Border>
<Border Grid.Column="1" Width="Auto" BorderThickness="1,0,1,1" BorderBrush="Black">
<TextBox Margin="0,2,0,2" BorderThickness="0" Text="{Binding Path=Value}" TextChanged="TextBox_TextChanged"/>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</DataTemplate>
, val . HorizontalContentAlignmment = Stretch, , .
-------------------
- var - opt - val -
- -------------
- - opt - val -
- -------------
- - opt - val -
-------------------
: , , .