Windows phone 8 Windows phone 8.1按钮单击事件不工作

Windows phone 8 Windows phone 8.1按钮单击事件不工作,windows-phone-8,buttonclick,Windows Phone 8,Buttonclick,单击来自的选项 不创建点击事件,我甚至尝试使用MouseLeftButton 但没有任何反应。我将附加我的“xaml”文件以查看是什么 错了。唯一的解决方案是放置对象 在启动屏幕代码之后,并在启动之后将可见性设置为true 屏幕结束。我在寻求更好的解决方案来放置我的对象 在和中,在单击事件时作出反应 <phone:PhoneApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xm

单击来自的选项 不创建点击事件,我甚至尝试使用MouseLeftButton 但没有任何反应。我将附加我的“xaml”文件以查看是什么 错了。唯一的解决方案是放置对象 在启动屏幕代码之后,并在启动之后将可见性设置为true 屏幕结束。我在寻求更好的解决方案来放置我的对象 在和中,在单击事件时作出反应

<phone:PhoneApplicationPage
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
xmlns:sysctrl="clr-namespace:System.Windows.Controls;assembly=Microsoft.Phone"
x:Class="SplashScreen.MainPage"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"
DataContext="{Binding Source={StaticResource Locator}, Path=Main}">

<i:Interaction.Behaviors>
    <ec:DataStateBehavior Binding="{Binding DataLoaded}" 
                          Value="False" 
                          TrueState="Loading"
                          FalseState="Loaded"/>
</i:Interaction.Behaviors>



<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="DataStates">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0:0:2" To="Loaded">
                    <VisualTransition.GeneratedEasingFunction>
                        <CubicEase EasingMode="EaseOut"/>
                    </VisualTransition.GeneratedEasingFunction>
                </VisualTransition>
            </VisualStateGroup.Transitions>
            <VisualState x:Name="Loading">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                   Storyboard.TargetName="ContentPanel">
                        <DiscreteObjectKeyFrame KeyTime="0">
                            <DiscreteObjectKeyFrame.Value>
                                <Visibility>Collapsed</Visibility>
                            </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
            <VisualState x:Name="Loaded">
                <Storyboard>
                    <DoubleAnimation Duration="0" 
                                     To="0" 
                                     Storyboard.TargetProperty="(UIElement.Opacity)" 
                                     Storyboard.TargetName="stackPanel" 
                                     d:IsOptimized="True"/>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" 
          Grid.Row="1" 
          Margin="12,0,12,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="67*"/>
            <ColumnDefinition Width="85*"/>
        </Grid.ColumnDefinitions>

        <phone:Pivot  Margin="0,10,0,-160" Grid.ColumnSpan="2" >

            <phone:PivotItem Header="Settings" >
                <StackPanel Grid.RowSpan="2"
                            >
                    <TextBox Name="PrintText"
                         Width="300"
                         Height="196" Margin="66,10,66,274"/>
                    <Button  Click="Button_Click"

                             IsHitTestVisible="True"
                             IsEnabled="True"
                        Width="100"
                        Height="100" RenderTransformOrigin="0.34,-2"
                        Margin="166,0"
                        >
                        <Image Source="upload.png" 
                            Stretch="Fill" 
                            Width="50"
                            Height="50"
                            />
                    </Button>
                </StackPanel>
            </phone:PivotItem>

            <phone:PivotItem Header="View Statistics">
            </phone:PivotItem>

            <phone:PivotItem Header="Notification">
            </phone:PivotItem>
        </phone:Pivot>

    </Grid>
    <StackPanel x:Name="stackPanel" Grid.RowSpan="2">
        <StackPanel.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="0"/>
                <GradientStop Color="#FFF3F3F3" Offset="0.552"/>
            </LinearGradientBrush>
        </StackPanel.Background>     
        <Image Source="screen_loader.png"
            Width="350"
            Height="350" Margin="65,120"/>
        <ProgressBar Height="10" Margin="0,20,0,0" IsIndeterminate="True"/>
    </StackPanel>
</Grid>

崩溃

这是一个有点XY问题。我认为您要做的是检测用户点击按钮时引发的点击事件。只需将其处理的事件更改为点击。

单击哪个属性的事件?感谢您的快速响应,我解决了它。问题是对象“stackPanel”位于主屏幕前面,因此我的方法无法处理触摸事件。解决方案是将GridPanel设置为Loaded=“ContentPanel\u GotFocus”属性,该属性在聚焦时触发。