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>来进行参数传递

相关推荐
LateFrames19 小时前
我用 WPF 做了一个 “苍蝇飞舞” 的屏保
ui·wpf
wuty0071 天前
完善基于WPF开发的标尺控件(含实例代码)
wpf·wpf标尺·支持横向竖向标尺·ruler
浩浩测试一下2 天前
洪水猛兽攻击 Ddos Dos cc Drdos floods区别
安全·web安全·网络安全·系统安全·wpf·可信计算技术·安全架构
无心水2 天前
分布式环境下定时任务与SELECT FOR UPDATE的陷阱与解决方案
分布式·后端·wpf·xxl-job·quartz·定时任务·selectforupdate
xdpcxq10292 天前
Spring AOP + Guava RateLimiter 用注解实现优雅限流
spring·wpf·guava
Aevget2 天前
界面控件DevExpress WPF v25.2新版亮点:模板工具包全新升级
wpf·界面控件·devexpress·ui开发·.net 10
czhc11400756633 天前
wpf 129
wpf
码界奇点4 天前
基于eBPF技术的高性能网络防火墙系统设计与实现
开发语言·网络·毕业设计·php·wpf·go语言·源代码管理
cjp5604 天前
022.WPF 封装TextBox控件限制只输入数字自定义属性
wpf
cjp5604 天前
021.WPF 以MVVM模式控制combox控件显示/隐藏
wpf