WPF中的错误:....不包含'CloseButton_Click'的定义,并且没有扩展方法'CloseButton_Click'接受类型'x.y'的第一个参数 [英] Error in WPF : ....does not contain a definition for 'CloseButton_Click' and no extension method 'CloseButton_Click' accepting a first argument of type 'x.y'

查看:274
本文介绍了WPF中的错误:....不包含'CloseButton_Click'的定义,并且没有扩展方法'CloseButton_Click'接受类型'x.y'的第一个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i给出了这个错误:

错误1'NezamMohandesi.WindowManager'不包含'CloseButton_Click'的定义,也没有扩展方法'CloseButton_Click '可以找到'NezamMohandesi.WindowManager'类型的第一个参数(你是否错过了使用指令或汇编引用?)D:\Project \ WPPNezamMohandesi \ NezamMohandesi \ NezamMohandesi \ WindowsStyles.xaml 45 108 NezamMohandesi 





我的资源代码:

 <  按钮    x:姓名  = 关闭   内容  = 按钮   宽度  =  27   保证金  =  2,2,0, 2   样式  =  {DynamicResource ButtonClose}   点击 < span class =code-keyword> =  CloseButton_Click    /  >  





< pre lang =c#> public class WindowsManager:ResourceDictionary
{
< span class =code-keyword> public WindowsManager()
{
// 在此点下方插入对象创建所需的代码。
}

public void CloseButton_Click( object sender,EventArgs e)
{
窗口窗口=((FrameworkElement)sender).TemplatedParent as Window;
if (window!= null
window.Close();

}
}





complet资料来源:

我的源文件

解决方案

错误说明了这一点:

'NezamMohandesi.WindowManager'不包含'CloseButton_Click'的定义



它提到 WindowManager ,但代码块中的类名为 WindowsManager (带有 s 在Window和Manager之间)。您必须将Windows类重命名为WindowManager,或确保您的XAML代码引用WindowsManager。


hi i give this error :

Error	1	'NezamMohandesi.WindowManager' does not contain a definition for 'CloseButton_Click' and no extension method 'CloseButton_Click' accepting a first argument of type 'NezamMohandesi.WindowManager' could be found (are you missing a using directive or an assembly reference?)	D:\Project\WPFNezamMohandesi\NezamMohandesi\NezamMohandesi\WindowsStyles.xaml	45	108	NezamMohandesi



my resource code:

<Button x:Name="Close" Content="Button" Width="27" Margin="2,2,0,2" Style="{DynamicResource ButtonClose}" Click="CloseButton_Click" />



public class WindowsManager : ResourceDictionary
   {
       public WindowsManager()
       {
           // Insert code required on object creation below this point.
       }

       public void CloseButton_Click(object sender, EventArgs e)
       {
           Window window = ((FrameworkElement)sender).TemplatedParent as Window;
           if (window != null)
               window.Close();

       }
   }



complet Source :
My Source File

解决方案

The error says this:

'NezamMohandesi.WindowManager' does not contain a definition for 'CloseButton_Click'


It mentions WindowManager, but the class in your code block is called WindowsManager (with an s between Window and Manager). You'll have to rename your class WindowsManager to WindowManager, or making sure that your XAML code refers to WindowsManager.


这篇关于WPF中的错误:....不包含'CloseButton_Click'的定义,并且没有扩展方法'CloseButton_Click'接受类型'x.y'的第一个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆