Example #1
0
        public virtual bool Navigate(NavigatingCancelEventArgsBase args, IDataContext context)
        {
            Should.NotBeNull(args, "args");
            if (!args.IsCancelable)
            {
                return(false);
            }
            var eventArgs = (NavigatingCancelEventArgs)args;

            //Close button pressed.
            if (eventArgs.IsBackButtonNavigation && XamarinFormsExtensions.SendBackButtonPressed != null)
            {
                var sendBackButton = XamarinFormsExtensions.SendBackButtonPressed(CurrentContent as Page);
                if (sendBackButton != null)
                {
                    RaiseNavigated(null, null, NavigationMode.Back);
                    sendBackButton();
                    return(true);
                }
            }
            if (eventArgs.NavigationMode == NavigationMode.Back)
            {
                GoBack();
                return(true);
            }
            // ReSharper disable once AssignNullToNotNullAttribute
            return(Navigate(eventArgs.Mapping, eventArgs.Parameter, context));
        }
Example #2
0
        private static PlatformInfo GetPlatformInfo()
        {
            Assembly assembly = TryLoadAssembly(BindingAssemblyName, null);

            if (assembly == null)
            {
                if (Device.OS == TargetPlatform.WinPhone)
                {
                    assembly = TryLoadAssembly(WinRTAssemblyName, null);
                }
                if (assembly == null)
                {
                    return(XamarinFormsExtensions.GetPlatformInfo());
                }
            }
            TypeInfo serviceType = typeof(IPlatformService).GetTypeInfo();

            serviceType = assembly.DefinedTypes.FirstOrDefault(serviceType.IsAssignableFrom);
            if (serviceType != null)
            {
                _platformService = (IPlatformService)Activator.CreateInstance(serviceType.AsType());

                BindingServiceProvider.ValueConverter = _platformService.ValueConverter;
            }
            return(_platformService == null
                ? XamarinFormsExtensions.GetPlatformInfo()
                : _platformService.GetPlatformInfo());
        }
Example #3
0
 private static void OnViewCleared(IViewManager viewManager, IViewModel viewModel, object arg3, IDataContext arg4)
 {
     try
     {
         XamarinFormsExtensions.ClearBindingsRecursively(arg3 as BindableObject, true, true);
     }
     catch (Exception e)
     {
         Tracer.Error(e.Flatten(true));
     }
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="XamarinFormsBootstrapperBase" /> class.
        /// </summary>
        protected XamarinFormsBootstrapperBase()
        {
            var assembly = TryLoadAssembly(BindingAssemblyName, null);

            if (assembly != null)
            {
                var serviceType = typeof(IPlatformService).GetTypeInfo();
                serviceType = assembly.DefinedTypes.FirstOrDefault(serviceType.IsAssignableFrom);
                if (serviceType != null)
                {
                    _platformService = (IPlatformService)Activator.CreateInstance(serviceType.AsType());
                }
            }
            _platform = _platformService == null
                ? XamarinFormsExtensions.GetPlatformInfo()
                : _platformService.GetPlatformInfo();
        }
Example #5
0
 private static void OnViewCleared(IViewManager viewManager, IViewModel viewModel, object arg3, IDataContext arg4)
 {
     XamarinFormsExtensions.ClearBindingsRecursively(arg3 as BindableObject, true, true);
 }