Ctrl-Wheel Zoom on ListBoxItem


I have a ListBox like object in my diagram:

                            <local:InertListBox Margin="5,0,0,0" BorderThickness="0" VerticalAlignment="Top" ItemsSource="{Binding Path=Data.Items}" ItemTemplate="{StaticResource AttributeItem}"/>

The attribute item template is defined this way:

    <DataTemplate x:Key="AttributeItem" >
        <StackPanel Orientation="Horizontal" >
         <span style="font-size: 12px; line-height: 1.4;">    <TextBlock Margin="10,0,0,0" HorizontalAlignment="Left" Text="{Binding Path=Name, Mode=TwoWay}" go:Part.TextEditable="True"/></span>
            <TextBlock HorizontalAlignment="Left" Text=" : " />
            <TextBlock HorizontalAlignment="Left" Text="{Binding Path=Type, Mode=TwoWay}"  go:Part.TextEditable="True"/>

InertListBox inherits from ListBox, and is its implementation is exactly the same as in the DynamicPorts Demo example. This allows me to edit the TextBlock within the ListBox items.

public class InertListBox : ListBox
protected override DependencyObject GetContainerForItemOverride()
return new InertListBoxItem();

public class InertListBoxItem : ListBoxItem
    protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        e.Handled = false;

My problem is that I when I Zoom in or out of my diagram using the Ctrl-MouseWheel combination, I cannot do so while the Mouse pointer is over a InertListBoxItem (in fact this is common to the ListBoxItem implementation). The zooming behaviour works once again as soon as I move the pointer out of the ListBoxItem.

I just tried changing the ItemTemplate in the DynamicPorts sample to be a Horizontal StackPanel and adding a TextBlock to be next to the existing Rectangle. Control-mouse-wheel events resulted in zooming the diagram over either of the objects in the ListBoxItems.

Then it occurred to me that maybe you weren’t talking about WPF, so I tried the same thing in Silverlight. But it worked there too, just as expected.

So I am unable to reproduce the problem that you describe.

The problem that you are talking about does exist, but since the Dynamic Ports sample replaces the ControlTemplate of ListBox, there is no ScrollViewer to intercept mouse-wheel events. So the DiagramPanel does get the mouse-events so that the tools can perform the usual mouse-wheel behaviors.

I’m sorry I forgot to mention I was indeed talking about WPF.

I added an ItemPresenter ControlTemplate to the ListBox style, as done in the DynamicPorts example and this fixed the problem. I simply did not consider that a ListBox had a ScrollViewer controller by default.

For your information, I based myself off the ER diagram demo, and replaced the ListView within the node templates with a ListBox. In the ER demo, the mouse wheel zoom in/out does not work either, when hovering the mouse over a ListView.

Thank you :).