EventTriggerBehavior对AppBarButton不起作用

时间:2015-07-09 14:29:37

标签: windows-phone-8.1 eventtrigger appbar

我在Blend中使用EventTriggerBehavior,当我使用ElementName绑定时,它在Windows Phone 8.1的测试应用程序中不适用于AppBarButton。 Button的相同EventTriggerBehavior工作正常。

 <Grid x:Name="grid">       
    <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="150,234,0,0" VerticalAlignment="Top">
    <i:Interaction.Behaviors>                   
        <core:EventTriggerBehavior EventName="Click">
            <core:ChangePropertyAction TargetObject="{Binding ElementName=okButton}" PropertyName="Visibility">
                <core:ChangePropertyAction.Value>
                    <Visibility>Collapsed</Visibility>
                </core:ChangePropertyAction.Value>
            </core:ChangePropertyAction>
        </core:EventTriggerBehavior>                    
    </i:Interaction.Behaviors>
</Button>
</Grid>
<Page.BottomAppBar>
    <CommandBar>
        <AppBarButton x:Name="okButton"  Icon="Accept" Label="appbarbutton">                                        
        </AppBarButton>       
        <AppBarButton x:Name="cancelButton" Icon="Cancel" Label="appbarbutton"/>
    </CommandBar>
</Page.BottomAppBar>

此行为正常。 okButton崩溃了: http://i.stack.imgur.com/kNIWt.png

 <Grid x:Name="grid">       
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="150,234,0,0" VerticalAlignment="Top">       
</Button>
</Grid>
<Page.BottomAppBar>
    <CommandBar>
        <AppBarButton x:Name="okButton"  Icon="Accept" Label="appbarbutton">                                        
            <i:Interaction.Behaviors>                   
                <core:EventTriggerBehavior EventName="Click">
                    <core:ChangePropertyAction TargetObject="{Binding ElementName=button}" PropertyName="Visibility">
                        <core:ChangePropertyAction.Value>
                            <Visibility>Collapsed</Visibility>
                        </core:ChangePropertyAction.Value>
                    </core:ChangePropertyAction>
                </core:EventTriggerBehavior>                    
            </i:Interaction.Behaviors>
        </AppBarButton>       
        <AppBarButton x:Name="cancelButton" Icon="Cancel" Label="appbarbutton"/>
    </CommandBar>
</Page.BottomAppBar>

按钮仍然可见。行为不起作用。 http://i.stack.imgur.com/LVQC7.png

0 个答案:

没有答案