Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 89864 articles
Browse latest View live

BindableProperty does not change even binded property changed

$
0
0
  1. OnSizeAllocated execute a command.
  2. On command, change MangoBox.RatioX value.
  3. When MangoBox Changed, MangoBox raises RaisePropertyChanged.
  4. I expect BaseLayerView.OnMangoBoxChanged will be executed.

However, step 4 only executed when initialize and bind BaseLayerViewModel.

I checked change MangoBox property does raise RaisePropertyChanged, but BaseLayerView.OnMangoBoxChanged does not executed.

View

public abstract class BaseLayerView<T> : MvxContentView
    {
        public static readonly BindableProperty MangoBoxProperty =
            BindableProperty.Create(
                propertyName: nameof(MangoBox),
                returnType: typeof(MangoBox),
                declaringType: typeof(BaseLayerView<T>),
                defaultValue: null,
                propertyChanged: OnMangoBoxChanged);

        public MangoBox MangoBox
        {
            get => (MangoBox)GetValue(MangoBoxProperty);
            set => SetValue(MangoBoxProperty, value);
        }

        static void OnMangoBoxChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if (newValue is null) { return; }
            var baseLayerView = (BaseLayerView<T>)bindable;

            // code i want to execute when `MangoBox` changed.
        }
    }

I bind BaseLayerView and BaseLayerViewModel by DataTemplate.

    <DataTemplate x:Key="RectLayerView">
        <forms:RectLayerView forms:MangoBox="{Binding MangoBox}" />

ViewModel

Here is binded BaseLayerViewModel

    public abstract class BaseLayerViewModel<LayerModel> : MvxViewModel
    {
        protected T _layerModel;

        public MangoBox MangoBox
        {
            get => _layerModel?.MangoBox;
        }

        public T LayerModel
        {
            get => _layerModel;
            set => SetProperty(ref _layerModel, value, () =>
            {
                _layerModel.MangoBox.PropertyChanged += (sender, e) =>
                {
                    RaisePropertyChanged(nameof(MangoBox));
                };
                RaisePropertyChanged(nameof(MangoBox));
            });
        }
    }

Model

LayerModel is used when BaeLayerViewModel created.

    public class LayerModel : MvxNotifyPropertyChanged
    {
        private MangoBox _mangoBox;
        public MangoBox MangoBox
        {
            get => _mangoBox;
            set => SetProperty(ref _mangoBox, value, () =>
            {
                BindBoxEventHandler();
            });
        }

        public LayerModel(MangoBox box)
        {
            _mangoBox = box;
            BindBoxEventHandler();
        }

        private void BindBoxEventHandler()
        {
            _mangoBox.XChanged += OnBoxPropertyChanged;
        }

        private void OnBoxPropertyChanged(object sender, MangoUnitChangedArgs e)
        {
            RaisePropertyChanged(nameof(MangoBox));
        }
    }

MangoBox

    public class MangoBox : MvxNotifyPropertyChanged
    {
        private readonly MangoPoint _point;
        private readonly MangoSize _size;

        public float RatioX
        {
            get => _point.RatioX;
            set => _point.RatioX = value;
        }

        public MangoBox(Standard2D standard, float x, float y, float width, float height)
        {
            _point = new MangoPoint(standard, x, y);
            _point.XChanged += OnXChanged;

        }

        public event EventHandler<MangoUnitChangedArgs> XChanged;

        private void OnXChanged(object sender, MangoUnitChangedArgs e)
        {
            XChanged?.Invoke(this, e);
            RaisePropertyChanged(nameof(RatioX));
            RaisePropertyChanged(nameof(ValueX));
        }

    }

How to delete a thread?

$
0
0

I accidentally create duplicated thread.

How can I delete a thread?

error MT2091

$
0
0

I am getting this error when building for iOS Release with Linker set to all or sdk framework.
error MT2091: Inliner failed processingSystem.Void MacAttribute::.ctor(System.Byte,System.Byte)``

What does that mean? I cannot find much on that error.

Can I select the words and copy it?

VM Broken

$
0
0

Hello evreryone

Just a quick question

I have my view

<ContentPage.BindingContext>
        <vm:RegisterViewModel />
    </ContentPage.BindingContext>

    <ScrollView>
        <StackLayout Spacing="20">
            <Image Style="{StaticResource ImageStyle}"
                   Margin="0,20,0,0" />
            <ActivityIndicator IsRunning="{Binding IsBusy}"
                               Color="#28A586" />
            <Grid Margin="10,0,20,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>

                <Image Source="Usuario.png" />

                <Entry Placeholder="Useario"
                       Text="{Binding Username}"
                       Grid.Column="1"
                       Style="{StaticResource Key=EntryStyle}" />

                <Image Source="Clave.png"
                       Grid.Row="1" />
                <Label Text="Debe tener al menos 8 caracteres y un carácter especial"
                       Grid.Column="1"
                       TextColor="White"
                       Margin="0,-7,0,0"
                       Grid.Row="2"
                       FontSize="11" />

                <Entry Placeholder="Contraseña"
                       Text="{Binding Password}"
                       IsPassword="True"
                       Grid.Column="1"
                       Grid.Row="1"
                       Style="{StaticResource EntryStyle}" />

                <Image Source="Clave.png"
                       Grid.Row="3" />

                <Entry Placeholder="Confirmar contraseña"
                       Text="{Binding ConfrimPassword}"
                       Style="{StaticResource EntryStyle}"
                       IsPassword="True"
                       Grid.Column="1"
                       Grid.Row="3" />

                <Image Source="Email.png"
                       Grid.Row="4" />

                <Entry Placeholder="Correo Electrónico"
                       Keyboard="Email"
                       Text="{Binding Email}"
                       Style="{StaticResource EntryStyle}"
                       Grid.Column="1"
                       Grid.Row="4" />
            </Grid>

            <Button Text="Registrame"
                    Command="{Binding RegisterCommand}"
                    Style="{StaticResource Key=YellowButtons}"
                    IsEnabled="{Binding IsEnable}"
                    Margin="0,20,0,0" />

            <Grid Margin="10,10,10,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80" />
                </Grid.ColumnDefinitions>
                <StackLayout Orientation="Horizontal">
                    <Button Text="Registro con facebook"
                            FontSize="8"
                            TextColor="White"
                            Command="{Binding FacebookCommand}"
                            ContentLayout="Left,20"
                            Image="Facebook.png"
                            HorizontalOptions="Start"
                            BackgroundColor="Transparent" />
                </StackLayout>
                <StackLayout Grid.Column="2"
                             Orientation="Horizontal">
                    <Button Text="Registro con Gmail"
                            FontSize="8"
                            Command="{Binding GmailCommand}"
                            ContentLayout="Left,20"
                            Image="Gmail.png"
                            TextColor="White"
                            BackgroundColor="Transparent"
                            HorizontalOptions="Start" />
                </StackLayout>
            </Grid>
        </StackLayout>
    </ScrollView>

and my view model

 class RegisterViewModel : BaseViewModel {
        public ICommand RegisterCommand { get; set; }
        public ICommand FacebookCommand { get; set; }
        public ICommand GmailCommand { get; set; }

        public RegisterViewModel() {
            IsEnable = false;
            FacebookCommand = new Command(() => {
                Application.Current.MainPage.DisplayAlert("", "Calling facebook", "OK");
            });
            GmailCommand = new Command(() => {
                Application.Current.MainPage.DisplayAlert("", "Calling Gmail", "OK");
            });
            RegisterCommand = new Command(async () => {
                IsBusy = true;
                JObject data = new JObject {
                    { "username", Username.ToLower() },
                    { "password", Password.ToLower() },
                    { "email", Email.ToLower() }
                };

                var obj = await NetworkHelpper.SendData(Constants.REGISTER, data);

                string result = obj.Content.ReadAsStringAsync().Result;

                if (obj.IsSuccessStatusCode) {
                    IsBusy = false;
                    // Application.Current.MainPage.Navigation.PushAsync(new LoginScreen(), true);
                } else {
                    IsBusy = false;
                    await Application.Current.MainPage.DisplayAlert("Error", result, "ok");
                }
            });
        }

        private string _Username;
        public string Username {
            get { return _Username; }
            set {
                _Username = value;
                RaisePropertyChanged();
                if (Validator()) {
                    IsEnable = false;
                } else {
                    IsEnable = true;
                }
            }
        }


        private string _ConfrimPassword;
        public string ConfrimPassword {
            get { return _ConfrimPassword; }
            set {
                if (_ConfrimPassword != value) {
                    _ConfrimPassword = value;
                    RaisePropertyChanged();
                    if (Validator()) {
                        IsEnable = false;
                    } else {
                        IsEnable = true;
                    }
                }
            }
        }


        private string _Password;
        public string Password {
            get { return _Password; }
            set {
                if (_Password != value) {
                    _Password = value;
                    RaisePropertyChanged();
                    if (Validator()) {
                        IsEnable = false;
                    } else {
                        IsEnable = true;
                    }
                }
            }
        }


        private string _Email;
        public string Email {
            get { return _Email; }
            set {
                if (_Email != value) {
                    _Email = value;
                    RaisePropertyChanged();
                    if (Validator()) {
                        IsEnable = false;
                    } else {
                        IsEnable = true;
                    }
                }
            }
        }

        private bool Validator() {
            return string.IsNullOrEmpty(_Username)
                                    || string.IsNullOrEmpty(_Password)
                                    || string.IsNullOrEmpty(_ConfrimPassword)
                                    || string.IsNullOrEmpty(_Email)
                                    || _ConfrimPassword != _Password;
        }

        private bool _IsEnable;
        public bool IsEnable {
            get { return _IsEnable; }
            set {
                if (_IsEnable != value) {
                    _IsEnable = value;
                    RaisePropertyChanged();
                }
            }
        }

        private bool _IsBusy;
        public bool IsBusy {
            get { return _IsBusy; }
            set {
                if (_IsBusy != value) {
                    _IsBusy = value;
                    RaisePropertyChanged();
                }
            }
        }
    }
}

For some weird reason the button is not getting disable or enable or anything, but the buttons that the commands are bind to facebook command and gmail command are working perfectly. Any thought?

How to pause Scanning utill i click on the alert in Zxing library using Xamarin forms

$
0
0

Hello everyone ,I'm developing an application using Xamarin forms with Zxing library for scanning ,i am calling the scan method in OnApearing method and it scan continously ,i tried everything to conrol but fail
here's my code

` protected override void OnAppearing()
{
base.OnAppearing();

        var opt = new MobileBarcodeScanningOptions();
        // opt.DelayBetweenContinuousScans = 3000;
        opt.UseNativeScanning = true;
        opt.DisableAutofocus = true;
        zXingView.Options = opt;


        TimeSpan ts = new TimeSpan(0, 0, 0, 2, 0);
        Device.StartTimer(ts, () =>
        {
            if (zXingView.IsScanning)
                zXingView.AutoFocus();
            return true;
        });


        zXingView.OnScanResult += (result) =>
        {   

            if (result == null)
            {
                Application.Current.MainPage.DisplayAlert("Failed", "No barcode found,please try again", "Okay");
                return;

            }
            Device.BeginInvokeOnMainThread(async () =>
            {

             await Application.Current.MainPage.DisplayAlert(result.Text.ToString(), "", "OK");


            });

            UserDialogs.Instance.HideLoading();

        };

    }

`
i also tried isScanning property to true but it scan only once

Crash on foregrounding app iOS

$
0
0

If I background the app and then foreground, I get an ArgumentNullException that doesn't seem to touch my code. What could I be doing wrong? Or should I log a bug?

ios:13.5.1
Xamarin.Forms 4.7.0.1080
Xamarin 16.6.000.1062 (d16-6@41e1f0e)
Xamarin.iOS and Xamarin.Mac SDK 13.18.2.1 (29c4ea7)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Stack Trace from Debugger:
System.ArgumentNullException

Value cannot be null.
Parameter name: enumerable

at Xamarin.Forms.Internals.EnumerableExtensions.IndexOf[T] (System.Collections.Generic.IEnumerable1[T] enumerable, T item) [0x00003] in <d38e76fdc23646f49d3b65e0bfb375de>:0 at Xamarin.Forms.Application.OnRequestedThemeChanged (Xamarin.Forms.AppThemeChangedEventArgs args) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Application.cs:172 at Xamarin.Forms.Platform.iOS.PageRenderer.TraitCollectionDidChange (UIKit.UITraitCollection previousTraitCollection) [0x00021] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:373 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at RemoteApp.Forms.iOS.Application.Main (System.String[] args) [0x00001] in /Users/collinfe/Documents/UnifyVehicleRemote/src/RemoteApp.Forms.iOS/Main.cs:17

Native crash log:
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Thread 0 name: tid_407 Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x0000000189d9dd88 __pthread_kill + 8 1 libsystem_pthread.dylib 0x0000000189cb61e8 pthread_kill$VARIANT$mp + 136 2 libsystem_c.dylib 0x0000000189c099b0 __abort + 112 3 libsystem_c.dylib 0x0000000189c09940 __abort + 0 4 RemoteApp.Forms.iOS 0x00000001072bf774 xamarin_printf + 79918964 (runtime.m:2468) 5 RemoteApp.Forms.iOS 0x000000010718a634 mono_invoke_unhandled_exception_hook + 78652980 (exception.c:1299) 6 RemoteApp.Forms.iOS 0x0000000107127e80 mono_handle_exception_internal + 78249600 (mini-exceptions.c:2783) 7 RemoteApp.Forms.iOS 0x0000000107126868 mono_handle_exception + 78243944 (mini-exceptions.c:3107) 8 RemoteApp.Forms.iOS 0x000000010711d334 mono_arm_throw_exception + 78205748 (exceptions-arm64.c:401) 9 RemoteApp.Forms.iOS 0x00000001030c0edc throw_exception + 172 10 RemoteApp.Forms.iOS 0x000000010341addc Xamarin_Forms_Internals_EnumerableExtensions_IndexOf_T_REF_System_Collections_Generic_IEnumerable_1_T_REF_T_REF + 14233052 (/D:\a\1\s\Xamarin.Forms.Core\EnumerableExtensions.cs:81) 11 RemoteApp.Forms.iOS 0x000000010316e310 Xamarin_Forms_Application_OnRequestedThemeChanged_Xamarin_Forms_AppThemeChangedEventArgs + 11428624 (/D:\a\1\s\Xamarin.Forms.Core\Application.cs:172) 12 RemoteApp.Forms.iOS 0x0000000105f9a98c Xamarin_Forms_Platform_iOS_PageRenderer_TraitCollectionDidChange_UIKit_UITraitCollection + 59845004 (/D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:375) 13 RemoteApp.Forms.iOS 0x0000000103003860 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272 14 RemoteApp.Forms.iOS 0x0000000107138388 mono_jit_runtime_invoke + 78316424 (mini-runtime.c:3165) 15 RemoteApp.Forms.iOS 0x00000001071e65d4 mono_runtime_invoke_checked + 79029716 (object.c:3220) 16 RemoteApp.Forms.iOS 0x00000001071e9a3c mono_runtime_invoke + 79043132 (object.c:3107) 17 RemoteApp.Forms.iOS 0x000000010268ce48 native_to_managed_trampoline_5(objc_object*, objc_selector*, _MonoMethod**, objc_object*, unsigned int) + 20040 (registrar.m:228) 18 RemoteApp.Forms.iOS 0x000000010270e494 -[Xamarin_Forms_Platform_iOS_PageRenderer traitCollectionDidChange:] + 550036 (registrar.m:49197) 19 UIKitCore 0x000000018da0a308 -[UIViewController _traitCollectionDidChange:] + 204 20 UIKitCore 0x000000018da0a5cc -[UIViewController _updateTraitsIfNecessary] + 372 21 UIKitCore 0x000000018e503414 -[UIView+ 15606804 (CALayerDelegate) layoutSublayersOfLayer:] + 1048 22 QuartzCore 0x0000000190a96724 -[CALayer layoutSublayers] + 284 23 QuartzCore 0x0000000190a9c87c CA::Layer::layout_if_needed+ 1407100 (CA::Transaction*) + 468 24 QuartzCore 0x0000000190aa73c0 CA::Layer::layout_and_display_if_needed+ 1450944 (CA::Transaction*) + 140 25 QuartzCore 0x00000001909eff1c CA::Context::commit_transaction+ 700188 (CA::Transaction*, double) + 296 26 QuartzCore 0x0000000190a198bc CA::Transaction::commit+ 870588 () + 676 27 UIKitCore 0x000000018e0589f4 __83-[UIApplication _createSnapshotContextForScene:withName:performLayoutWithSettings:]_block_invoke_4 + 44 28 UIKitCore 0x000000018e057dd0 -[UIApplication _performWithUICACommitStateSnapshotting:] + 184 29 UIKitCore 0x000000018e05892c __83-[UIApplication _createSnapshotContextForScene:withName:performLayoutWithSettings:]_block_invoke_2 + 552 30 UIKitCore 0x000000018e4f61cc +[UIView+ 15552972 (Animation) performWithoutAnimation:] + 96 31 UIKitCore 0x000000018e0586cc __83-[UIApplication _createSnapshotContextForScene:withName:performLayoutWithSettings:]_block_invoke + 216 32 UIKitCore 0x000000018d665540 -[UIScene _applyOverrideSettings:forActions:] + 116 33 UIKitCore 0x000000018e294fa4 -[UIWindowScene _applySnapshotSettings:forActions:] + 76 34 UIKitCore 0x000000018e05859c -[UIApplication _createSnapshotContextForScene:withName:performLayoutWithSettings:] + 380 35 UIKitCore 0x000000018e059f38 __65-[UIApplication _performSnapshotsWithAction:forScene:completion:]_block_invoke_3 + 124 36 FrontBoardServices 0x000000018f166538 -[FBSSceneSnapshotAction _executeNextRequest] + 256 37 FrontBoardServices 0x000000018f16658c -[FBSSceneSnapshotAction _executeNextRequest] + 340 38 FrontBoardServices 0x000000018f166128 -[FBSSceneSnapshotAction executeRequestsWithHandler:completionHandler:expirationHandler:] + 276 39 UIKitCore 0x000000018e059e60 __65-[UIApplication _performSnapshotsWithAction:forScene:completion:]_block_invoke_2 + 280 40 UIKitCore 0x000000018e0593c8 -[UIApplication _beginSnapshotSessionForScene:withSnapshotBlock:] + 1028 41 UIKitCore 0x000000018e059d20 __65-[UIApplication _performSnapshotsWithAction:forScene:completion:]_block_invoke + 132 42 UIKitCore 0x000000018d665438 -[UIScene _enableOverrideSettingsForActions:] + 60 43 UIKitCore 0x000000018d6656b8 -[UIScene _performSystemSnapshotWithActions:] + 120 44 UIKitCore 0x000000018e059a9c -[UIApplication _performSnapshotsWithAction:forScene:completion:] + 468 45 UIKitCore 0x000000018e594968 __98-[_UISceneSnapshotBSActionsHandler _respondToActions:forFBSScene:inUIScene:fromTransitionContext:]_block_invoke_3 + 168 46 UIKitCore 0x000000018e5947f0 __98-[_UISceneSnapshotBSActionsHandler _respondToActions:forFBSScene:inUIScene:fromTransitionContext:]_block_invoke_2 + 468 47 UIKitCore 0x000000018d664cb4 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 664 48 UIKitCore 0x000000018d665cac -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220 49 UIKitCore 0x000000018dbebafc -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464 50 FrontBoardServices 0x000000018f1200a8 -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] + 528 51 FrontBoardServices 0x000000018f144684 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 + 120 52 FrontBoardServices 0x000000018f129bfc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 53 FrontBoardServices 0x000000018f1445b8 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke + 184 54 libdispatch.dylib 0x0000000189c6e524 _dispatch_client_callout + 16 55 libdispatch.dylib 0x0000000189c17434 _dispatch_block_invoke_direct$VARIANT$mp + 224 56 FrontBoardServices 0x000000018f168850 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40 57 FrontBoardServices 0x000000018f16851c -[FBSSerialQueue _queue_performNextIfPossible] + 404 58 FrontBoardServices 0x000000018f168a44 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 59 CoreFoundation 0x0000000189f26c18 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 60 CoreFoundation 0x0000000189f26b70 __CFRunLoopDoSource0 + 80 61 CoreFoundation 0x0000000189f262f8 __CFRunLoopDoSources0 + 184 62 CoreFoundation 0x0000000189f21328 __CFRunLoopRun + 788 63 CoreFoundation 0x0000000189f20ce8 CFRunLoopRunSpecific + 424 64 GraphicsServices 0x000000019406b38c GSEventRunModal + 160 65 UIKitCore 0x000000018e04f444 UIApplicationMain + 1932 66 RemoteApp.Forms.iOS 0x0000000105a33798 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 344 67 RemoteApp.Forms.iOS 0x000000010516b020 UIKit_UIApplication_Main_string___intptr_intptr + 44970016 (UIApplication.cs:86) 68 RemoteApp.Forms.iOS 0x000000010516aea4 UIKit_UIApplication_Main_string___string_string + 44969636 (UIApplication.cs:66) 69 RemoteApp.Forms.iOS 0x000000010273c190 RemoteApp_Forms_iOS_Application_Main_string__ + 737680 (Main.cs:17) 70 RemoteApp.Forms.iOS 0x0000000103003860 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272 71 RemoteApp.Forms.iOS 0x0000000107138388 mono_jit_runtime_invoke + 78316424 (mini-runtime.c:3165) 72 RemoteApp.Forms.iOS 0x00000001071e65d4 mono_runtime_invoke_checked + 79029716 (object.c:3220) 73 RemoteApp.Forms.iOS 0x00000001071eb878 mono_runtime_exec_main_checked + 79050872 (object.c:5284) 74 RemoteApp.Forms.iOS 0x000000010711ce74 mono_jit_exec + 78204532 (driver.c:1328) 75 RemoteApp.Forms.iOS 0x00000001072cfd84 xamarin_main + 79986052 (monotouch-main.m:485) 76 RemoteApp.Forms.iOS 0x000000010273c094 main + 737428 (main.m:186) 77 libdyld.dylib 0x0000000189da88f0 start + 4

WebView.EvaluateJavaScriptAsync always null

$
0
0

I'm trying to use WebView.EvaluateJavaScriptAsync.

I'm just using this page to test with

If you try it in Chrome and in the debug console type
myFunction(123, 456)

It says "56088".

But in Xamarin.Forms if I do:

string result = await webView.EvaluateJavaScriptAsync($"myFunction(123, 456)");

result is always null

I can do other things, and they work fine:

string result2 = await webView.EvaluateJavaScriptAsync("27 + 92");
string result3 = await webView.EvaluateJavaScriptAsync("alert('hey')");
string documentBodyInnerHTML = await webView.EvaluateJavaScriptAsync("document.body.innerHTML");

Anyone know how to get this working?


Getting (com.apple.AuthenticationServices.AuthorizationError error 1000)

$
0
0

Getting (com.apple.AuthenticationServices.AuthorizationError error 1000) on calling AppleSignInAuthenticator.AuthenticateAsync(). I added apple signin key 'com.apple.developer.applesignin' in Entitlements as documented. But i'm getting access token from WebAuthenticator.AuthenticateAsync(authorizationUrl, callbackUrl)

Content of a frame that is the View of a ViewCell appear on top of other rows in the list - iOS only

Will the MediaElement support playing .m3u8 files in the future?

$
0
0

As far as I tested the MediaElement in Xamarin.Forms 4.7, it plays mp4 files, but not .m3u8 playlist files.
Is there a plan to support also the m3u8 file type in the future? Or is there another Xamarin Forms component that could handle m3u8 files?
Thank you.

Xamarin Forms: How to highlight text and pause/play audio of text to speech?

$
0
0

I am using the xamarin essentials package for text to speech feature. When speech the text I need to highlight the corresponding text. Also, I need an option to pause/play the speech. Please see this video.

Screenshot:

enter image description here

How can I achieve highlight text feature and pause/play audio as the video?

HTML Content not working properly on IOS

$
0
0

Hi everyone, I'm getting a headache to display some dashboards into my Xamarin Forms project, as you can see in the picture below it's working pretty nice at Android devices. However when it goes to IOS it doesn't work, the screen does not fill and expand and the view is not properly exhibiting in "Mobile Mode View",

I'm using a Tableau Desktop to make these dashboards and then I insert a EMBED into my HTML pages to then display it on my Xamarin, here's what I used to manage it to work, i followed Microsoft documentation to display the HTML content into a webview

And here is the Javascript embed API to display the dashboard:

    <div class='tableauPlaceholder' id='viz1587599706721' style='position: relative'>
            <noscript>
            <a href='#'>
                <img alt=' ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Da&#47;DashboardEFColunasSample&#47;DashboardMainTest&#47;1_rss.png' style='border: none' />
                </a>
                </noscript>
            <object class='tableauViz'  style='display:none;'>
            <param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
            <param name='embed_code_version' value='3' />
            <param name='site_root' value='' />
            <param name='name' value='DashboardEFColunasSample&#47;DashboardMainTest' />
            <param name='tabs' value='no' />
            <param name='toolbar' value='yes' />
            <param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Da&#47;DashboardEFColunasSample&#47;DashboardMainTest&#47;1.png' />
            <param name='animate_transition' value='yes' />
            <param name='display_static_image' value='yes' />
            <param name='display_spinner' value='yes' />
            <param name='display_overlay' value='yes' />
            <param name='display_count' value='yes' />
            <param name='filter' value='publish=yes' />
                </object>
            </div>                
            <script type='text/javascript'>                   
                var divElement = document.getElementById('viz1587599706721');
                var vizElement = divElement.getElementsByTagName('object')[0];
                if (divElement.offsetWidth > 800) {
                    vizElement.style.width = '1100px';
                    vizElement.style.height = '627px';
                } else if (divElement.offsetWidth > 500) {
                    vizElement.style.width = '1100px';
                    vizElement.style.height = '627px';
                } else {
                    vizElement.style.width = '100%'; vizElement.style.height = '577px';
                } var scriptElement = document.createElement('script');
                scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
                vizElement.parentNode.insertBefore(scriptElement, vizElement);
            </script>

HERE IS THE XAML CODE:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:d="http://xamarin.com/schemas/2014/forms/design"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
                 mc:Ignorable="d"
                 android:TabbedPage.IsSwipePagingEnabled="False"
                 android:TabbedPage.ToolbarPlacement="Bottom"
                 BarBackgroundColor="#00143D"
                 BarTextColor="White"
                 Visual="Material"
                 SelectedTabColor="DeepSkyBlue"
                 UnselectedTabColor="White"
                 x:Class="AlgorixMobile.Views.FaturamentoeEbitdaView"
                 Title="Faturamento Ebitda">
        <TabbedPage.ToolbarItems>
            <ToolbarItem IconImageSource="diagrama.png" />
        </TabbedPage.ToolbarItems>
        <TabbedPage.Children>
            <ContentPage Title="Colunas" IconImageSource="lucro.png" >
                <StackLayout>
                    <WebView x:Name="Barras"
                       HorizontalOptions="{OnPlatform Android=FillAndExpand, iOS=FillAndExpand}"
                       VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
            <ContentPage Title="Linhas" IconImageSource="estatisticas.png">
                <StackLayout>
                    <WebView x:Name="Linhas"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
            <ContentPage Title="Ultimos 12 meses" IconImageSource="lucro.png" >
                <StackLayout>
                    <WebView x:Name="Ultimos12"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
            <ContentPage Title="Anual" IconImageSource="lucro.png">
                <StackLayout>
                    <WebView x:Name="Anual"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
        </TabbedPage.Children>
    </TabbedPage>

What I need is to make it work on IOS the same way as it is working at the Android, can anyone help ?

I mean is it possible to force the ios to recognize as a mobile device the HTML content if so how to make it shows on full screen mode?

Thanks in advance!

I don't know how to fix this

Service doesn't work when device sleeps

$
0
0

I've built a simple service which works fine.

public class FibonacciJob : JobService
{
    public override bool OnStartJob(JobParameters jobParams)
    {
        int x = jobParams.Extras.GetInt("secondsToWait", -1);

        Task.Run(() =>
        {
            Thread.Sleep(1000*x);
            JobFinished(jobParams, false);
        });            
        return true;
    }

    public override bool OnStopJob(JobParameters jobParams)
    {
        return false;
    }
}

The calling to the service is done by the next class:

    public class Class1: I1
    {
        public const string JobSchedulerService = "jobscheduler";
        public void F1(int seconds)
        {
            var instance = MainActivity.Instance;

            Java.Lang.Class javaClass = Java.Lang.Class.FromType(typeof(FibonacciJob));
            ComponentName component = new ComponentName(instance, javaClass);
            var jobParameters = new PersistableBundle();
            jobParameters.PutInt("secondsToWait", seconds);

            JobInfo.Builder builder = new JobInfo.Builder(1, component)
                                                 .SetMinimumLatency(10000)   
                                                 .SetOverrideDeadline(10000) 
                                                 .SetExtras(jobParameters);

            JobInfo jobInfo = builder.Build();

            JobScheduler jobScheduler = (JobScheduler)instance.GetSystemService(JobSchedulerService);
            int result = jobScheduler.Schedule(jobInfo);        
        }
    }

The problem is that when I switch the phone to sleep mode (click the button on the device's side, so the screen is turned off),
the service doesn't work- the SetOverrideDeadline(10000) will not be taken in account.
Nothing will happen no matter how much time will pass.

How can I cause the service to start after X time (Lets say 1 hour) , no matter if the device sleeps or not.


How to insert badge in botttom tab on shell page?

$
0
0

I searched alot on internet but found no solution..Badge can be easily inserted in tabbed page but i am using Shell page..Anyone have code how to show badge in bottom tab in shell page?

PostAsync has occurred “the request timed out” on iOS Xamarin Forms

$
0
0

I use xamarin forms to create an mobile app for Android and iOS. I need to make Http Request, so I use HttpClient.

Here is a simple code of request :

var client = new HttpClient();
try
{
   string requestUrl = URL_DATABASE + "xxx";

   var content = new StringContent("{\"param\":\"" + param+ "\"}", Encoding.UTF8, "application/json");
   var response = await client.PostAsync(requestUrl, content);

   if (response.StatusCode == HttpStatusCode.OK)
   {
      var result = await response.Content.ReadAsStringAsync();
      return result;
   }

   return "{\"status\":-1}";
}

catch (Exception ex) // Error catched : "the request timed out"
{
   return "{\"status\":-1}";
}

I used Postman to check result of my request and work's well, I got good response without timeout.
I noticed that error occurs sometimes but can last an hour.

Thank you in advance for your help

Device.RuntimePlatform not resolved in some files

$
0
0

Hi,

When using the RuntimePlatform attribute in some files, the VS cannot resolve the symbol. I have grouped my code in two folders (called "Misc" and "Models").

  1. Inside the Models directory, the Device.RuntimePlatform is found and works as expected.

  2. Inside the Misc directory (manually created by me), I get "The name 'Device.RuntimePlatform' does not exist in the current context." and the "using Xamarin.Forms" statement stays greyed out.

The Xamarin.Forms."Device" assembly is present and the RuntimePlatform attribute is there.

May you please advise how to figure this out?

Problem with conditional compilation

$
0
0

Good day!
if I run this fragment

var sCheck = "universal code";
# if _ ANDROID _
sCheck = "Android code";
# endif

on android device (or emulator) sCheck always has "universal code" value (I wait for "Android code" value). What I am doing wrong ?

I use Visual Studio Community 2017.

Thanks in advance for your help

Xamarin.UITest

$
0
0

Hi All,

is there a way how to verify in UI test that for example only three elements are on screen.

So for example I have something like this:

I want to verify that only those three options are on screen. So for example when there would be 4th option there test would fail.

Thank you.

Viewing all 89864 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>