I noticed that KeyTrigger
does not fire when used inside a Popup
control.
<UserControl x:Class="SilverlightBindingTest.iTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ii="clr-namespace:Microsoft.Expression.Interactivity.Input;assembly=Microsoft.Expression.Interactions"
xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions">
<Grid x:Name="LayoutRoot" Background="White">
<Popup IsOpen="True">
<i:Interaction.Triggers>
<ii:KeyTrigger Key="Enter">
<ei:ChangePropertyAction TargetName="alert" PropertyName="Visibility" Value="Visible" />
</ii:KeyTrigger>
</i:Interaction.Triggers>
<StackPanel>
<TextBox />
<TextBlock Text="hi" x:Name="alert" Visibility="Collapsed"/>
</StackPanel>
</Popup>
</Grid>
</UserControl>
When you remove the Popup part, this works as expected ("hi" appears when you press Enter).
What's going on here? I can't think of a reason why KeyTrigger should be failing.