3

I am trying to implement an ItemsControl which contains a collection of graphing components. The component should be able to use the MouseWheel event to zoom, but it appears that the Scrollbar is capturing and handling the event first. Most of the articles I have found here and here speak to letting parents handle the wheel, but I need the child to handle the wheel, and I can't figure out the right hooks. Here is my TiledGrid, which is an ItemsControl at its core:

<ItemsControl x:Class="Grapes.Common.Controls.TiledGrid.TiledGrid"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:local="clr-namespace:Grapes.Common.Controls.TiledGrid"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300" x:Name="itemsGrid" 
              ScrollViewer.CanContentScroll="True" >
        <!--ItemTemplate="{Binding ItemTemplate}"-->
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Border BorderBrush="Black" BorderThickness="1"
                        Padding="3" Margin="3" >
                    <HeaderedContentControl
                        HeaderTemplate="{Binding HeaderTemplate,ElementName=itemsGrid}" Header="{Binding}"
                        ContentTemplate="{Binding ItemTemplate,ElementName=itemsGrid}" Content="{Binding}"
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                       >
                        <HeaderedContentControl.Template>
                            <ControlTemplate TargetType="HeaderedContentControl">
                                <DockPanel>
                                    <ContentPresenter DockPanel.Dock="Top" ContentSource="Header" />
                                    <ContentPresenter />
                                </DockPanel>
                            </ControlTemplate>
                        </HeaderedContentControl.Template>
                    </HeaderedContentControl>
                </Border>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
        <local:UniformGridPanel Rows="{Binding RowCount,ElementName=itemsGrid}" 
                                Columns="{Binding ColumnCount,ElementName=itemsGrid}" 
                              >

        </local:UniformGridPanel>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.Template>
            <ControlTemplate>
                <Border
        BorderThickness="{TemplateBinding Border.BorderThickness}"
        Padding="{TemplateBinding Control.Padding}"
        BorderBrush="{TemplateBinding Border.BorderBrush}"
        Background="{TemplateBinding Panel.Background}"
        SnapsToDevicePixels="True">
                    <ScrollViewer
                Padding="{TemplateBinding Control.Padding}"
                Focusable="False" FlowDirection="RightToLeft" CanContentScroll="True" SnapsToDevicePixels="True"
                        >

                <ItemsPresenter FlowDirection="LeftToRight">

                </ItemsPresenter>
                    </ScrollViewer>
                </Border>
            </ControlTemplate>
        </ItemsControl.Template>
    </ItemsControl>

What can I do to stop the ScrollViewer in the ItemsControl.Template from handling the MouseWheel event?

Thanks in Advance!

Mike.

Community
  • 1
  • 1
mdusoe
  • 41
  • 5

0 Answers0