WPF頁面(前端)向后端傳參
1、編寫一個(gè)Button,綁定后端命令,并傳遞參數(shù):
<TextBox x:Name="SendMessage" />
<!-- 傳遞頁面中控件的Text -->
<Button
Width="100"
Command="{Binding SendCommand}"
CommandParameter="{Binding ElementName=SendMessage, Path=Text}"
Content="Send" />
2、在ViewModel.cs中編寫后端處理代碼:文章來源:http://www.zghlxwxcb.cn/news/detail-726211.html
public PortsViewModel()
{
SendCommand = new DelegateCommand<string>(Test);
}
public DelegateCommand<string> SendCommand { get; set; }
public void Test()
{
MessageBox.Show(BaudRate);
}
通過DelegateCommand<T>
來進(jìn)行參數(shù)傳遞文章來源地址http://www.zghlxwxcb.cn/news/detail-726211.html
到了這里,關(guān)于WPF頁面向后端傳參的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!