C# 名称为;“格式化命令”;命名空间中不存在“0”;clr命名空间:命令“U 1”;
I xaml我收到了名称空间不存在的消息吗?我尝试了另一个新项目。但一切都没有改变 在中,我想实现下面类中的命令,这些命令位于同一程序集和同一项目中C# 名称为;“格式化命令”;命名空间中不存在“0”;clr命名空间:命令“U 1”;,c#,wpf,C#,Wpf,I xaml我收到了名称空间不存在的消息吗?我尝试了另一个新项目。但一切都没有改变 在中,我想实现下面类中的命令,这些命令位于同一程序集和同一项目中 <Window x:Class="Commands_1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/x
<Window x:Class="Commands_1.MainWindow"
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"
xmlns:local="clr-namespace:Commands_1"
mc:Ignorable="d"
Title="Commands_1" Height="350" Width="525">
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="Edit">
<MenuItem Command="Copy"></MenuItem>
<MenuItem Command="ApplicationCommands.Cut"></MenuItem>
<MenuItem Command="{x:Static ApplicationCommands.Paste}"></MenuItem>
<MenuItem Command="{x:Static local:FormatCommand.SetBackground}"/>
</MenuItem>
</Menu>
<RichTextBox>
<RichTextBox.CommandBindings>
</RichTextBox.CommandBindings>
</RichTextBox>
</DockPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Commands_1
{
public static class FormatCommand
{
public static RoutedUICommand setBackground = new RoutedUICommand
(
"Set the Background",
"SetBackground",
typeof(FormatCommand));
public static RoutedUICommand SetBackground { get { return SetBackground; } }
}
}