WPF에서 일부 사용자 지정 바인딩을 구현하는 동안 네임 스페이스 문제가 있습니다. 내가 CLR-네임 스페이스 '네임 스페이스에 존재하지 않는'오류 '이름'CustomCommands을 얻고있다 :. GraphicsBook, 조립 = Testbed2D을 "WPF - 네임 스페이스에 이름이 없습니다.
을 내 XAML에서 나는이 :
<Window x:Class="GraphicsBook.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:k="clr-namespace:GraphicsBook;assembly=Testbed2D"
Title="Window1"
<Window.CommandBindings>
<CommandBinding Command="k:CustomCommands.AddCircle" CanExecute="AddCircleCommand_CanExecute" Executed="AddCircleCommand_Executed"></CommandBinding>
</Window.CommandBindings>
<Menu>
<MenuItem Header="Add">
<MenuItem Command="k:CustomCommands.AddCircle" />
</MenuItem>
</Menu>
그리고 내 CustomsCommand을. CS 파일은 프로젝트 폴더 안에이 파일은 내 :. 오류는 'MenuItem의 명령 = "K : CustomCommands.AddCircle"'라인에서 오는
namespace GraphicsBook
{
public partial class CustomCommandSample : Window
{
public CustomCommandSample()
{
...
}
private void AddCircleCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
}
public static class CustomCommands
{
public static readonly RoutedUICommand AddCircle = new RoutedUICommand
(
"AddCircle",
"AddCircle",
typeof(CustomCommands),
new InputGestureCollection()
{
new KeyGesture(Key.F4, ModifierKeys.Alt)
}
);
}
}
.
어떤 도움 것 많이 주시면 감사하겠습니다 !!
죄송합니다. 실제로 제거했지만 아직 작동하지 않습니다. :/ – petehallw
'CustomCommands'는 (는)'Testbed2D' 어셈블리에 선언되어 있습니까? –
예. Testbed2D 내의 .cs 파일입니다. – petehallw