I wanted to keep loader for xamarin forms is there a way to keep loader in PCL file rather than keeping separately in android and ios
There are few options:
You can use ActivityIndicator which is an abstraction of a 'loader' on each platform. Just add <ActivityIndicator IsRunning ="true" /> to your XAML.
Another option is to use 'IsBusy' property of Page. So you could set it to true to activate global activity indicator on each platform.
Additionally, there is a very handy open source library Rg.Plugins.Popup which you can use to present an AcitivityIndicator as a popup, so you don't have to deal with disabling controls on your form.
Now when you know how to present a loading indicator on the screen, all you need to do is to bind 'IsRunning' (depends on the presenter) to a bool flag in your ViewModel.
Which will change its state according to your WebService call state.
Good luck.
Related
WPF in .NET 4.5 allows binding to static properties using x:Static markup. I'm using it to binding my labels to resource strings. My labels look like this:
<TextBlock Text="{x:Static properties:Resources.SomeResourceString}" />
Application allows localization and user can choose display language from Settings dialog. All translations are in place. The only problem I'm facing is that there is no apparent way of "refreshing" these bindings.
WPF in .NET 4.5 listens to static version of PropertyChanged event, but there is no way for me to raise such an event because Resources class is auto-generated and is not extendable (no partial).
Reloading the application is of course one solution, but I don't want to do that. Interestingly, any labels that are not on screen right now (in a different Tab for example) get updated correctly. It is only the current screen that is not updating.
I have a prism Xamarin Forms application which is being designed for both UWP, Android on IOS. This is the first UWP app that I have created. I want to have a menu that is only accessible from the first level of navigation. To do this, in the past, I have used a Master-Detail page. However, I have encountered some behaviour differences that I need some help with.
When I use a Master-Detail screen on IOS or Android it behaves like a menu only accessible to the first level of navigation. Any subpage that you might navigate from there you don't see menu it is replaced by the back button.
When I use a Master-Detail screen on UWP it's behaviour is different. The menu is available on all pages no matter how far into the navigation stack you travel. It is by default also a menu tray of items anchored on the left side of your application.
I have figured out how to make the menu collapse into the hamburger button that I am used to on an Android and IOS application by setting the parameter MasterBehavior to the value Popover. But I would like to have the menu completely disappear on any page navigated past the first level as it does on IOS of Android.
Does anyone know of a way to make this happen?
I think I can say safely that this can't be done in pure Xamarin.Forms.
To change this you would have to change to which UWP Frame the content is loaded, and I am not aware that Frame is exposed anywhere in Xamarin.Forms which means that even custom renderers cannot help.
However you may try to build the native navigation that would act like that in the UWP project and then load inside those native controls Xamarin.Forms page, that should work and deliver the results that you have requested. Not trivial and no few lines that I can show you, but if that is important for you it should be possible this way.
Tap the video player to drop in to Picture-in-Picture mode. Tapping on the PiP view will present controls which can be used to pause, show info, return to full screen, or exit the application.
Xamarin.Forms by default only contains Views that work on all platforms. For example an Entry -> EditText (android), UITextField (iOS), TextBox (UWP).
The Picture-in-picture ability is something that's only available on Android, which means Xamarin.Forms did not implement this.
The only way i could think of doing this is by exporting custom renderers that set the native control for a home-made xamarin.forums-view. I think you can find a good example here: http://blog.infernored.com/going-native-using-android-views-in-xamarin-forms, though i haven't tried it myself.
You'd basically use the SetNativeControl command in the OnElementChanged hook of the custom renderer to probably dom.xamarin.PictureInPicture.MovieView. Don't forget to export the renderers on the namespace.
Then you can use the XF view on your xaml-pages. I'll look in to making an sample.
Picture-in-picture sample for android-only: https://developer.xamarin.com/samples/monodroid/android-o/PictureInPicture/
I want to open the gallery in iPhone simulator upon button click.
I am using Xamarin forms - xaml to create pages and image views.
What I have implemented so far :
I have a GalleryService specific to iOS that implements IGalleryService that has a method selectImage. The selectImage creates a UIImagePickerController _imagePicker.
In iOS specific apps, I would just do
NavigationController.PresentModalViewController(_imagePicker, true);
But how to do something similar using Navigation in xamarin forms?
PS: I have created view in .xaml file and move across pages in xaml.cs file like
Navigation.PushModalAsync(page)
Here, the page must basically contain the _imagePicker view, right? How to do that?
Kindly correct me if I am wrong.
Xamarin.Forms actually utilises a single NavigationController on iOS to host all the different pages. All of the Xamarin Content Pages navigation happens internally in XF, inside the single main NavigationController.
You cannot mix other native view controllers inside the NavigationPage stack. But you can use all the native code you normally would and just treat the one NavigationController that forms uses as a single "screen".
Inside the iOS native project, you can use
var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (topController.PresentedViewController != null) {
topController = topController.PresentedViewController;
}
topController.PresentViewController (_imagePicker, true, null);
to access the XF's view controller, find the top one and use that like you would in a "native" ios app to present the modal view.
Note that this RootViewController will be null until "LoadApplication" finishes, so make sure any calls are made after that, which should always be the case if you are triggering this action from the running app and not immediately on startup.
If using PCL's, you would need some form of a DependencyService to trigger this call from your shared code, and you might need a bit more logic in the native app to get the result back into the shared code. You would also need to reimplement this on any other platforms you might be targeting with your app (such as Android or UWP).
I have an aspx page wherein there are different silverlight components. Each component is of different size and the xaps take different time to download.
Is there any way wherein I can be notified that all my components are downloaded?
I want to display a Splash screen till that time.
Thank You.
Maybe you can try to set an event handler to the "loaded" event of the Silverlight plugin as described here, pointing to a common function that knows each Silverlight plugin on the page and fires another event if all plugins have reported that they are loaded (to hide the splash screen).
But this requires some real-world testing to make sure that the event described there is fired if the plugin is loaded including your "payload" application (and not just the browser plugin).
Another approach could be to implement the "Loaded" event in each of the user controls that make up your applications (maybe by providing a suitable base class) and then invoke a JavaScript method in the surrounding web page as described here, setting a flag for each plugin in the page and hiding the splash screen if all plugins/applications reported to be loaded.