2

I have a Button with an attached Command:

<Button Command="{Binding Path=command}">
    <Button.CommandParameter>
        <s:String>1</s:String>
    </Button.CommandParameter>
</Button>

where the command is:

public ICommand command
{
    get { return new DelegateCommand<string>((string str) => MessageBox.Show(str)); }
}

So far everything works fine. When I press the button, the MessageBox with "1" message is shown.

But when I'm trying to pass a System.Int32 value as CommandParameter, no message is shown:

<Button Command="{Binding Path=command}">
    <Button.CommandParameter>
        <s:Int32>1</s:Int32>
    </Button.CommandParameter>
</Button>

public ICommand command
{
    get { return new DelegateCommand<System.Int32>((System.Int32 n) => MessageBox.Show(n.ToString())); 
}

What am I doing wrong?

undermind
  • 1,779
  • 13
  • 33
  • 1
    Put a break point and see if any error comes or not. Also check for output window in VS for any error. – Nikhil Agrawal Jul 09 '14 at 11:17
  • 3
    @NikhilAgrawal, thank you, Debug output window helped me. It appears that type T for DelegateCommand generic class must be nullable. So I should simply replace `Int32` with `Int32?` in the code behind. – undermind Jul 09 '14 at 11:32

0 Answers0