Comments (10)
I'm had similar issues with Init().
Since this get's called before the view model is set as the BindingContext on the page, then you can't perform any UI activities here.
I've had to resort to saving the parameter as a member variable, then doing any of my real work in the ViewIsAppearing()
from freshmvvm.
any solution?
from freshmvvm.
Init method is only used for setup, not for showing messages.
It would be better to use the appearing events on the PageModel.
from freshmvvm.
Ok, when I use the ViewIsAppearing() method it it works fine.
@rid00z in my app, each time I navigate (doing push) to some pages, the PageModel needs to do some calls to server side (and will show some alert if there is some exception). Must I use ViewIsAppearing instead of Init method?
from freshmvvm.
up
from freshmvvm.
Yes appearing events are better but you can also set of a background task in the init method.
from freshmvvm.
Yes, the problem is where in the Init method is there any exception and, because of this exception, I want to show an alert. The navigation is broken and you cannot do any navigation.
For example, in the Init method I do something like...
public override void Init(object initData)
{
base.Init(initData);
try
{
CallToApi();
}
catch (Exception ex)
{
// Show a modal with some error message.
}
}
I have the feeling that I am doing something wrong...
Thanks.
from freshmvvm.
any idea guys? :-)
from freshmvvm.
Yeah, why you not call the api on Event? And create an activity indicator in init.
from freshmvvm.
Task.Factory.StartNew(() => DownloadDataFromInternet(), TaskCreationOptions.LongRunning);
from freshmvvm.
Related Issues (20)
- CoreMethods PopPageModel() throws exception when page contains CarouselView HOT 1
- using <Path> in XAML throws TinyIoCResolutionException
- ReverseInit not called HOT 1
- XF 5 MasterDetailPage to FlyoutPage HOT 1
- Correct way to handle Button Clicks and updating the model HOT 1
- Hamburger Menu is displayed in the Content Page in Landscape Orientation - Android HOT 1
- Project status and plans for .NET MAUI HOT 10
- Page not loaded properly for PopPageModel using navigation stack in FreshMVVM Xamarin Forms Android HOT 1
- SetBackButtonTextProperty doesn't work HOT 1
- How to intercept software back button press on FreshMVVM PageModel? HOT 3
- v4.0 Release notes?
- SIGABRT: Popped page does not appear on top of current navigation stack, please file a bug. IOS Xamarin HOT 2
- Can not run sample App in VS2019
- Fody Propertychanged on Viewmodels
- PushPageModel does not work after the app ran in the background
- Implement same bevaviour as at PRISM IDestructible HOT 4
- Update view after update bind property in ViewModel
- Cannot resolve IFreshNavigationService from a page loaded from Notifcation tap HOT 1
- FreshMVVM MAUI support
- Issue 'NavGraph cannot be null' with FreshMasterDetailNavigationContainer since MAUI 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freshmvvm.