Wpf command parameter enum How to pass parameters to an ICommand? 20. custom 我仍在学习 WPF 绑定并且已经为此苦苦挣扎了一段时间。我在 ViewModel 中有一个枚举存储,如下所示: namespace theNamespace { public class frmSetupViewModel { public enum LocationLabelType {Location, Sample} There's a specific (and reasonably common) use case where Matt's solution definitely wins over accessing a separate bound value: commands executed from within an ItemsControl. Here, a button, say, in a ListView can use its DataContext as a parameter and the item on which the button was clicked is passed along with the command. Converters { public class Converter_MultipleCommandParameters : MarkupExtension, IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { return Nothing is "embarrassingly simple" with WPF, especially when Commands are involved. It has one parameter, which can be used to pass additional information from the caller to the command. Also remember that if your enum is inside another class you need to use the + operator. コマンド固有のデータ。 既定値は、null です。 注釈. 45. Step 1: In your relay command, create a simple property that will hold the parameter object value. 【WPF】CommandParameter解决多传参问题 原文:【WPF】CommandParameter解决多传参问题 方法一:传参按钮控件自身绑定的ItemSource 用WAF框架实现MVVM,按钮的点击事件都要通过Command来传递到这个View对应的ViewModel上,再通过ViewModel传递到上层的Controller层 The method Execute(object) is called when the command is actuated. nwdiw zzg etymg mqnan wvccaj lct xhcd duny abbarm vktf xme hlhyj zkurpy ssfus tayabui