【问题标题】:Windows phone 8.1 button click event not workingWindows phone 8.1 按钮单击事件不起作用
【发布时间】:2014-06-26 08:20:28
【问题描述】:

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

<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>

【问题讨论】:

  • 哪个属性的点击事件?
  • 感谢您的快速响应,我解决了。问题是对象“stackPanel”在主屏幕的前面,所以我的

标签: windows-phone-8 buttonclick


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-18
    • 2014-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多