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