gpt4 book ai didi

wpf - 将DropDown值传递给WPF MVVM中的RelayCommand

转载 作者:行者123 更新时间:2023-12-03 10:55:05 24 4
gpt4 key购买 nike

这是我在XAML中的代码。

<telerik:RadComboBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" ></telerik:RadComboBox>

<telerik:RadButton Name="BtnExportToPdf" Content="Export To PDF" Command="{Binding ExportToPDFClickCommand}"></telerik:RadButton>

下面是我在ViewModel中的RelayCommand
public ICommand ExportToPdfClickCommand
{
get
{
return new RelayCommand(ExportReportData);
}
}

我想将下拉值传递给中继命令。我怎样才能做到这一点 ?

最佳答案

为什么需要将所选项目传递给命令?
您的 View 模型已经具有该值:

SelectedItem =“{Binding SelectedItem}”

结果,只需在 View 模型中引用SelectedItem属性即可。

关于wpf - 将DropDown值传递给WPF MVVM中的RelayCommand,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26849582/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com