我有一个使用C#和WPF编写的应用程序,它是在Prism 6框架之上构建的。
我正在尝试使用XAML创建一个按钮,当点击时,我想要将一个固定的小数值传递给我的视图模型。
<Button Content="5"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Command="{Binding ProcessAmount}"
CommandParameter="5.00000"
FontSize="24"
Height="75"
Width="85" />
在我的视图模型中,我有以下内容:
public class ViewModel : BindableBase
{
public DelegateCommand<decimal?> ProcessAmount { get; set; }
public ViewModel()
{
ProcessAmount = new DelegateCommand<decimal?>(HandleProcessAmount, CanProcessAmount);
}
private bool CanProcessAmount(decimal? amount)
{
return amount.HasValue && amount.Value != 0;
}
private void HandleProcessAmount(decimal? amount)
{
// do something with the amount
}
}
但是当我编译应用程序时,在XAML视图中出现错误指定的转换无效。
我该如何从视图中发送一个固定的十进制值?
x:Int32
。 - Shimmy Weitzhandler