ZoomContentControl 'Consumes' MouseClicks

Navigation for WPF Forum

Posted 4 years ago by Justin Klein
Version: 17.2.0662
Avatar

Given the following sample code, clicking any of the items in the ListBox does not activate/update the SelectedItem, unless I click on that entry *outside* of the ZoomContentControl, or *double*-click on the ZoomContentControl:

        <ListBox ItemsSource="{Binding SurveyChannelObjects}" SelectedItem="{Binding SelectedChannelObject, Mode=TwoWay}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <navigation:ZoomContentControl IsViewControlPaneVisible="False" IsVirtualSpaceEnabled="False" IsPanPadVisible="False">
                            <TextBlock MaxWidth="100" TextWrapping="Wrap">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</TextBlock>
                        </navigation:ZoomContentControl>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

If I comment out only the ZoomContentControl (so that each entry is just a StackPanel & TextBlock), then SelectedItem again works property.

It seems as though the ZoomContentControl is 'Consuming' the MouseClicks, so that they aren't seen by the ListBox, and thus selections are non-functional.  Is there a way to rectify this?

Thanks in advance

Comments (4)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Justin,

I think what's happening is that there are elements with backgrounds in between the click and ListBoxItem, and those would intercept the click.  If you set the ZoomContentControl.Background to "{x:Null}", does that make any difference?  That would be part of it, but there are also some other controls sandwiched in between like ZoomContentControlScrollViewer and ZoomContentControlItemsControl (via the ZoomContentControl's Template) that may also have Backgrounds that are blocking click-throughs.  You might have to also walk the visual tree and remove backgrounds on those by setting them to null.


Actipro Software Support

Posted 4 years ago by Justin Klein
Avatar

Nope, Background="{x:Null}" on the ZoomContentControl doesn't change the issue.

Not sure how to "walk the visual tree and remove backgrounds" - could you provide some more specifics on how to fix (ZoomContentControl's impact on clickability of its contents)?

Thanks again

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Justin,

ZoomContentControl isn't impacting the clickability of its contents at all here.  Anything inside the ZoomContentControl should be fully clickable. 

In your scenario, you are trying to click through the ZoomContentControl to its own containing control (the ListBoxItem).  However that mouse down event gets caught by something between the clicked element and the ZoomContentControl.

The same thing is illustrated with native WPF controls like this where Button and ScrollViewer handles left clicks and don't allow the event to bubble up so that ListBoxItem sees it:

<ListBox>
	<ListBoxItem>
		<TextBlock Text="Plain TextBlock" />
	</ListBoxItem>
	<ListBoxItem>
		<Button>
			<TextBlock Text="TextBlock in Button" />
		</Button>
	</ListBoxItem>
	<ListBoxItem>
		<ScrollViewer>
			<TextBlock Text="TextBlock in ScrollViewer" />
		</ScrollViewer>
	</ListBoxItem>
</ListBox>

Normally a ScrollViewer would block the mouse down event from bubbling up but it looks like our ZoomContentControlScrollViewer overrides it to not do that, so that the mouse down events bubble up to the ZoomContentControl.  That's good news.  After debugging, we found that it's the ZoomContentControl's InputBindings catching the mouse down event.

If you set AreDefaultInputBindingsEnabled="False" on the ZoomContentControl then the mouse down event should bubble up, but you will lose normal drag and pan functionality, etc.


Actipro Software Support

Posted 4 years ago by Justin Klein
Avatar

Great!  That's actually a fine solution in this case, & works just as I'd expect.  Thanks :D

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.