I have an app written using c# and WPF on the top of Prism 6 framework.
I am trying to create a button using XAMl, when clicked, I want to be pass a fixed decimal value to my view-model.
<Button Content="5"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Command="{Binding ProcessAmount}"
CommandParameter="5.00000"
FontSize="24"
Height="75"
Width="85" />
In my view-model I have the following
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
}
}
But when I compile the app, I get an error in the XAML view Specified cast is not valid.
How can I send a fixed decimal value from the view?