Page 1 of 1

PreviewTouchDown on parent doesn't allow child buttons to be clicked.

Posted: 04 Oct 2019, 18:29
by asusralis
I am panning and zooming the canvas. However, in this current setup I cannot click the buttons in the ItemsSource, but they are being highlighted when the mouse is over them. I'm assuming it has something to do with subscribing to the preview events, but I wasn't sure why.
<Grid Name="OuterParent" Background="Transparent">
                <Grid
                    Name="InnerParent"
                    RenderTransformOrigin="0.5, 0.5">
                    <Grid.RenderTransform>
                        <MatrixTransform />
                    </Grid.RenderTransform>
                    <ItemsControl>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                            	<Canvas/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button Width="100" Height="100" />
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Grid>
            </Grid>
            
            _outerParent.PreviewTouchDown += OnTouchDown;
            _outerParent.PreviewTouchUp += OnTouchUp;
            _outerParent.PreviewTouchMove += OnTouchMove;
            _outerParent.MouseWheel += OnMouseWheel;

Re: PreviewTouchDown on parent doesn't allow child buttons to be clicked.

Posted: 08 Oct 2019, 10:36
by sfernandez
Are you setting e.Handled = true on the PreviewTouchDown handler?
Because that will stop the routing of touch down event down the tree, making impossible to click the buttons.

I just verified that not setting e.Handled allows you to correctly click the inner buttons.