wpf listview itempanel scrollviewer

430 views Asked by At

When I set ListView.ItemsPanel in WrapPanel then right scrollbar is lost (not visible). And the content is scrolled by a mouse wheel and of course with the study of the visual tree in this scrollviewer all properties is installed correctly. What could be wrong here and why he is not visible.

        <Style TargetType="{x:Type ListView}">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <WrapPanel Background="Transparent" MouseDown="WrapPanel_MouseDown_1" 
                             IsItemsHost="True"
                             Width="{Binding Path=ActualWidth,  RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollContentPresenter}}}">

                        </WrapPanel>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Path Fill="{Binding ElementName=tBlock, Path=Foreground}" Width="20" Height="20" Margin="5, 0, 0, 0" Stretch="Uniform" Data="{Binding SmallIcon}" />
                            <TextBlock Margin="5, 4, 5, 0" x:Name="tBlock" Grid.Column="1" TextWrapping="Wrap" Width="200" Text="{Binding Name}"></TextBlock>
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

This is the screenshot:

Screenshot

1

There are 1 answers

0
rmojab63 On

set VerticalScrollBarVisibility and/or HorizontalScrollBarVisibility to the desired value:

<ListView
          ScrollViewer.HorizontalScrollBarVisibility="Visible" 
          ScrollViewer.VerticalScrollBarVisibility="Visible"> 
    <ListView.Style>
        <Style TargetType="{x:Type ListView}">
         // ...

VerticalScrollBarVisibility is Auto by default and I could not replicate your problem. However, I hope this helps.