This project is read-only.

Binding to methods

There is no difference in binding. For methods you need to bind to an ICommand Interface and since the DynamicViewModel can invoke methods on the model (with or withour args) you can use CommandBindings.

Adding CommandBindings from XAML:
 <StackPanel.CommandBindings>
     <CommandBinding
         Command="{x:Static m:ContactView.ClearNamesCommand}" />
     <CommandBinding
         Command="{x:Static m:ContactView.NavigateUriCommand}" />
 </StackPanel.CommandBindings>
Binding a button click to a method with no arguments:
 <Button
     Content="Clear Names"
     Command="{x:Static m:ContactView.ClearNamesCommand}" />
Binding a hyperlink to a method passing the an argument via CommandParameter:
<Hyperlink
    Command="{x:Static m:ContactView.NavigateUriCommand}"
    CommandParameter="http://nikosbaxevanis.com"
    NavigateUri="nikosbaxevanis.com">nikosbaxevanis.com</Hyperlink>

Last edited Dec 18, 2010 at 5:28 PM by baxevanis, version 7

Comments

No comments yet.