110,538
社区成员
发帖
与我相关
我的任务
分享
public struct CustemData
{
int 上料伺服首层位置;
int 加速度;
int 速度;
int 层间距;
int 当前层;
int 总层数;
int 点动距离;
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 WpfApplication
{
public class OrderInfo
{
public string temp { get; set; }
public string temp1 { get; set; }
}
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public ObjectDataProvider myObject
{
get
{
return TryFindResource("GoodsDetail") as ObjectDataProvider;//找到前端设置的资源文件
}
}
public MainWindow()
{
InitializeComponent();
OrderInfo obj = new OrderInfo()
{
temp = "11da",
temp1 = "admin"
};
setData(obj);
}
public void setData(OrderInfo obj)
{
myObject.ObjectInstance = obj;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
OrderInfo obj = myObject.ObjectInstance as OrderInfo;
MessageBox.Show(string.Format("temp:{0},temp1:{1}", obj.temp, obj.temp1));
}
}
}
<Window x:Class="WpfApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary>
<ObjectDataProvider x:Key="GoodsDetail"/>
</ResourceDictionary>
</Window.Resources>
<StackPanel>
<TextBox Margin="10" Text="{Binding Source={StaticResource GoodsDetail},Path=temp}" Width="80"/>
<TextBox Margin="10" Text="{Binding Source={StaticResource GoodsDetail},Path=temp1}" Width="80"/>
<Button Content="提交信息" Margin="10" Click="Button_Click"/>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassDataChange
{
public struct CustemData
{
public int Data;
public string Property;
}
class DataChange
{
public static string addr; //PLC的IP地址
public static int port; //PLC的端口号
public static int UserNo; //用户模式,1代表工程师
public static CustemData[] AAA = new CustemData[50];
public static void xx()
{
AAA[0].Property = "D1106"; //上料伺服首层位置
AAA[1].Property = "D1100"; //加速度
AAA[2].Property = "D1101"; //速度
AAA[3].Property = "D103"; //层间距
AAA[4].Property = "D104"; //当前层
AAA[5].Property = "D105"; //总层数
AAA[6].Property = "D106"; //点动距离
}
}
}