这是我在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/