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

UI Stops updating when navigating back to a page only on Android 5.1.1

$
0
0

For some reason when I leave a page and then navigate back to it. When I try to type in an Entry or select from a Picker, the value is not displayed on the UI. The keyboard still appears and I can see the text in the autocomplete but the UI remains blank.

This doesn't happen on Android 6.0

The page in question looks like this

    <Image x:Name="ImageUpload" Source="Upload"/>

    <Label x:Name="labelUpload" Text="" HorizontalOptions="Center"
        VerticalOptions="Center"/>

    <StackLayout Orientation="Vertical" Margin="20, 0, 20, 0">
        <ActivityIndicator x:Name="spinner" IsRunning="True" IsVisible="False"/>
        <ProgressBar x:Name="uploadProgress" IsVisible="False" Margin="30, 0, 30, 0" Progress="{Binding uploadProgress}"/>
        <Label HorizontalOptions="Center" x:Name="status"/>
    </StackLayout>

    <StackLayout Margin="20, 0,0,0" Orientation="Horizontal">
        <Label VerticalOptions="Center"  Text="Fail Reason"/>
        <Picker HorizontalOptions="FillAndExpand"  ItemsSource="{Binding Reasons}" x:Name="FailReason"></Picker>
    </StackLayout>
    <StackLayout Margin="20, 0,0,0" Orientation="Horizontal">
        <Label VerticalOptions="Center"  Text="Additional Comments"/>
        <Entry HorizontalOptions="FillAndExpand" x:Name="Comment" />
    </StackLayout>
    <Entry HorizontalOptions="FillAndExpand" x:Name="Comment" />


    <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
        <Label VerticalOptions="Center" Text="Attach additional files"/>
        <Button Clicked="OpenFileExplorer" Text="Add"></Button>
    </StackLayout>

    <ListView x:Name="files" ItemsSource="{Binding files}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.ContextActions>
                        <MenuItem Clicked="RemoveImage" CommandParameter="{Binding .}" Text="Delete"/>
                    </ViewCell.ContextActions>
                    <StackLayout Orientation="Horizontal">
                        <Image  Source="{Binding thumbnail}"></Image>
                        <Label Text="{Binding fileName}" FontSize="18"/>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</StackLayout>

Datepicker: How to override done button clicked of datepicker in xamarin android?

$
0
0

I want to override done button clicked, dont wanna use dateselected event.
In iOS i have done, but dont no how to do in android.

Date changing During Selection in DatePicker in iOS App.

$
0
0

Hi , i added a Date Picker for Page .in iOS App its working fine , but When am going to Select Date in Date Dropdown , Date Selected Automatically During Dropdown Scrolling .
In iOS Date Dropdown also Show Done option .
is it Possible to Select date only after Done option Click ?

Problem Android HttpClient SSL certificate can't find path file.

$
0
0

Hello,
My compagnie have changed the certificate this week and since, android version of my app does not work anymore. The certificate work and it is an official certificate.

        public static async Task<Tuple<bool, string>> get(Dictionary<string, string> parameters, string key_url = "")
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                // Return soit la liste en string get soit une chaine vide
                parameters.Add("device", Global.Device.UID);
                parameters.Add("version", Global.Version);
                parameters.Add("device_model", Global.Device.Model);
                parameters.Add("os_name", Global.Device.OSName);
                parameters.Add("os_version", Global.Device.OSVersion);
                parameters.Add("datetime", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));
                if(Global.User != null && !parameters.ContainsKey("login"))
                {
                    parameters.Add("logon", Global.User.Login);
                    parameters.Add("login", Global.User.Login);
                }

                string s_parameters = convertParametersToString(parameters);

                //Debut de la requête
                //var handler = new ModernHttpClient.NativeMessageHandler();
                //handler.ClientCertificateOptions = ClientCertificateOption.Automatic;
                using (var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) })//new ModernHttpClient.NativeMessageHandler()
                {
                    //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", OAuth.token);
                    client.DefaultRequestHeaders.Host = Global.Url.Replace("https://", "").Replace("http://", "").Replace("/", "");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = new HttpResponseMessage();
                    try{

                        response = await client.GetAsync(Global.Url + key_url + "?" + s_parameters);
                    } catch (Exception exceptionss)
                    {
                        string testttt = "test";
                    }

                    string result = await response.Content.ReadAsStringAsync();

                    if (response.IsSuccessStatusCode)
                    {
                        return new Tuple<bool, string>(true, result);
                    }
                    else
                    {
                        if((int)response.StatusCode == 503)
                        {
                            return new Tuple<bool, string>(false, "503 : " + result);
                        }
                        else
                        {
                            return new Tuple<bool, string>(false, result);
                        }
                    }

                }
            }
            else
            {
                return new Tuple<bool, string>(false, "no internet");
            }
        }

**ERROR : **

{Javax.Net.Ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. ---> Java.Security.Cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. ---> Java.Security.Cert.CertPathValidatorException: Trust anchor for certification path not found.
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0 at ModernHttpClient.NativeMessageHandler+<SendAsync>c__async0.MoveNext () [0x00428] in /Users/paul/code/paulcbetts/modernhttpclient/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs:135 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at GestionnairesCopro.Models.WebService+d__0.MoveNext () [0x0022c] in /Users/msaunier/Documents/GestionnairesCopro/GestionnairesCopro/GestionnairesCopro/Models/WebService.cs:49
--- End of managed Javax.Net.Ssl.SSLHandshakeException stack trace ---
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:242)
at com.squareup.okhttp.Connection.connect(Connection.java:159)

Thanks for your help.

Seperating the Xamarin Forms ToDoItemManager into multiple Managers to add some structure

$
0
0

My app started off as the 'TodoItem' example app which consisted on a single ToDoItemManager, which defines the MobileServiceSyncTable, syncs the tables in the SyncAsync() method and also consists of methods which are called in the app (for example SaveTodoItem() and GetAllTodoItems()) which consist of CRUD operations on the local tables.

The issue is that this single 'ToDoItemManager' is starting to get a bit messy, because it is getting bigger and bigger every time some new functionality is added. Has anyone had much experience in with dealing with this scenario, and what's the best way to go around separating the Managers, when queries consist of joins with multiple tables.

Button.ContentLayout on Android

$
0
0

I am trying to create a button with an image to the left of the text. The text and image should be centered within the button, and it should have some padding in between. I am using the ContentLayout attribute. It looks as expected on iOS with Left,10; however, on Android the image is always hugging the left edge of the button.

Has anyone written a renderer that can properly adjust the padding between the image and text? I looked at ButtonRenderer source code, and it looks like the CompoundDrawablePadding is being called which is supposed to handle the padding; however, it's not working. Bug in Xamarin Forms for sure, but is it a bug in Xamarin as well?

How to place icon before entry control

$
0
0

Hi all,

I would like design a login form like below image
Image1

This is what I've managed to do so far

I want to place an icon before entry control. I don't know how to achieve that design. Below is the code.

<StackLayout VerticalOptions="Center" HorizontalOptions="Center" Spacing="30">
  <custom:CustomEntry Placeholder="Username" x:Name="Entry_Username" FontSize="25" HeightRequest="40"></custom:CustomEntry>
  <custom:CustomEntry Placeholder="Password" x:Name="Entry_Password" IsPassword="True" FontSize="25" HeightRequest="40"></custom:CustomEntry>
  <Button Text="LOGIN" x:Name="Btn_Login" Clicked="SignInProcedure" TextColor="White" BackgroundColor="#006400"  WidthRequest = "400" FontAttributes="Bold" FontSize="25"></Button>
  <Button Text="ADD USER" x:Name="Btn_Add" Clicked="AddUser" TextColor="White" BackgroundColor="#006400"  WidthRequest = "400" FontAttributes="Bold" FontSize="25"></Button>
</StackLayout>

1) How to change entry border color onfocus?
2) Is it possible to apply any external theme to xamarin forms

Thanks!!!

Max length on Entry

$
0
0

Is there a way to limit the length of text in an Entry control? If not, is it planned to add this feature?


Android fix font size with custom label

$
0
0

I am working on xamarin cross platforms project.
How can I fix font size on Android and make sure font size will not change when user change device font size?
I tried to make custom label with adding new attribute or property but the problem is I have to use different font sizes like 14, 18, 22 and 26
My custom label is:
namespace MyProject.Controls
{
public class CustomLabel : Label
{
public string TextFontSize { get; set; }
public CustomLabel()
{
}
}
}

The problem I can not access TextFontSize which will handle font size to control it from Android project.
I tried to convert from sp to dp:
[assembly: ExportRenderer(typeof(CustomLabel), typeof(AndroidCustomLabel))]
namespace Library.Droid
{
public class AndroidCustomLabel : LabelRenderer
{

            protected override void OnElementChanged(
            ElementChangedEventArgs<Label> e)
            {
                base.OnElementChanged(e);

                if (Control != null)
                {
                    float textSize = Control.TextSize;
                    Resources resources = Control.Context.Resources;
                    DisplayMetrics metrics = resources.DisplayMetrics;
                    int dp = (int)(textSize / metrics.Density);
                    Control.SetTextSize(ComplexUnitType.Dip, dp );
                }

            }

        }
    }

Any other solutions or ideas?

SlideOverKit - Multiple Menu on same page

$
0
0

Hi! I've start using SlideOverKit for my application (targeting Android, iOS and UWP) and I find it very nice.
The only thing is I'd like to add more than one menu (e.g. a right drawer and a bottom one) on the same page.
From what I've seen that's not possible.
So, what I'm asking you (in particular @MichaelRidland, I guess :smile: - also, thanks man for this package) is if there is a workaround in order to make it happens.
Thanks,
Jacopo

Is there a way to position the center of an element somewhere?

$
0
0

More generically, I'd like to be able to set some anchored point (with center as 0.5, 0.5) to a specific location on the screen (instead of only positioning the top-left corner of an element all the time)?

Does Xamarin Forms support this?

This would be handy for building data visualizations and simple XAML-based games.

ACR User Dialogs not working in Android PCL

$
0
0

I am trying to use ACR User Dialog in my PCL Project. It works like a charm in my iOS project build but when I try to build my Android Project, it gives me the below error:

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'AndHUD, Version=1.2.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'AndHUD.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) TimPapp.Droid

I already have AndHUD 1.2.0 package installed in NuGet. Any idea what can be the reason? Appreciate any help.

map.MoveToRegion not working after updting xamarin.form version

$
0
0

I am facing the issue in my project after updating nugget packages and xamarin form 2.34.247,,in my project i displayed the custum map pin bind to the some addressed on map that comes firstly the region shown the pins at center using TK Custum map and xamarin .forms map,previously everything worked perfectly but after updating the packages pins were displayed on map but the MoveToRegion method not worked as intended (even the PinCallOutClick event bindable to CalloutClickedCommandProperty not fired. Any help can be great ful.

Could you please help with this Xamarin.Forms related survey that might result in a new team

$
0
0

Hello All,

This is a slightly different question to my usual, and I will be posting this in the Jobs forum too, but have included it here because it specifically relates to Xamarin.Forms .

The background to this is that I have joined a business accelerator program for startups. One of their suggestions, which I had been thinking about anyway, is that to speed up building the product that, rather than me doing most of the coding and outsourcing small bits, that I get some investment and hire a development team full-time. To investigate this option, I need to work out how much this would cost to do, so that I can present numbers to potential investors.

If you would like to help (it will take less than 10 minutes), particularly if you might be interested in being involved, could you please do the short survey at this address: https://johnhardman.typeform.com/to/RNep1P

Many thanks in advance,

John H.

Accessibility in XF

$
0
0

We have to stay in XF core 2.0.0 but I need to be able to have extra props on buttons, images, labels, etc... for the screen readers (talkback and voiceover) to read instead of the caption or text.
BTW, I'm new to Xamarin.
I've been reading up on bindable properties, but haven't found a tutorial/article that covers it completely.


Pre-release: Xamarin.Forms 2.3.5.256-pre6

$
0
0

We've pushed Xamarin.Forms 2.3.5.256-pre6 to NuGet and have begun QA in preparation for making this our next stable release.

To install the pre-release, check the pre-release option in your NuGet manager and install this version.

For some quick highlights, check out our blog announcement. Hint: Fast Renders for Android, ListView performance enhancements and fixes, and MacOS preview.

If you’ve got a bug to report, drop us a quick report here so we can troubleshoot in detail.

As you have performance specific feedback, please join the discussion in this performance specific thread.

Important notes

  • Xamarin.Forms is now compatible with .NET Standard projects! Not all build features may work.
  • Behavior change: Device.RuntimePlatform now returns WinRT on WinRT and UWP on UWP.
  • Behavior change: Using the new AutomationProperties may impact UI Test execution on Android. AutomationId, Name, and HelpText will all set the native ContentDescription property, with Name and/or HelpText taking precedence over AutomationId (Name and HelpText will be concatenated). This means that any tests looking for AutomationId will now fail if Name and/or HelpText are also set on that element. To work around this issue, please alter your UI Tests to look for the value of Name/HelpText in this scenario.
  • Behavior change: Calling Focus on a Picker on WinRT/UWP will now open the drop down.
  • Deprecation: Android IVisualElementRenderer.ViewGroup is now obsolete. Please use View instead.

2.3.5.256-pre6

  • 56795 - "DataTriggers do not work on UWP in RELEASE mode"

2.3.5.255-pre5

  • [Android] Dispose check before setting properties on Button (PR)
  • 36031 - "Button border not drawn on Android without a BorderRadius" (PR)
  • 57717 - "Setting background color on Button in Android FormsApplicationActivity causes NRE" (PR)
  • 57749 - "[UWP] After enabling a disabled button it is not clickable" (PR)
  • [Android] Dispose check on FastButtonRenderer to prevent crash (PR)
  • [Android] Set the Id field for Android Views created by Forms (PR)
  • 55588 - "Cannot open more than one ContextAction in different ListViews on IOS" (PR)
  • 56444 - "A small "dot" shows up as value in Android labels when the value is null/empty." (PR)
  • 56895 - "VS2017 stable - previewer exception crash- no method found Button_click on type" (PR)
  • 56896 - "ListViews for lists with many elements regressed in performance on iOS" (PR)
  • 57108 - "Fix possible crash on API 21+ at launch when using Holo theme and FormsApplicationActivity" (PR)

Release Notes

2.5.3.239-pre3

Release Notes

2.3.5.235-pre2

Release Notes

2.3.5.233-pre1

Release Notes

Would this list view be possible with out of the box Xamarin Forms?

$
0
0

I'm trying to figure out how close we can get to to this list view as far as interactivity (nested grouped list views)

The root assembly conflicts with another assembly

$
0
0

Hi, after updating my Xamarin for Visual Studio it shows

Severity Code Description Project File Line Suppression State
Error The root assembly /Users/focus/Library/Caches/Xamarin/mtbs/builds/Sample.iOS/f4117d8ec82f837c5c099ce86166d4d3/bin/iPhoneSimulator/Debug/Sample.iOS.exe conflicts with another assembly (/Users/focus/Library/Caches/Xamarin/mtbs/builds/Sample.iOS/f4117d8ec82f837c5c099ce86166d4d3/bin/iPhoneSimulator/Debug/Sample.iOS.exe).

while building the ios project help me for solving this.
Thank you.

Tap on a item in a listview and open new page

$
0
0

So i have a list view like so:

<ListView x:Name="curso" ItemSelected="CursoView_ItemSelected" SelectedItem="{Binding SelectedItem}" HasUnevenRows="True">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.View>
                    <StackLayout Orientation="Horizontal">
                        <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">
                            <Label StyleClass="Header" Text="{Binding name}" />
                        </StackLayout>
                    </StackLayout>
                </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>


This list view is populated by a info from a webserver. For now it was 3 itens and i want to when a user taps on one item it opens a page related to that item. How can i do that in the codebehind?

XF native embedding - What is the syntax to tell an Android Fragment to MATCH_PARENT?

$
0
0

Xamarin.Forms PCL project.
ContentPage has an Android Fragment on it using Native Embedding.
I think the fragment is technically working, in that the native engine initialization callback responds with ERROR.NONE, and I can use the API calls that get initialized when the fragment initializes.
The problem is that the fragment has a size of 0,0.

I can set the container size. I cannot for the life of me find any documentation in any of the Xamarin write-ups on how to set the LayoutParameters of the fragment to MATCH_PARENT so it will expand to fit its container.
There's some limited examples of sending x:Arguments, but I'm just guessing in the dark about DataType and parameter casing. The permutations are almost endless.

Per examples: The native MapFragment has been subclassed to "NokiaMapView in order to call Initialize(), create Android Listeners, subscribe to callbacks etc. So NokiaMapView` in the example below is a fragment derived from the native fragment; as shown then the available tutorials.

This is just a small sampling of my attempts. I have a huge amount of commented markup with various combinations and permutations of attempts that all fail at runtime with errors same or similar to the commented error here.

<views:View x:Name="mapWrap"  x:Arguments="{x:Static androidForms:Forms.Context}">
  <androidLocal:NokiaMapView x:Arguments="{x:Static androidForms:Forms.Context}">
    <!--<androidLocal:NokiaMapView.Layoutparameters>
      <x:Arguments>
        <androidForms:Layoutparameters>MATCH_PARENT</androidForms:Layoutparameters>
      </x:Arguments>
    </androidLocal:NokiaMapView.Layoutparameters>-->
  </androidLocal:NokiaMapView>
</views:View>

<!--  06-23 15:04:21.095 I/MonoDroid(23792): Xamarin.Forms.Xaml.XamlParseException: Position 273:25.
      Cannot assign property "LayoutParameters": Property does not exists, or is not assignable, or mismatching type between value and property  -->

@DavidOrtinau @JamesMontemagno @PierceBoggan
You've each written a tutorial or article on behalf of Xamarin for this new ability of embedding native elements in a PCL ContentPage - Do any of you have a technique, example or input on how to set this vital arguement?

~~~~

*Native Embedding references:
https://developer.xamarin.com/guides/xamarin-forms/user-interface/native-views/
https://blog.xamarin.com/adding-bindable-native-views-directly-to-xaml/
https://developer.xamarin.com/guides/xamarin-forms/user-interface/layouts/add-platform-controls/
https://blog.xamarin.com/unleashed-embedding-xamarin-forms-in-xamarin-native/

Viewing all 91519 articles
Browse latest View live


Latest Images

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