Search code examples
silverlightxamlbindinguser-controlscommandparameter

Binding XAML usercontrol in XAML


I have two UserControls: Main nad Settings. In Main in some control I want to set CommandParameter in XAML to Settings. In C# code is simple, like:

biSettings.CommandParameter = new Settings();

How can I do that in XAML?

CommandParameter="???"

The Settings has own model I'm using MVVM. I found solutions here Binding UserControl in XAML, but It is not clear MVVM because in VM is MV! I'm using Silverlight 4.


Solution

  • Let's say the control is a Button, you could so something like this:

    <Button Command={Binding Foo} Content="Click Me">
      <Button.CommandParameter>
        <mystuff:Settings />
      </Button.CommandParameter>
    </Button>