asusralis
Topic Author
Posts: 60
Joined: 30 Jul 2018, 05:03

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

04 Oct 2019, 18:29

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;
 
User avatar
sfernandez
Site Admin
Posts: 1785
Joined: 22 Dec 2011, 19:20

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

08 Oct 2019, 10:36

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.

Who is online

Users browsing this forum: No registered users and 5 guests