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

Not able to open url https://www.omh.ny.gov/ on iOS


Quickblox sdk - Authentication token is required error

$
0
0

Hello there,
I am trying to run quickblox sample chat application which I got from following link

https://github.com/QuickBlox/quickblox-dotnet-sdk

Issue here is, when I run the app, it fails to load base session and gives error such as "{"errors":["Token is required"]}". I tried to debug it but could not find the root cause of it.

(Example code is using Quickblox sdk 1.2.2, which I tried to upgrade to 1.2.7 as well but in that case also still that issue remains)

The method inside sdk uses service call to api (http://api.quickblox.com/session.json) for getting session, which I tried to call by using Postman (google chrome extension), in which case I was able to get the session in response. Strange it is.

Does anybody know what is wrong with the example?

Trust anchor for certification path not found.

$
0
0

Hi there,

I'm currently developing an app where (working with a third party) I make calls to their web service.

As part of this, I make a HttpClient (initialised with a new Xamarin.Android.NetAndroidClientHandler() for my Android testing), and after tweaking some request headers, await a response with client.GetStringAsync(targetURL).

With this all in a try catch, it get's caught in a catch with a java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

From what I can gather online, this means that the server is replying with an authentication certificate that isn't trusted. However, I know that the server has been issued with a certificate from a trusted CA, and have found the same type of certificate in the Android device's trusted CA Certificates.

Can someone assist me in getting this working? Some things I've been trying to work out that could help include:
1) Does a Xamarin cross-platform application use the Android devices trusted certificates, or (as it's built with Mono) does it have it's own certificate store somewhere?
2) Am I able to install a trusted certificate as part of the application?

Using the same HttpClient implementation as above, I am able to connect to generic sites like Google and Microsoft. So I don't think it's an issue with implementation, especially as the java exception seems to indicate is is connecting to the web service, just not with a trusted certificate.

Thanks

Custom Round Button with Image

$
0
0

Hello guys, i need your help.
I am using this code to create custom round buttons. Thanks to this code i create button with a certain image (this.SetBackgroundResource(Resource.Drawable.Keyboard);).
How can i change the image on the button using this code?
`class BtnWIthImage : ButtonRenderer
{
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = Math.Min(canvas.Width, canvas.Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
//Create path to clip
var path = new Path();
path.AddCircle(canvas.Width / 2, canvas.Height / 2, radius - 10, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Create path for circle border
path = new Path();
path.AddCircle(canvas.Width / 2, canvas.Height / 2, radius - 10, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = 5;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = global::Android.Graphics.Color.Transparent;
canvas.DrawPath(path, paint);
//Properly dispose
paint.Dispose();
path.Dispose();
return result;
}
catch (Exception ex)
{
}
return base.DrawChild(canvas, child, drawingTime);
}

                protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
                 {
                    base.OnElementChanged(e);

                     this.SetBackgroundResource(Resource.Drawable.Keyboard);

                   if (e.OldElement != null || Element == null)
                         return;
                    if ((int)Build.VERSION.SdkInt < 18)
                         SetLayerType(LayerType.Software, null);
                }
             }`

Can the dead period for TapGestureRecognizer be reduced?

$
0
0

Currently, TapGestureRecognizer in my Xamarin.Forms (only tested in UWP for now) appears to require ~1 second between taps. Is there any way to reduce this dead period or eliminate it?

iOS master detail going to a custom view (PCL project) - how do I get a back button?

$
0
0

Hello,

I am looking for some help/guidance on how to fix an issue I have. I have a master/detail view of topics->documents (change topic shows you a new list of documents in the detail pane). Once the user clicks a document I take them to an embedded PDF reader.

My problem stems from the way the PDF reader in then rendered:

A push navigation from the detail pane in iOS renders the PDF inside the detail view (which is wrong as I want it full screen) but a back button is visible and I can navigate back to the list. A simple push works fine on Android and windows but fails on iOS.

A pushmodal from the detail renders the PDF fullscreen but I cannot get a back button\nav bar to appear. What is the trick in getting a back button to appear on iOS to get you back to the correct place in a master/detail?

Many thanks

How to communicate bluetooth paired devices in Xamarin

$
0
0

Hi Any One please let me know process or sample code for getting Bluetooth paired devices in Xamarin.forms or if it will not support from PCL please suggest for from Native level i.,e separate Android(.Droid) and iOS(.iOS).

Webview certificate issue

$
0
0

Hello guys,

I'm having problems with a webview and certificates on my PCL project.
I tested only the android version, so we're talking about Xamarin.Android.

I'm getting this error ( only from that webview, chrome desktop does not prompt any error), trying to navigate to an HTTPS website.
07-03 07:52:06.624 I/X509Util( 2957): Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

The webview displays a white page and does not load anything.

What can I do now? Any suggestions?

Best Regards,


How to load Images in Xamarin Forms Listview with Asp.Net Web API from Sql Azure Database?

$
0
0

Hi Everyone !
I have a xamarin forms app in which I am trying to load images into listview with the help of Asp.Net Web API. API and Sql database are hosted on azure. Sql Azure database has some rows of data in it. When I run the app, text details from Sql Azure DB are shown in listview rows but images are not shown. This is becuase I might be doing it wrong. I have Product.cs model class from database that has a property for Image as shown below:
public byte[] Product_Image { get; set; }

Below is how i am getting data from server:

` public static async Task CallWebApiAsync()
{

        using (var client = new HttpClient())
        {
            client.BaseAddress = new Uri("http://fypapids.azurewebsites.net/api/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //GET Method
            HttpResponseMessage response = await client.GetAsync("Product");

                if (response.IsSuccessStatusCode)
                {
                    if (count < 1)
                    {
                        var products = await response.Content.ReadAsStringAsync();
                        var des = JsonConvert.DeserializeObject<List<Product>>(products);
                        foreach (var i in des)
                        {
                            // if(productsList==null)
                            productsList.Add(new Product()
                            {
                                Product_Name = i.Product_Name,
                                Total_Cash_Price = i.Total_Cash_Price,
                                Product_Image = i.Product_Image
                            });
                        }
                        count++;
                    }
                }

            else
            {
                await App.Current.MainPage.DisplayAlert("Failure", "Internal server Error", "OK");
                //return "";
            }
        }
    }`

API controller to fetch images is: http://fypapids.azurewebsites.net/api/Product . And ListView binding to codebehind is given as below:

                  <ViewCell  >
                    <StackLayout Orientation="Vertical" Spacing="10">
                        <Image Source="{Binding Product_Image}" HeightRequest="150" Aspect="Fill" />
                        <StackLayout Orientation="Vertical" Spacing="10">
                            <Label Text="{Binding Product_Name}" TextColor="Crimson"  HorizontalTextAlignment="Center" FontAttributes="Bold" FontSize="20"/>
                            <Label Text="{Binding Total_Cash_Price}" TextColor="Crimson"  HorizontalTextAlignment="Center" />
                        </StackLayout>
                    </StackLayout> </ViewCell>

With all this implemented, I can see text details and not the images. Please help me how to load images successfully and show in listviews.
Thanks

Exception 'System.NullReferenceException' in Xamarin.Forms.Platform.UAP.dll

$
0
0

Hi. I'm using Xamarin Forms (2.3.4.247) and I'm having an issue with Unhandled exception at 0x62DA6918 (Windows.UI.Xaml.dll) on Windows 10 Mobile. On other platforms (UWP in Windows 10 desktop, Android) all is ok.
Here my code:

private FirstPage firstPage; //it's i get from the constructor it's root page (NavigationPage = new NavigationPage(firstPage);)
private SecondPage secondPage = new SecondPage();
private ThirdPage thirdPage = new ThirdPage();
private async void ItemSelectedMethod()
{
        var root = App.NavigationPage.Navigation.NavigationStack[0];
        if (SelectedItem == Items[0])
        {
            if (!IsFirstChoose)
            {
                App.NavigationPage.Navigation.InsertPageBefore(firstPage, root);
                await App.NavigationPage.PopToRootAsync(false);
            }
        }
        if (SelectedItem == Items[1])
        {
            App.NavigationPage.Navigation.InsertPageBefore(secondPage, root);
            await App.NavigationPage.PopToRootAsync(false);
        }
        if (SelectedItem == Items[2])
        {
            App.NavigationPage.Navigation.InsertPageBefore(thirdPage, root);
            await App.NavigationPage.PopToRootAsync(false);
        }

        IsFirstChoose = false;
        rootPageViewModel.IsPresented = false;
}

So... When I choose thirdPage on WM10 and I return to firstPage, my app is crashed with unhandled exception at 0x62DA6918 (Windows.UI.Xaml.dll)/Exception thrown: 'System.NullReferenceException' in Xamarin.Forms.Platform.UAP.dll. On other platforms all works ok. Does anyone know why this is happening? When I choose secondPage and return to firstPage all is ok... And when I choose thirdPage and return to second all is ok... When secondPage is choosed I can choose firstPage....

The second thing: When I update Xamarin Forms to version 2.3.5.256-pre6 for the same code is throwing exception "System.ArgumentException: 'Cannot insert page which is already in the navigation stack'" on all platforms. It's a bug of Xamarin? On older version all works with Android/UWP Windows 10 desktop.

Error in getting result in login page. It is not storing inside the the model

$
0
0

private async void Button_Clicked(object sender, EventArgs e)
{
try
{
var res = await ApiClass.GetAsyncMethod(ApiClass.login + "?UserName=" + username.Text + "&Password=" + password.Text);
if (string.Equals(loginResponseModel.UserName, username.Text) && string.Equals(loginResponseModel.Password, password.Text))
loginResponseModel = JsonConvert.DeserializeObject(res);
await Navigation.PushAsync(new LmsPage());
}

catch (Exception ex)
{

        }
        }

Please help me

Issue with the DatePicker control.

$
0
0

Hello guys,
I am using date picker control. if I click on date picker by mistake, and click on 'Cancel' button, today's date get selected. The date control should be blank. I have bind nullable date.
Thank you.

ViewCell.ContextActions is not working for Xamarin.iOS.

$
0
0

Hello Guys,

I am using ListView control for listing some records.
Also I have used "ViewCell.ContextActions" for delete list item.
This is working fine on Android, but for iOS it is not working.

Whenever I will call the ListView page, the application does nothing also it is not showing any exception.

<ListView x:Name="list" ItemSelected="OnSelection" ItemTapped="OnTap" IsPullToRefreshEnabled="true" Refreshing="OnRefresh"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.ContextActions> <MenuItem Clicked="OnMore" Text="More" CommandParameter="{Binding .}" /> <MenuItem Clicked="OnDelete" Text="Delete" IsDestructive="true" CommandParameter="{Binding .}" /> </ViewCell.ContextActions> <StackLayout Padding="15,0"> <Label Text="{Binding .}" /> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

How to write a code for post request by calling Api

$
0
0

private async Task ApplyLeave_Clicked_1(object sender, EventArgs e)
{
try
{
ApplyLeaveRequestModel empid = new ApplyLeaveRequestModel();
empid.EmployeeId = loginResponseModel.Id;
var res = await ApiClass.PostAsyncMethod(applyLeaveRequestModel, ApiClass.Applyleave);
applyLeaveRequestModel = JsonConvert.DeserializeObject(res);
await DisplayAlert("Leave", "Leave Successfull", "OK");
}
catch (Exception ex)
{

        }

please help me

Getting image for contacts using Xamarin Forms


Installing CocosSharp.Forms via NuGet leads to Build Errors

$
0
0

Hi everyone, I just created an empty Xamarin.Forms project (shared code) in Visual Studio 2017. The project built and ran fine (debug x86, UWP, local machine).

I then added the CocosSharp.Forms and CocosSharp NuGet packages for Android, iOS, and UWP.

Now the project does not build (same configuration), with errors:

  • Type universe cannot resolve assembly: Xamarin.Forms.Platform.WinRT, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null
  • Cannot resolve Assembly or Windows Metadata file 'Xamarin.Forms.Platform.WinRT.dll'

I'm not sure how to interpret this. Does CocosSharp.Forms not support UWP?

Cheers,
Thomas

Versions:
CocosSharp.Forms Android, iOS, UWP v 1.7.1
CocosSharp Android, iOS, UWP v 1.7.1
Xamarin.Forms Android, iOS, UWP v 2.3.3.193

Looking for a TabbedPage with wraparound

$
0
0

Hello community!

I am looking for a behavior that I cannot seem to find in Xamarin.Forms. What I am looking for is a TabbedPage, that when a user swipes left on the last tab, the first tab i shown, and when a user swipes right on the first tab, the last tab is shown.

This functionality is quite simple to grasp, and is demonstrated (with arrows instead of swiping) in HTML here: https://www.w3schools.com/bootstrap/bootstrap_carousel.asp

Basically, the swiping will select the "next or first" and "previous or last" instead of just "next" and "previous".

I have tried to search for different permutations of "tab","carousel", "wrap","wraparound", but without luck.

Does anyone know of an existing plugin/extension/control, or how I would go about implementing such a behavior myself?

google maps

$
0
0

Hello developers,

Is there any example of as use google maps with place autocomplete and get current location?

'Pink' styling issues on Android

$
0
0

Hi,
I am seeing some strange styling effects on Android, my switches are a pink colour when toggled on - same issue as https://forums.xamarin.com/discussion/70907/forms-switch-doesnt-look-like-i-expected-on-android.
I applied an Effect to the switches to manually fix the colour but now I notice that the same pink is on the underline and blinking cursor on Edit boxes + the selected item in a List is bright orange (perhaps the same problem?). I installed the Light theme and it made no difference to this.

I read on another post that this is caused by Material Design implementation which is fine and well but surely it isn't right for apps to have this strange styling by default? Ando how do I remedy, must I add effects to every control has this issue?

UserDialogs.Instance.HideLoading not working on BeginInvokeOnMainThread

$
0
0

userdialogs not hiding . please tell me how to resolve this.

 Device.BeginInvokeOnMainThread(() => {
                        Application.Current.MainPage.Navigation.PushAsync(new Views.MasterDetailPage());
                        UserDialogs.Instance.HideLoading();
                    });
Viewing all 91519 articles
Browse latest View live


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