KeyTrigger does not work
Posted: 14 Nov 2020, 05:11
Hi, I am trying to use a command when a key is pressed. But the KeyTrigger does not work. I saw some samples and other posts but nothing. I am very new to Noesis so I don't know why it doesn't work.
Here is the xaml code
Those are the components that I included. Prehaps I forgot include another.
Here is the xaml code
Code: Select all
<UserControl
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"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
xmlns:local="clr-namespace:GameGUI"
x:Class="GameGUI.Loading"
x:Name="LoadingControl" Focusable="True" IsTabStop="False">
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding State}" Comparison="NotEqual" Value="{x:Static local:State.Loading}">
<ei:ChangePropertyAction PropertyName="Visibility" Value="Hidden" />
</ei:DataTrigger>
<ei:DataTrigger Binding="{Binding State}" Comparison="Equal" Value="{x:Static local:State.Loading}">
<ei:ChangePropertyAction PropertyName="Visibility" Value="Visible" />
</ei:DataTrigger>
<ei:KeyTrigger Key="Esc" ActiveOnFocus="False">
<i:InvokeCommandAction Command="{Binding Game}"/>
</ei:KeyTrigger>
</i:Interaction.Triggers>
<Grid x:Name="LayoutRoot">
<Viewbox>
<StackPanel Margin="30">
<TextBlock Foreground="White" Text="Loading..."/>
<TextBlock Foreground="White" Text="Press Esc key to start"/>
</StackPanel>
</Viewbox>
</Grid>
</UserControl>
Code: Select all
Noesis::TypeOf<NoesisApp::Interaction>();
Noesis::RegisterComponent<NoesisApp::DataTrigger>();
Noesis::RegisterComponent<NoesisApp::TriggerCollection>();
Noesis::RegisterComponent<NoesisApp::KeyTrigger>();
Noesis::RegisterComponent<NoesisApp::InvokeCommandAction>();
Noesis::RegisterComponent<NoesisApp::ChangePropertyAction>();
Noesis::RegisterComponent<NoesisApp::EventTrigger>();
Noesis::RegisterComponent<NoesisApp::PropertyChangedTrigger>();
Noesis::RegisterComponent<NoesisApp::TriggerActionCollection>();
Noesis::RegisterComponent<NoesisApp::SetFocusAction>();
Noesis::RegisterComponent<Noesis::EnumConverter<NoesisApp::ComparisonConditionType>>();
Noesis::RegisterComponent<Noesis::EnumConverter<NoesisApp::KeyTriggerFiredOn>>();
