WP8中不会触发Button Click事件

时间:2014-05-30 20:39:47

标签: xaml windows-phone-8 windows-phone

我有这样的布局。

<Grid Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Name="gridTestAd" Height="80" Margin="-12,0,-12,0" >
                    <StackPanel Orientation="Vertical" Tap="StackPanel_Tap">
                        <StackPanel.Background>
                            <ImageBrush ImageSource="/Assets/image.jpg" />
                        </StackPanel.Background>
                    </StackPanel>
                    <adduplex:AdControl x:Name="adDuplexAd" AppId="123456"/>
                    <Button Name="btnRemoveAd" Content="X" Height="40" Width="40" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Red" BorderBrush="Red" Foreground="White" Template="{StaticResource RemoveAdsButtonStyle}" Margin="0,-20,6,0" Click="btnRemoveAd_Click" />
</Grid>

我在btnRemoveAd_Click事件中设置了一个断点,但是当我点击按钮时,点击事件不会触发。最初我使用图像创建了一个自定义按钮,但也没有用。使用Blend稍微编辑此按钮,因为它太小而且内容没有显示。但只更改原始按钮的边距。我找了原因,但没有找到任何原因,我也无法想象。可能是什么问题?请帮忙

按钮的控制模板

 <ControlTemplate x:Key="RemoveAdsButtonStyle" TargetType="Button">
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Normal" GeneratedDuration="0:0:0.25" To="Pressed">
                            <VisualTransition.GeneratedEasingFunction>
                                <CircleEase EasingMode="EaseIn"/>
                            </VisualTransition.GeneratedEasingFunction>
                        </VisualTransition>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver"/>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle1" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled"/>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Rectangle x:Name="rectangle1" StrokeThickness="0">
                <Rectangle.Fill>
                    <ImageBrush Stretch="Fill" ImageSource="/Assets/img/close_small.png"/>
                </Rectangle.Fill>
            </Rectangle>
            <Rectangle x:Name="rectangle" StrokeThickness="0" Opacity="0">
                <Rectangle.Fill>
                    <ImageBrush Stretch="Fill" ImageSource="/Assets/img/close_small_presses.png"/>
                </Rectangle.Fill>
            </Rectangle>
        </Grid>
    </ControlTemplate>

0 个答案:

没有答案
相关问题