I'm navigating to a view. I have an EventDateTime
property which I want to set to DateTime.Today
unless the navigation is coming from MyCustomView
This is what I've come with so far. It's working, but I find this really ugly:
public void OnNavigatedTo(NavigationParameters parameters)
{
if (parameters != null)
{
if (!parameters.ContainsKey(PARAM_NAVIGATEDFROM)) // If there is parameter PARAM_NAVIGATEDFROM, then the navigation doesn't come from MyCustomView
{
EventDateTime = DateTime.Today;
}
else if (parameters[PARAM_NAVIGATEDFROM] != typeof(MyCustomViewModel)) // If there is a parameter PARAM_NAVIGATEDFROM but not with the specific value, the navigation doesn't come from MyCustomView
{
EventDateTime = DateTime.Today;
}
}
else // If there are no parameters at all, the navigation is not coming from MyCustomView either
{
EventDateTime = DateTime.Today;
}
}
Any ideas how I can improve this Code? Maybe even with another approach instead of putting the Code into the OnNavigatedTo()
method?
MyCustomViewModel
? – Heslacher 17 hours agoView
I'm navigating from, so I didn't include it here for readability). – Zure 17 hours agoMyCustomViewModel
and if it is just callreturn;
– Heslacher 17 hours agoOnNavigatedTo()
method after the "other stuff" has already been executed? – Zure 17 hours ago