Reputation: 773
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.
Upvotes: 1
Views: 497
Reputation: 8849
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>
Upvotes: 2
Reputation: 752
Type type = biSettings.GetType();
FieldInfo field = type.GetField("CommandParameter");
if (field != null)
{
DependencyProperty dp = (DependencyProperty)field.GetValue(Result);
if (dp != null)
{
((UserControl)Result).SetValue(dp, YourSettingObject);
}
}
Upvotes: 0