WPF页面向后端传参

WPF页面(前端)向后端传参

1、编写一个Button,绑定后端命令,并传递参数:

csharp 复制代码
<Button
	Width="100"
	Command="{Binding SendCommand}"
	CommandParameter="{Binding ElementName=SendMessage, Path=Text}"
	 Content="Send" />

2、在ViewModel.cs中编写后端处理代码:

csharp 复制代码
public PortsViewModel()
{
	SendCommand = new DelegateCommand<string>(Test);
}
public DelegateCommand<string> SendCommand { get; set; }
public void Test()
{
	MessageBox.Show(BaudRate);
}

通过DelegateCommand<T>来进行参数传递

相关推荐
happyprince6 小时前
07_verl-Trainer模块详解
人工智能·架构·wpf·强化学习
bugcome_com10 小时前
WPF + Prism 技术指南与实战项目(二、模板搭建)
wpf
小满Autumn16 小时前
log4net 日志框架 — 从配置到实战速查手册
笔记·c#·.net·wpf·上位机·log4net
政沅同学1 天前
基于 C# WPF + HALCON 的工业视觉算法工具框架(开源)
开发语言·c#·wpf
happyprince1 天前
03_verl-设计理念与核心原理
wpf
happyprince1 天前
01_verl-项目概览与架构总览
架构·wpf
Chris _data1 天前
# WPF 学习记录( 第二天)
学习·wpf
myenjoy_12 天前
大规模采集架构——从单台网关到千点集群
架构·wpf
Chris _data2 天前
c#学习WPF笔记(一)
学习·c#·wpf
FuckPatience3 天前
WPF 自定义容器控件的布局
wpf