Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight: How do I pass True to a CommandParameter?

How do I pass True to a CommandParameter?

Currently I am imperatively adding Boolean.True to the resource dictionary, but that seems like a clumsy way to do it.

like image 432
Jonathan Allen Avatar asked Nov 27 '22 18:11

Jonathan Allen


1 Answers

Because command parameters are of type 'object' the XAML parser is unable to perform type conversion for you. If you pass 'true', the parser has no way of knowing that you want this converted to a boolean value. You will have to do this explicitly. You could use the property element syntax:

<Button>
  <Button.CommandParameter>
    <sys:Boolean>true</sys:Boolean>
  </Button.CommandParameter>
</Button>

Where the sys namepsace is mapped:

xmlns:sys="clr-namespace:System;assembly=mscorlib"
like image 133
ColinE Avatar answered Dec 06 '22 10:12

ColinE