I have a WPF ListView inside StackPanel, with Height=”Auto”. It’s great that it does what I wanted to – changes it’s height according to the all items contained in ListView. I have also HorizontalScrollBarVisiblity=”Auto” on my ListView, which suits my needs.
The problem occurs when the whole width of columns of my ListView is greater than width of ListView control (i.e. user decreases width of a window and this control). In that case obviously horizontal scrollbar appears – thats ok. The problem is that this scrollbar covers last (bottom) item of the ListView’s items so it is partially not visible.
Vertical scrollbar doesn’t appear and this is ok – I don’t want it. I just want to have my ListView height beeing calculated properly, so it considers the height of shown horizontal scrollbar and includes it in calculation so all items are wholy visible.
Xaml code example:
<ListView Name="lvProcedures" ItemsSource="{Binding Path=Procedures}" SelectionMode="Single">
<ListView.View>
<GridView AllowsColumnReorder="False" ColumnHeaderToolTip="Lista zabiegów">
<GridViewColumn DisplayMemberBinding="{Binding Path=procedure}" Header="A" Width="150" />
<GridViewColumn DisplayMemberBinding="{Binding Path=location}" Header="B" Width="100" />
<GridViewColumn DisplayMemberBinding="{Binding Path=material}" Header="C" Width="180" />
<GridViewColumn DisplayMemberBinding="{Binding Path=other}" Header="D" Width="180" />
<GridViewColumn DisplayMemberBinding="{Binding Path=description}" Header="E" Width="400" />
</GridView>
</ListView.View>
</ListView>
I’ve now hanged on idea to create user control (maybe only ListView’s derieved class??) which overrides MeasureOverride but I don’t think it is good way to solve such a small but iritating “bug” and it also still makes me trouble to implement the solution.
Can somebody provide some elegant solution for this problem?
Any idea would be appreciated.
@bartivo: I’m not getting the same result as you – the bottom horizontal scrollbar doesn’t appear to obscure the lowest item. I’m wondering if you’re using a custom ControlTemplate for your ListView and ScrollViewer, b/c the default ScrollViewer template has two rows the ScrollContentPresenter in the first (Height=”*”) and the HorizontalScrollBar in the 2nd row (Height=”Auto”) thus ensuring that the one doesn’t overlap the other.
Maybe you could try using these styles for your ListView and ScrollViewer and see if that problem still occurs: