nmaillet 97 Posting Whiz in Training

I'm trying to create some custom styles/control templates for WPF. The only control that seems to be giving be any issues (so far) is the ScrollViewer:

    <Style x:Key="{x:Type ScrollViewer}" TargetType="ScrollViewer">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border Background="#404040">
                        <Border BorderBrush="#808080" BorderThickness="1" Margin="4">
                            <Grid >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <ScrollContentPresenter Name="PART_ScrollContentPresenter"/>
                                <ScrollBar Grid.Column="1"
                                   Name="PART_VerticalScrollBar"
                                   Orientation="Vertical"
                                   Value="{TemplateBinding VerticalOffset}"
                                   Maximum="{TemplateBinding ScrollableHeight}"
                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                                <ScrollBar Grid.Row="1"
                                   Name="PART_HorizontalScrollBar"
                                   Orientation="Horizontal"
                                   Value="{TemplateBinding HorizontalOffset}"
                                   Maximum="{TemplateBinding ScrollableWidth}"
                                   ViewportSize="{TemplateBinding ViewportWidth}"
                                   Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                            </Grid>
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

When I add a ListBox, and ~70 items (just ListBoxItems with string Content) it gives me some wierd scrolling issues. When I click and hold it scrolls down as it should. When I click and hold (while scrolled towards the bottom) and move the cursor up, the list jumps up and after moving a few pixels reaches the top of the list.

I commented every other style I was using and it still gives me the same result. When I disable the ScrollViewer style, everything works fine. I even tried copying the example custom style from the MSDN library here. It has the same issue. I thought it might be a property that gets set by the default style, so I removed the OverridesDefaultStyle setter, and no luck. It was being used as a merged resource dictionary from another project, so I moved it to the windows resource collection. I think I'm out of ideas now...

Does anybody have any ideas, or experienced this before? Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.