Reputation: 25
<UserControl x:Class="PMS.UserControlUsersList"
//...
xmlns:local="clr-namespace:PMS"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="ListViewStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
</Style>
</UserControl.Resources>
<Grid>
<DockPanel>
<Expander Grid.Row="0" Header="Filters" Margin="10" Background="White" DockPanel.Dock="Top">
<Grid>
//...
</Grid>
</Expander>
<ListView Margin="10" ItemsSource="{Binding FilteredUsers}">
<ListView.View>
<GridView>
<GridViewColumn HeaderContainerStyle="{StaticResource ListViewStyle}" Header="First name" DisplayMemberBinding="{Binding FirstName}" Width="Auto"/>
<GridViewColumn HeaderContainerStyle="{StaticResource ListViewStyle}" Header="Last name" DisplayMemberBinding="{Binding LastName}" Width="Auto"/>
//other GridViewColum
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</Grid>
</UserControl>
Hello. When I resize window VerticalScrollBar in ListView doesn't appear. HorizontalScrollBar works fine. How I can fix this? When I set MaxHeight VerticalScrollBar is visible but this isn't good solution :P
UserControl is placing in StackPanel:
<StackPanel x:Name="StackPanelMain" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch">
<!-- my UserControl is here -->
</StackPanel>
Edit: Look how it looks with me. UserControl is displayed in the bottom right corner. On the left is a menu and a bar at the top. In the main window I use WindowStyle = "None".
Here, I pasted the full Window and Usercontrol code: full code
Upvotes: 0
Views: 334
Reputation: 238
You are placing your nested ListView
inside a StackPanel
, which prevents it from calculating its size properly. Instead, your control renders to invisible area thus not showing a vertical scrollbar.
Consider changing your container panel to Grid
.
See also: WPF ListView no scrollbar if height set to auto
Upvotes: 1