Scott Nimrod
Scott Nimrod

Reputation: 11595

Button not consistently recognizing tapped event

I have a couple of buttons on a canvas. One button consistently recognizes tapped events while the other does not.

If I enlarge the button to a gross size and then tap it, then the "Tapped" event is captured.

The code is below:

        <Canvas>
            <Image Source="Assets/us_map_portrait.png" />
            <Button Canvas.Left="320" Canvas.Top="214" Tapped="Button_Tapped" Tag="FL">
                <Button.Template>
                    <ControlTemplate>
                        <Ellipse Height="50" Width="25" Fill="Transparent" RenderTransformOrigin="0.5,0.5" >
                            <Ellipse.RenderTransform>
                                <CompositeTransform Rotation="-29.541"/>
                            </Ellipse.RenderTransform>
                        </Ellipse>
                    </ControlTemplate>
                </Button.Template>
            </Button>

            <Button Canvas.Left="292" Canvas.Top="86" Tapped="Button_Tapped" Tag="OH" >
                <Button.Template>
                    <ControlTemplate>
                        <Ellipse  Height="35" Width="35" Fill="Red" RenderTransformOrigin="0.5,0.5" >
                            <Ellipse.RenderTransform>
                                <CompositeTransform Rotation="-14.684"/>
                            </Ellipse.RenderTransform>
                        </Ellipse>
                    </ControlTemplate>
                </Button.Template>
            </Button>

        </Canvas>

Upvotes: 0

Views: 53

Answers (1)

Scott Nimrod
Scott Nimrod

Reputation: 11595

I had the canvas contained within a list view. When I removed the list view, the issue got resolved.

Translated, the list view may have been swallowing the event.

Upvotes: 1

Related Questions