c#中的程序报错

supercast 2011-07-25 09:28:39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace mYproject
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
label1.Text = "Hello,World!";
}

private void button2_Click(object sender, RoutedEventArgs e)
{

}
}
}

错误 1 “System.Windows.Controls.Label”不包含“Text”的定义,并且找不到可接受类型为“System.Windows.Controls.Label”的第一个参数的扩展方法“Text”(是否缺少 using 指令或程序集引用?) D:\projects\mYproject\mYproject\Window1.xaml.cs 30 20 mYproject
...全文
122 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
supercast 2011-07-26
  • 打赏
  • 举报
回复
谢谢大家,我是照《c#从入门到精通》敲的,还以为是自己设置出问题了
结帖了
aXen 2011-07-25
  • 打赏
  • 举报
回复

private void button1_Click(object sender, RoutedEventArgs e)
{
this.label1.Content = "Hello World!";
}
心灵彩虹 2011-07-25
  • 打赏
  • 举报
回复
是的前几天写wpf代码,发现改了,
机器人 2011-07-25
  • 打赏
  • 举报
回复
wpf 的属性改了。

不是 label1.Text = "Hello,World!";

改为 label1.Content = "Hello,World!";

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧