Posts

Showing posts from May, 2015

CallDataMethod trigger in Xamarin Forms

Here’s a very simple implementation of a CallDataMethod trigger in Xamarin Forms: public class CallDataMethod: TriggerAction < VisualElement > { public string Method { get ; set ; } #region implemented abstract members of TriggerAction protected override void Invoke (VisualElement sender) { MethodInfo method = sender.GetType ().GetRuntimeMethod (Method, new Type[ 0 ]); if (method != null ) { ParameterInfo[] parameters = method.GetParameters (); if (parameters.Length == 0 ) method.Invoke (sender, null ); } } #endregion } For a demo, let’s say we have two text-boxes (Entry control in Xamarin Forms) and you want to enable the second one when the first has ten characters: <? xml version = " 1.0 " encoding = " UTF-8 " ?> < ContentPage xmlns = " http://xamarin.com/schemas/2014/forms &quo

Manually install Xamarin Studio addins

Just copy the .dll file to (note the Xamarin Studio version, it might be different today): on Windows : %LocalAppData%\XamarinStudio-5.0\LocalInstall\Addins on Mac : /Users/[YourUser]/Library/Application Support/XamarinStudio-5.0/LocalInstall/Addins Source: http://forums.xamarin.com/discussion/comment/6356/#Comment_6356

Add ImageFailed and ImageOpened to the Xamarin Forms Image control

Currently the Image control in Xamarin Forms does not have an event to handle when image could or couldn't open. I created a way to do this by extending the implementation for the Image control and ImageSource. Check out the source code and a demo app on my GitHub: https://github.com/nitescua/ImageExtensionsApp I implemented two ways to handle image loaded status. You could either:  1. Use the Image derived class ImageEx which exposes ImageOpened and ImageFailed events: < controls:ImageEx Source = " http://dummyimage.com/100x100/000/fff " ImageFailed = " Image_ImageFailed " ImageOpened = " Image_ImageOpened " /> 2. Handle the status change right on the ImageSource instance: ImageSourceExtensions.SetStatusChangedHandler (MyImage.Source, (sender, status) => { Debug.WriteLine( " Image status: {0} " , status); }); where MyImage is an Image control in your Page To add the implementation in your apps, you need to: 1. Add ImageSour

Cross platform splash screen in Xamarin Forms

If the splash screen is more than just an image, you can treat the splash screen as a Xamarin Page. To make this there are some steps: Step 1 . set the App’s MainPage to the splash screen page: public partial class App : Application { public App() { InitializeComponent(); Setup.Init(); // with XLabs, you would do (Page)ViewFactory.CreatePage<SplashViewModel>(); MainPage = new SplashPage(); } Step 2 .  In SplashPage, after some logic is done, you will need to “navigate” to your first app’s page. This means you just need to set again the App’s MainPage, i.e”: void ShowMainPage() { MainPage = new SplashPage(); } The issue is how do you call this. If you are not doing any logic in the splash screen, you can just do something like this: public class SplashPage : Page { async protected override void OnAppearing() { ba