Silverlight5
From a button click on Tab1Data I want to pass a parameter to Tab2_1Data
Am currently doing it with a global public property(!) on the MainPage which each UserControl can reference using this helper
Is there a better way using a non MVVM approach to pass parameters?
<controls:TabControl Name="TabOverallMain">
<!-- Tab 1 -->
<controls:TabItem Header="Home Screen" IsSelected="True">
<UserControls:Tab1Data />
</controls:TabItem>
<!-- Tab 2 -->
<controls:TabItem Header="Admin">
<Grid>
<controls:TabControl>
<!-- Tab 2_1 -->
<controls:TabItem Header="Users">
<UserControls:Tab2_1Data />
</controls:TabItem>
EDIT:
Using this I implemented a DependencyProperty in my Tab2_1Data control:
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(WidgetControl),null);
public string Caption
{
get { return (string)GetValue(CaptionProperty); }
set { SetValue(CaptionProperty, value); }
}
which I then referenced from my Tab1Data user control by:
wid.Caption = "hello world";
This is fine for me now.. although databinding between the 2 looks v.good too!
Since you dont want to use MVVM, try use data binding.. You will need to expose the parameter as a dependency propety int the first control
Here’s some pseudo code. Create a dependency property on Tab1Data called MyParam
Then create a dependency property (similar to above) on the second control called something like ParamFromControlOne… then bind them
That’s not tested and thrown together using Notepad, but that is the path I would go down