【发布时间】:2015-10-23 14:59:55
【问题描述】:
我是 C# 和一般编程新手。
我创建了一个简单的 plc 程序(步骤 7),在 PLSIM 模拟器上进行模拟。
我想使用Siemens S7ProSim COM Object 参考在 C# 中使用 WPF 接口来控制这个程序。
问题来了: 当我想将 CPU 状态分配给我的标签时,会显示此消息:
错误 1“System.Windows.Controls.Label”不包含“Text”的定义,并且找不到接受“System.Windows.Controls.Label”类型的第一个参数的扩展方法“Text”(是您缺少 using 指令或程序集引用?) C:\Users\Lenovo\Documents\Visual Studio 2010\Projects\CSProject\CSProject\MainWindow.xaml.cs 32 28 CSProject 这是我的程序和我的 wpf 界面:
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;
namespace CSProject
{
public partial class MainWindow : Window
{
public S7PROSIMLib.S7ProSim ps = new S7PROSIMLib.S7ProSim();
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
ps.Connect();
label_CPUState.Text = ps.GetState();
labelScanMode.Text = ps.GetScanMode().ToString();
}
}
}
非常感谢。
【问题讨论】: