Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

New Post: WPF button Command vs Content

$
0
0
<Button x:Name="CancelCommand" Content="Cancel" /> <<Convention will work

<Button Content="Cancel" Command="{Binding CancelCommand}" /> << but you lose some automagic abilities

Is all you will need, convention will take care of wiring up the "CancelCommand" in your viewmodel to the control thru binding that is built into CM. Effectively you have broken the mechanic which your "double" binding of the name to command... Essentially you don't need to set anything to Command at all with conventions that CM already takes care of with smoke and mirrors for you.

Aside from that also be thinking of guard properties if necessary probably not necessary in this case, but creating a bool property with "Can" as part of the prefix of the property tells CM hey we have something to check before we are allowing the button to be enabled...

e.g. CanCancelCommand , CanSubmit, etc.


hth

Morgan

Viewing all articles
Browse latest Browse all 1760

Trending Articles