0

I have the following ListView layout:

                <ScrollViewer HorizontalScrollBarVisibility="Visible">
                    <ListView Height="Auto" Name="lstvItems" Width="Auto" Background="#FF354D55" SelectionMode="Single" >
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Name:" DisplayMemberBinding="{Binding Name}" Width="100" />
                                <GridViewColumn Header="Type:" DisplayMemberBinding="{Binding Type}" Width="70" />
                            </GridView>
                        </ListView.View>
                    </ListView>
                </ScrollViewer>

If I add a border to the ListView and the scrollbars are available, the borders scroll along with the content.

How do I stop this from happening?

1 Answer 1

1

Remove the ScrollViewer.

The Default ListView Template already has a ScrollViewer.

Obtained from Expression Blend:

<ControlTemplate TargetType="{x:Type ListView}">
    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="1" SnapsToDevicePixels="true">
        <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        </ScrollViewer>
    </Border>
    <!-- more content here -->
</ControlTemplate>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.