Hi,
i have problem in user control shortcut key..in my project i have expander if i click expander button i will show user control in ContentControl.. i have 2 button in user control and i set shortcut keys but it not working...in wpf window form it work...and my coding .....but i got 2 error as..
Error 1 Unknown build error, 'Key cannot be null.
Parameter name: key Line 195 Position 49.'
Error 2 The type or namespace name 'MyCommand' could not be found (are you missing a using directive or an assembly reference?)
<UserControl x:Class="WpfApplication2.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
xmlns:local="clr-namespace:WpfApplication2">
<Grid>
<Button Content="Test Command" Command="{x:Static local:UserControl1.TestCommand}"/>
</Grid>
</UserControl>
UserControl C#:
publicpartialclassUserControl1 :UserControl
{
publicstaticICommand _testCommand =newMyCommand();
public UserControl1()
{
InitializeComponent();
}
publicstaticICommand TestCommand
{
get {return _testCommand; }
}
}
KeyBinding:
<Window.InputBindings>
<KeyBinding Key="K" Modifiers="Control" Command="{x:Static local:UserControl1.TestCommand}"/>
</Window.InputBindings>