Ok. , !
, , , . , , . , , ListView! , . , ListViews, .
MinHeight ListView.
, , StackPanel, MeasureOverride ArrangeOverride. ListView
CustomPanel:
public class ScrollablePanel : StackPanel
{
protected override Size MeasureOverride(Size constraint)
{
Size tmpSize = base.MeasureOverride(constraint);
tmpSize.Height = (double)(this.Children[0] as UIElement).GetValue(MinHeightProperty);
return tmpSize;
}
protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
{
Size tmpSize = new Size(0, 0);
tmpSize.Width = finalSize.Width;
tmpSize.Height = finalSize.Height;
this.Children[0].SetCurrentValue(HeightProperty, tmpSize.Height);
this.Children[0].Arrange(new Rect(new Point(0, 0), tmpSize));
return tmpSize;
}
}
XAML
<Window x:Class="WpfTest1.ScrollTestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:WpfTest1"
Title="ScrollTestWindow" Height="400" Width="700">
<ScrollViewer >
<DockPanel LastChildFill="True" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Visible">
<Grid DockPanel.Dock="Top">
<TextBlock Text="Example controls above listview" Background="LightGray" FontSize="30"></TextBlock>
</Grid>
<Grid DockPanel.Dock="Bottom">
<TextBlock Text="Example controls below listview" Background="LightGray" FontSize="30"></TextBlock>
</Grid>
<local:ScrollablePanel>
<ListView FontSize="30" MinHeight="80">
<ListView.View>
<GridView>
<GridViewColumn Width="190" Header="Date" />
<GridViewColumn Width="200" Header="Day Of Week" DisplayMemberBinding="{Binding DayOfWeek}" />
<GridViewColumn Width="120" Header="Year" DisplayMemberBinding="{Binding Year}" />
</GridView>
</ListView.View>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
<sys:DateTime>1/1/1</sys:DateTime>
</ListView>
</local:ScrollablePanel>
</DockPanel>
</ScrollViewer>
</Window>
, , -!
@sisyphe , :)