locked
What could be causing a button in XAML to not be clickable?

    Question

  • I have a button that works in other places within the page. If I add it to a particular grid though, it gets displayed but it's not clickable. Here's my full markup for that:

    <Grid Style="{StaticResource NogMasterPageGridStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
    
        <!-- Page title -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="300"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="15"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="20"/>
            </Grid.RowDefinitions>
            // THIS BUTTON SHOULD BE CLICKABLE, AND IS ELSEWHERE
            <Button IsHitTestVisible="True" Grid.Column="0" Grid.Row="1" Canvas.ZIndex="9999" Content="Go Back" Style="{StaticResource NogButton}" 
                                Click="Click_GoBack"/>
            <StackPanel Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Orientation="Vertical" Margin="40,0,0,0">
                <Image Style="{StaticResource NogLogoImage}" VerticalAlignment="Center"></Image>
                <TextBlock Text="NOG"  Style="{StaticResource NogPageTitle}"  
                        IsHitTestVisible="false" TextWrapping="NoWrap" Margin="2,-35,0,0" HorizontalAlignment="Center"/>
            </StackPanel>
        </Grid>

    What could be causing the button to not be clickable in this particular grid?

    Wednesday, May 28, 2014 4:22 PM

All replies

  • De stackpanel is laying over it. place it below the stackpanel in the xaml and will be clickable again

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, May 28, 2014 7:08 PM
  • Hey Dave,

    I just also thought this, but the StackPanel is in Grid.Column="1". :-)

    @deliveryguy: What's in the Style of the Root-Grid (NogMasterPageGridStyle)?

    I think that set's some things like e.g. IsHitTestVisible.


    Thomas Claudius Huber

    "If you can't make your app run faster, make it at least look & feel extremly fast"

    My latest app: The "Womanizer" :-)
    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook

    Wednesday, May 28, 2014 9:25 PM
  • Also the other styles. Are there any other controls on this page which could be placed over the button? If the remainder of the page is accidentally in Grid.Row="0" rather than Grid.Row="1" then that could block input. Can you click to set the focus on TextBox NOG?

    If I remove the styles so I can run this code it works as expected: clicking the button triggers its Click event.

    Can you upload a minimal sample which demonstrates the problem to your OneDrive? That would let us see the repro in context.

    --Rob

    Wednesday, May 28, 2014 9:49 PM
    Owner