在我的 WPF 应用程序中,用户可以通过右键单击来选择命令。现在,我创建了一个按钮,并希望将此方法与该按钮相关联。
到目前为止我做了什么:
在 XAML 文件中,我有:
<Button Content="Run Compare" Command="{x:Static RunCompare_Exectued}"></Button>
然后在 ResourceDirectory 部分中,我试图引用我的文件,其中包含该方法为
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:myMethods="**Nothing Comes up here!!!**"
>
通常我会按住Ctrl 并点击空格键,但没有显示任何内容,然后我尝试输入 clr-namespace:FileNameConatiningMethod ...但我收到错误消息:
未定义的 CLR 命名空间。“clr-namespace” URI 指的是程序集中未包含的命名空间“Application.Commands”。
任何帮助将不胜感激。
谢谢。
编辑:
我可以访问具有方法 A 和 B 的文件之一,但是,我无权访问不同源文件中的方法 C 和 D。通过在 XAML 文件的根标记中添加命名空间不应该可以吗?
假设我的命名空间是 ABC,所以我有:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:ABC">