MattNorman
Well-known member
- Joined
- May 22, 2021
- Messages
- 98
- Programming Experience
- 1-3
I am having some trouble figuring out the best approach to pass data around when switching windows/views.
On application start up, I first check if the application needs to be configured for the first time.
If it does, I create a new instance of a window called 'AutoSizeWindow' which just has a ContentControl and auto sizes to the contents height and width.
I then set the ContentControls content to a new instance of my 'SetupTypeView'.
From that view, the user selects a setup type from a combobox and hits the continue button.
The selected value from the combo box is bound back the SetupTypeViewModel.
Once that process has completed I then need to display my 'SystemSettingsView' within the original 'AutoSizeWindow' but need to pass through the selected setup type the user chose.
Should I be updating the view from my 'SetupTypeViewModel' or should I be doing this back on the applications entry point?
Also how can I pass the chosen setup type back to my app.xaml.cs so that the next view can be displayed based on that selection?
Appreciate any help.
app.xaml.cs
Is there a way I can access the property from the SetupTypeViewModel once the dialog window has been closed?
On application start up, I first check if the application needs to be configured for the first time.
If it does, I create a new instance of a window called 'AutoSizeWindow' which just has a ContentControl and auto sizes to the contents height and width.
I then set the ContentControls content to a new instance of my 'SetupTypeView'.
From that view, the user selects a setup type from a combobox and hits the continue button.
The selected value from the combo box is bound back the SetupTypeViewModel.
Once that process has completed I then need to display my 'SystemSettingsView' within the original 'AutoSizeWindow' but need to pass through the selected setup type the user chose.
Should I be updating the view from my 'SetupTypeViewModel' or should I be doing this back on the applications entry point?
Also how can I pass the chosen setup type back to my app.xaml.cs so that the next view can be displayed based on that selection?
Appreciate any help.
app.xaml.cs
C#:
private void AppStart(object sender, StartupEventArgs e)
{
//Set default theme colors.
ThemeManager.ChangeAccentColor(Colors.DarkRed);
//Check if first time setup. If so, run through setup process and then go back to start to re-process user info.
if (RegistryManager.GetRegistrySetting("FirstTimeSetup") == "true" || RegistryManager.GetRegistrySetting("FirstTimeSetup") == string.Empty)
{
//Display setup type view.
AutoSizeWindow wdw = new AutoSizeWindow();
SetupTypeView viewSetupType = new SetupTypeView();
viewSetupType.DataContext = new SetupTypeViewModel();
wdw.cntMain.Content = viewSetupType;
wdw.ShowDialog();
//Check setup type.
}
else
{
//Validate user etc
//Load main window and view
}
}
Is there a way I can access the property from the SetupTypeViewModel once the dialog window has been closed?
Last edited: