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

Top Padding in Carousel View on iOS

$
0
0

I have a CarouselView inside of an AbsoluteLayout. It is the only element within the AbsoluteLayout. This AbsoluteLayout is the only element of a ContentPage which has NavigationPage.HasNavigationBar="false"

When the CarouselView displays in portrait orientation on the device, it is moved slightly down, seems around 10 units to me. It's definitely the CarouselView as setting the background for the Absolute layout makes this background stick out in the gap. This does not occur in landscape orientation. Does anyone know how to fix this? I've tried everything.

Here is my XAML:
<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.Content>

        <cv:CarouselView x:Name="IntroCarousel"
                     ItemsSource="{Binding Path=BindingContext.Intros, Source={x:Reference IntroPage}}"
                     PositionSelected="pageChanged"                                    
                     AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                     AbsoluteLayout.LayoutFlags="All">

            <cv:CarouselView.ItemTemplate>
                <DataTemplate>
                    <StackLayout BackgroundColor="{Binding backgroundColor}"
                                HorizontalOptions="FillAndExpand"
                                VerticalOptions="FillAndExpand"
                              Orientation="Vertical"
                             Margin="0"
                             >

                        <Image Source="{Binding ImageUri}"
                           WidthRequest="250"
                             HeightRequest="150" 
                             HorizontalOptions="Center"
                             VerticalOptions="Center">
                            <Image.Margin>
                                <OnPlatform x:TypeArguments="Thickness"
                                 Android="10, 10, 10, 10"
                                 iOS="10, 30, 10, 10"
                                 WinPhone="10, 10, 10, 10" />
                            </Image.Margin>
                        </Image>

                        <Label Text="{Binding Heading}"
                           FontSize="Large" 
                           FontAttributes="Bold"
                           TextColor="White"
                           HorizontalOptions="Center"
                           VerticalOptions="Center"/>

                        <Label Text="{Binding Description}"
                           TextColor="White"
                           HorizontalOptions="Center"
                           VerticalOptions="Center"
                           Margin="10, 10, 10, 10"/>
                    </StackLayout>
                </DataTemplate>

            </cv:CarouselView.ItemTemplate>
        </cv:CarouselView>
    </AbsoluteLayout>


</ContentPage.Content>


SetBinding a Boolean to display it localised

$
0
0

I want to bind a label with a Boolean and display the value localised in Spanish like "Sí/No" instead of "True/False"
I'm trying this, but doesn't work:
Label1.SetBinding(Label.TextProperty, new Binding(path: "MyBooleanValue", stringFormat: "{0:Sí;No}"));
This still displays True/False.

Any ideas of how to accomplish this?
Thank you.

Xamarin.Android returned no custom HttpClientHandler. ...

$
0
0

Hello guys,

I'm working on a Xamarin.Forms application and i have a Service in the portable project that consumes a REST API.

For consuming the API i use HttpClient as follows:

var client = new HttpClient(); client.DefaultRequestHeaders.Add("Accept-Language", AcceptLanguage); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(ContentType)); return await client.PostAsync(requestUrl, requestEncodedContent);

Running WindowsPhone project: all works great. (i've been running/debugging mostly on this one)

Running Droid project: visual elements/navigation is working. HttpClient is not executing properly.

Running iOS project: Don't have a client that i can test with, so maybe i have the same HttpClient problem here.

Code - ApiService.cs:

try { (...) Debug.WriteLine(TAG + " | PostApiWithUrlEncoded(" + authorize_url + ")"); HttpResponseMessage response = await PostApiWithUrlEncoded(authorize_url, requestEncodedContent); var jsonResponse = await response.Content.ReadAsStringAsync(); (...) } catch() { (...) }

private async Task<HttpResponseMessage> PostApiWithUrlEncoded(string requestUrl, FormUrlEncodedContent requestEncodedContent) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("Accept-Language", AcceptLanguage); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(ContentType)); return await client.PostAsync(requestUrl, requestEncodedContent); }

So the program executes:
HttpResponseMessage response = await PostApiWithUrlEncoded(authorize_url, requestEncodedContent);

But never return a value and eventually falls on the catch..

Thanks in advance,
Best regards.
Miguel.

Output when running Android and consuming API:
[0:] XxxApiService | PostApiWithUrlEncoded(http://192.168.11.226:29999/api/OAuth) 08-12 15:24:07.886 D/Mono ( 1261): DllImport attempting to load: '/system/lib/liblog.so'. 08-12 15:24:07.886 D/Mono ( 1261): DllImport loaded library '/system/lib/liblog.so'. 08-12 15:24:07.886 D/Mono ( 1261): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so'). 08-12 15:24:07.886 D/Mono ( 1261): Searching for '__android_log_print'. 08-12 15:24:07.886 D/Mono ( 1261): Probing '__android_log_print'. 08-12 15:24:07.886 D/Mono ( 1261): Found as '__android_log_print'. 08-12 15:24:07.886 I/mono-stdout( 1261): Xamarin.Android returned no custom HttpClientHandler. Defaulting to System.Net.Http.HttpClientHandler Xamarin.Android returned no custom HttpClientHandler. Defaulting to System.Net.Http.HttpClientHandler 08-12 15:24:07.910 D/Mono ( 1261): Assembly Ref addref System.Net.Http[0xb9026fb0] -> System.Core[0xb7f37ca0]: 7 08-12 15:24:07.918 D/Mono ( 1261): Assembly Ref addref Mono.Android[0xb7c85260] -> System[0xb7d27f80]: 15 08-12 15:24:07.926 D/Mono ( 1261): DllImport searching in: '__Internal' ('(null)'). 08-12 15:24:07.926 D/Mono ( 1261): Searching for 'java_interop_jnienv_call_int_method'. 08-12 15:24:07.926 D/Mono ( 1261): Probing 'java_interop_jnienv_call_int_method'. 08-12 15:24:07.926 D/Mono ( 1261): Found as 'java_interop_jnienv_call_int_method'. Thread started: <Thread Pool> #7 08-12 15:24:07.946 D/Mono ( 1261): [0xb932d440] worker starting protoent* getprotobyname(char const*)(3) is not implemented on Android 08-12 15:24:07.950 W/libc ( 1261): protoent* getprotobyname(char const*)(3) is not implemented on Android protoent* getprotobyname(char const*)(3) is not implemented on Android 08-12 15:24:07.950 W/libc ( 1261): protoent* getprotobyname(char const*)(3) is not implemented on Android protoent* getprotobyname(char const*)(3) is not implemented on Android 08-12 15:24:07.954 W/libc ( 1261): protoent* getprotobyname(char const*)(3) is not implemented on Android Thread finished: <Thread Pool> #2 The thread 'Unknown' (0x2) has exited with code 0 (0x0). Thread finished: <Thread Pool> #7 08-12 15:24:36.706 D/Mono ( 1261): [0xb932d440] worker finishing The thread 'Unknown' (0x7) has exited with code 0 (0x0). Thread started: <Thread Pool> #8 Thread started: <Thread Pool> #9 08-12 15:25:47.922 D/Mono ( 1261): [0xb9379f10] worker starting Thread started: <Thread Pool> #10 08-12 15:25:47.934 D/Mono ( 1261): [0xb937a0c0] worker starting [0:] XxxApiService | Exception: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0002d] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:179 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x004af] in /Users/builder/data/lanes/3540/1cf254db/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:382 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Users/builder/data/lanes/3540/1cf254db/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 at f.Mobile.Services.ApiService+<PostApiWithUrlEncoded>d__22.MoveNext () [0x00081] in D:\TFS\Clientes\f\Solution\Platform\Mobile\f.Mobile\f.Mobile\f.Mobile\Services\ApiService.cs:313 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 at f.Mobile.Services.ApiService+<OAuth>d__19.MoveNext () [0x0014f] in D:\TFS\Clientes\f\Solution\Platform\Mobile\f.Mobile\f.Mobile\f.Mobile\Services\ApiService.cs:92 08-12 15:25:48.002 W/EGL_emulation( 1261): eglSurfaceAttrib not implemented Thread finished: <Thread Pool> #10 08-12 15:26:19.802 D/Mono ( 1261): [0xb937a0c0] worker finishing The thread 'Unknown' (0xa) has exited with code 0 (0x0).

Context is obsolete as of version 2.5

$
0
0

I updated my project to Xamarin forms 2.5. When I use Xamarin.Forms I get warning:

  Context is obsolete as of version 2.5. Please use a local context instead

How use local context instead?

Xamarin Forms SpeechToText Example

$
0
0

How is speech recognition done in xamarin forms?

`public class SpeechToText : ISpeechToText
{
public SpeechToText()
{

    }

    public void speech()
    {
        var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

        // put a message on the modal dialog
        voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt,Android.App.Application.Context.GetString(Resource.String.messageSpeakNow));

        // if there is more then 1.5s of silence, consider the speech over
        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
        voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

        // you can specify other languages recognised here, for example
        // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German);
        // if you wish it to recognise the default Locale language and German
        // if you do use another locale, regional dialects may not be recognised very well

        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);


    }`

How to add rounded badge on button in Xamrin Form?

$
0
0

Hi,

I want to add badge on top right of button as it is given in following screen. Well, I can't add screenshot :neutral:

Let me explain. I have 3 buttons and I want to provide badge of Green color with counter and Gray color with counter. I don't know how to add badge.

When user click on any of button, badge of that button should be in Green color and other should be Gray as it looks like deselected.
Current code of XAML:

<Button Grid.Row="0" Grid.Column="0" Text="Received" WidthRequest="110"/>
<Button Grid.Row="0" Grid.Column="1" Text="Sent" WidthRequest="110"/>
<Button Grid.Row="0" Grid.Column="2" Text="Unknown" WidthRequest="110"/>

Please suggest.

iOS Remoting

$
0
0

Hello,
I just started developing App using Xamarin.form (PCL). I tested it for Android & UWP, It works nice but I can't able to test it for iOS.
I tried using iOS remoting but it fails every time. My Windows having VS 2017 (Enterprise) & Mac ( XCode 9.2 ) .
What are prerequisites ?
Please share me some detailed & complete Forum. Thanks.

Application was working fine but suddenly problem occured

$
0
0

Hi all,

  • I made an application which starts with SPLASH SCREEN, then on HOME PAGE it has Login and Register Button after a button click is pressed it redirects to the respective page but if try registering or logging in, it directly shuts itself by error message on the else part but why can't it work now, which was working earlier [Attached Logs], please help out guys.

    [Activity] Activity.onPostResume() called
    [Timeline] Timeline: Activity_idle id: android.os.BinderProxy@38a3e236 time:17603442
    [ViewRootImpl] ViewRoot's Touch Event : ACTION_DOWN
    [ViewRootImpl] ViewRoot's Touch Event : ACTION_UP
    Thread finished: #28
    Thread finished: #27
    [ViewRootImpl] ViewRoot's Touch Event : ACTION_DOWN
    [ViewRootImpl] ViewRoot's Touch Event : ACTION_UP
    [PhoneWindow] [generateLayout] setColorNavigationBar => color=0x ff000001
    [PhoneWindowEx] [PWEx][generateLayout] setNavigationBarColor2 : colors=0xff000000
    [PhoneWindow] [setNavigationBarColor2] color=0x ff000000
    [ViewRootImpl] CPU Rendering VSync enable = true
    [libc-netbsd] [getaddrinfo]: hostname=xxxxx; servname=0; cache_mode=(null), netid=0; mark=0
    [libc-netbsd] [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=2; ai_family=0
    [Choreographer] Skipped 626 frames! The application may be doing too much work on its main thread.
    ERROR An error occurred while sending the request
    Thread finished: #22
    Thread started: #29
    [PhoneWindow] [generateLayout] setColorNavigationBar => color=0x ff000001
    [PhoneWindowEx] [PWEx][generateLayout] setNavigationBarColor2 : colors=0xff000000
    [PhoneWindow] [setNavigationBarColor2] color=0x ff000000
    [ViewRootImpl] CPU Rendering VSync enable = true
    [Choreographer] Skipped 1094 frames! The application may be doing too much work on its main thread.


Error when i try to generate .APK

$
0
0

The error is:

Path or File name is too big...the file name must have less 260 character..

I cretaed a new folder called "A" and moved my project to this folder and when i went to generate the samething. How can i solve this issue?

Potential iOS Renderer Issue in Base Forms

$
0
0

Hi all,

I was trying to work around the Xamarin Forms ListView memory leak issues that are already well-documented in Bugzilla. While doing so, I encountered a crash in iOS: A null reference exception in the method OnShortNamesCollectionChanged.

I went to the listview renderer on GitHub (note: I cannot post links yet) and looked into this method. In short, I found that there is a subscription to a collection changed event that could theoretically never be unsubscribed from. I don't want to file it as a bug yet because there might be something I missed.

Here's the snippet from the ListViewDataSource class inside the renderer .cs file:

void UpdateShortNameListener()
{
        var templatedList = TemplatedItemsView.TemplatedItems;
        if (List.IsGroupingEnabled)
        {
            if (templatedList.ShortNames != null)
                ((INotifyCollectionChanged)templatedList.ShortNames).CollectionChanged += OnShortNamesCollectionChanged;
        }
        else
        {
            if (templatedList.ShortNames != null)
                ((INotifyCollectionChanged)templatedList.ShortNames).CollectionChanged -= OnShortNamesCollectionChanged;
        }
}

As far as I can see there are no other references to this CollectionChanged event. So, in the scenario where a page is completely removed from the stack (via PopAsync for instance) wouldn't this prevent the GC from releasing the memory due to an event subscription that's never removed?

Like I said, maybe I'm missing something here due to not seeing all the code, but this seems potentially problematic and it seems less than coincidental that I ran into this while researching memory leaks in my Forms app.

Problem handling OpenUrl calls with XF on iOS

$
0
0

I'm working on a Xamarin.Forms project that can be called from another application using an url "testscheme://dosomething".
A OnePage should be shown if the application is called directly and AnotherPage if called through an url.
I have it working on UWP but I fail on iOS... I think I miss something but can't figure what. On iOS, only OnePage is shown but never AnotherPage.
Here is what I have now (just the essential):
iOS AppDelegate:

public partial class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        Xamarin.Forms.Forms.Init();
        LoadApplication(new App(null)); // url is sent to the XF App - null because direct call
        return base.FinishedLaunching(app, options);
    }
    public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
    {
        Xamarin.Forms.Forms.Init();
        LoadApplication(new App(url)); // url is sent to the XF App
        return true;
     }
}

PCL App:

public class App : Application
{
    public App(Uri url = null)
    {
        if (url == null)
        {
            MainPage = new NavigationPage(new OnePage());
        }
       else
        {
            MainPage = new NavigationPage(new AnotherPage());
        }
    }
}

Debugger and some Debug.WriteLine in OnePage and AnotherPage constructors told me that AnotherPage constructor is called if url is not null and OnePage is updated. But iOS just keeps showing the default OnePage...

XF version: 2.1.0.6529
iOS 7.2 mini (tests on iPad iOS 9.2)

Any help is welcome, I was not able to find any example code on the internet nor discussions.

How to add rating stars

$
0
0

I want to add rating bar in xamarin portable class. I had searched a lot and use syncfusion rating bar but not having progress.I had used nuget 3rd party tools. But rating bar dont display. Any suggestion?

How to open PDF or TXT file in default app on Xamarin Forms

$
0
0

I am going to open document using default app in Xamarin Forms. I tried already this approach but it doesn't work for me and I am not sure what is the reason.

Device.OpenUri(new Uri(FILE_PATH));

Please give me great solution if anyone knows how to handle it. Thanks.

Bug or wrong approach? FormattedText and Bindings through XAML throw an exception

$
0
0

We have a Label that has a sentence as the Text property, we want to split it in two to style it differently.
The original approach that compiles and "works" but doesn't show up on screen because our view only allows one component.

<Label Text="{Binding Info}"
      TextColor="#666666"
      FontSize="Small" />
<Label Text="{Binding Sum}"
    TextColor="#666666"
    Font="Bold"
    FontSize="Small" />

When we tried this, it throws an exception. Without the Binding, it works.

<Label>
    <Label.FormattedText>
        <FormattedString>
            <FormattedString.Spans>
                <Span Text="{Binding Info}" ForegroundColor="Red" FontAttributes="Italic" FontSize="10" />
                <Span Text="{Binding Sum}" ForegroundColor="Blue" FontSize="10" />
            </FormattedString.Spans>
        </FormattedString>
    </Label.FormattedText>
</Label>

Does anyone think this is a bug, or it's usually done another way?

Can the Picker signal my MV when it gains focus?

$
0
0

I am trying to get a filtered list to populate a Picker through MVVM (after the user enters a string into a textbox to filter the list). At first, I was rebuilding that list on every keystroke in the textbox (by requerying the db). That worked, but the lag between keystrokes was unacceptable.

I tried to build the list ONLY when the textbox lost focus, and achived that by using an unfocused event trigger (through MessagingCenter). I also decided to use an ObservableCollection instead of a query, thinking that when the OC is filtered, it would automatically update the picker list.

Worked, but the problem is that if you typed a string into the textbox and then clicked the picker, the picker list was populated BEFORE the unfocused event fired (I think). I say that because the list was always one step behind. In other words:

-You enter 'ABC' into the textbox
-Click the picker
-The list in the picker has ALL items still in it

But if you:

-Go back to the textbox
-Replace the string with 'XYZ'
-Click the picker again
-The list populates with ONLY items that included 'ABC'

If you were to enter a string in the textbox, click on ANY other control (besides the picker), and then click the picker, the list would be correct when you DO click the picker.

Does the 'focused' event fire before 'unfocused'? I tried to move the trigger to the picker control, but I get errors when the events are fired. The build is fine, and everything works until the picker gains control, when it then crashes.

FWIW, here is the code for the picker (with trigger):

<Picker ItemsSource="{Binding myList}" Title="Select one" SelectedItem="{Binding myItem}">
    <Picker.Triggers>
        <EventTrigger Event="Focused">
            <local:FocusedTriggerAction />
        </EventTrigger>
    </Picker.Triggers>
    <Picker.ItemDisplayBinding>
        <Binding Path="FullName"/>
    </Picker.ItemDisplayBinding>
</Picker>

The code for the 'FocusedTriggerAction':

namespace DatabaseTest
{
    public class FocusedTriggerAction : TriggerAction<Entry>
    {
        protected override void Invoke(Entry entry)
        {
            MessagingCenter.Send<FocusedTriggerAction>(this, "changeList");
        }
    }
}

And in the VM:

public class MyViewModel : INotifyPropertyChanged {
    public MyViewModel() 
    {
        List<MyOptions> mystuff = new List<MyOptions>();
        using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH)) {
            conn.CreateTable<MyOptions>();
            mystuff = conn.Table<MyOptions>().ToList(); }
        myList = new ObservableCollection<MyOptions>(mystuff);
        MessagingCenter.Subscribe<FocusedTriggerAction> (this, "changeList", (sender) => {
            if (mylookupstring != "")
                myList = new ObservableCollection<MyOptions>(mystuff.Where(o => o.SpecFullName.Contains(mylookupstring)));  });  
    }
    string mylookupstring = string.Empty;
    public event PropertyChangedEventHandler PropertyChanged;
    void OnPropertyChanged([CallerMemberName] string name = "") {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }
    public string myLookupString { get { return mylookupstring; } set {
        mylookupstring = value;
        mylookupstring = mylookupstring.ToUpper();
        OnPropertyChanged(); } }
    private ObservableCollection<MyOptions> _mylist;
    public ObservableCollection<MyOptions> myList { get { return _mylist; } set { 
        if (_mylist != value) { _mylist = value; OnPropertyChanged(); } } 
    } 
}


Keeping UI thread from freezing when setting large content?

$
0
0

Hi - I have content that takes about 2 seconds to render on a nexus 6. i.e. setting Content = mycontent takes 2 seconds. This is in XF by the way.

During that time, the UI thread is totally frozen, including the activityindicator so it looks really bad to the users.

I've done all the optimizations I could think of for the content - it's not particularly large content (around 2 iPhone screens long) so I doubt I can improve the 2 seconds any further.

However, I'd like to know if it's possible to keep the activityindicator spinning while Content = mycontent is being assigned instead of the entire program freezing.

Thank you

Connect to externa webcam

$
0
0

Hello,
Is it possible to get images from an external webcam in a Xamarin iOs or Android ?
Thx
cjacquel

System.Exception: Cannot destroy MyApp.Views.MyNavigationPage when resetting navigation stack

$
0
0

Using Prism 7.0, I'm trying to navigate from ContentPage to a MasterDetailPage. I want to delete the current ContentPage from the navigation stack and go to the MasterDetailPage (Like a login function) like this:

_navigationService.NavigateAsync("../MyMasterDetailPage/MyNavigationPage/ViewB");

This works succesfully. Now, I want to make a logout function that goes back to first page with this:

_navigationService.NavigateAsync("../../../MyNavigationPage/ViewA");

This gives the following error:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

But I'm quite sure there are three elements in this list, MyMasterDetailPage, MyNavigationPage and ViewB. So I tried to use an absolute URI, like this:

_navigationService.NavigateAsync("myapp:///MyNavigationPage/ViewA");

Which results in the error message:

System.Exception: Cannot destroy MyApp.Views.MyNavigationPage

What happens under water when calling an absolute URI in Prism 7.0 to create this error? And is only ViewB counted as an entry and that's why I cannot navigate three steps back?

iOS SignalR Client Error via HTTPS (PCL-Project)

$
0
0

Hello ,

I've got the error from iOS project (PCL-Project) using SignalR-Client when Hubconnection.Start(); via HTTPS but the code it's worked perfectly on Android how should i solve this problem.

And this is the error

{System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00017] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/Socket.cs:1773 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:513 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.EndReadOrWrite (System.IAsyncResult asyncResult, Mono.Net.Security.AsyncProtocolRequest& nestedRequest) [0x00056] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:335 at Mono.Net.Security.MobileAuthenticatedStream.EndRead (System.IAsyncResult asyncResult) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:278 at System.Net.WebConnection.ReadDone (System.IAsyncResult result) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/System.Net/WebConnection.cs:475 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1031 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <6314851f133e4e74a2e96356deaa0c6c>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <6314851f133e4e74a2e96356deaa0c6c>:0 at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x00406] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:388 --- End of inner exception stack trace --- at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x0049f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:392 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <6314851f133e4e74a2e96356deaa0c6c>:0 at System.Net.Http.HttpClient+d__48.MoveNext () [0x00080] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2159 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3189 at System.Threading.Tasks.Task.Wait () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3054 at Taxi.Mobile.Global.InitialSignalR () [0x00027] in E:\Projects\Projects_VS2015\Workspace\Taxi\Taxi.Mobile\Taxi.Mobile\Global.cs:27 ---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00017] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/Socket.cs:1773 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:513 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.EndReadOrWrite (System.IAsyncResult asyncResult, Mono.Net.Security.AsyncProtocolRequest& nestedRequest) [0x00056] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:335 at Mono.Net.Security.MobileAuthenticatedStream.EndRead (System.IAsyncResult asyncResult) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:278 at System.Net.WebConnection.ReadDone (System.IAsyncResult result) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/System.Net/WebConnection.cs:475 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1031 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <6314851f133e4e74a2e96356deaa0c6c>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <6314851f133e4e74a2e96356deaa0c6c>:0 at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x00406] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:388 --- End of inner exception stack trace --- at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x0049f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:392 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <6314851f133e4e74a2e96356deaa0c6c>:0 at System.Net.Http.HttpClient+d__48.MoveNext () [0x00080] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 <---}

firebase notification with xamarin forms

$
0
0

I've implemented firebase push notification in both android and ios,
on android it worked like a charm,
but, in ios (i am targeting ios 11.2) the following error occurd when build a release build(it worked when build a debug build)
the error is:

Native linking error: truncated fat file. Slice from 4611984 to 6449696 is past end of file with length 5144576 file '/Users/mohammadshaban/Library/Caches/Xamarin/mtbs/builds/HBRS.iOS/7757187b09de98f2bb163c41d580c1ef/obj/iPhone/AppStore/mtouch-cache/FirebaseMessaging' for architecture arm64

any ideas?

thanks in advance

Viewing all 77050 articles
Browse latest View live


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