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

FrameRenderer crash with Binding

$
0
0

Hy, i'd create a Android Custom control for frame to create a gradient background. It works fine if i set static color(StartColor and EndColor) but if i bind with converters, app crashes. This is my code:

Renderer

public class FrameGradientRenderer : VisualElementRenderer
{

   private Color StartColor { get; set; }
   private Color EndColor { get; set; }

protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
{
    var gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0,
           this.StartColor.ToAndroid(),
           this.EndColor.ToAndroid(),
           Android.Graphics.Shader.TileMode.Mirror);

    var paint = new Android.Graphics.Paint()
    {
        Dither = true,
    };
    paint.SetShader(gradient);
    canvas.DrawPaint(paint);
    base.DispatchDraw(canvas);
}

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

    if (e.OldElement != null || Element == null)
    {
        return;
    }
    try
    {
        var frame = e.NewElement as FrameGradient;
        this.StartColor = frame.StartColor;
        this.EndColor = frame.EndColor;
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(@"ERROR:", ex.Message);
    }
}

CustomControl:

public class FrameGradient : Frame
{

    public Color StartColor { get; set; }
    public Color EndColor { get; set; }

}

button back to my app in the background and when you resume it starts again

$
0
0

I am developing an app in Xamarin.Forms, before I was trying to make a master detail page to become my MainPage when I logged in to my app, this I have already achieved. Now I have the problem that when I use the button behind the phone my app is miimiza and goes to the background which is the behavior I hope, but when I return to my app does not continue showing my master detail page, but returns to my LginPage.

It is as if my app was running twice or at least there were two instances of LoginPage existing at the same time, this is because in my LoginPage I trigger some DisplayAlert according to some messages that my page is listening through the MessaginCenter and they are they shoot twice.

Can someone tell me how I can return the same to my app on the master detail page and not restart in the strange way described?
Thanks.

Need help debugging random crashes in GridCalc.cs

$
0
0

Hi, it's been a year or so that im getting random crashes in GridCalc, totally fail to repro, making it impossible for me to avoid. It's just random, on both iOS and Android, whatever forms version, being on latest atm.
Even worse, I cant seem to match Xamarin open source code i can find in inet with stacktrace lines numbers.
If anyone could could give me a direction to dig in, would be grateful for any clue:

12-12 16:08:53.456 I/MonoDroid( 7446): UNHANDLED EXCEPTION:
Thread started: <Thread Pool> #13
12-12 16:08:53.776 I/MonoDroid( 7446): System.NullReferenceException: Object reference not set to an instance of an object.
12-12 16:08:53.777 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.MeasureStarredRows () [0x0017c] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:530 
12-12 16:08:53.777 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.MeasureAndContractStarredRows (System.Double width, System.Double height, System.Double totalStarsHeight) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:403 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x00117] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:510 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002a] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:58 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.780 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.780 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198 
12-12 16:08:53.783 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
12-12 16:08:53.783 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.ScrollView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\ScrollView.cs:233 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:39 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.786 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.786 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x00110] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:165 
12-12 16:08:53.786 I/MonoDroid( 7446):   at Xamarin.Forms.AbsoluteLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00046] in D:\a\1\s\Xamarin.Forms.Core\AbsoluteLayout.cs:69 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x0014b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:263 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:223 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:798 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.Layout+<>c.<OnChildMeasureInvalidated>b__45_0 () [0x00080] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:380 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <ad2f15102b3a4d36b40e9b0cbc11c376>:0 
12-12 16:08:53.788 I/MonoDroid( 7446):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <ad2f15102b3a4d36b40e9b0cbc11c376>:0 

PK Phoo

$
0
0

I want to class Content page class from Android .cs Class.
I use StartActivity(new Intent(Application.Context, typeof(LoginPage)));
showing error message
"System.ArgumentException: type
Parameter name: Type is not derived from a java type
"
Someone knows the sloution??Hlep me.

How to remove blank space from scrollable tab menu?

$
0
0

I want scroll-able tabs in my xamarin.forms .net standard project. So i have set the tab mode to scrollable in Tabbar.axml file in xamarin.Android Project:

app:tabMode="scrollable" .

My issues is if there are only two tabs in entire tab menu, there is some blank space left after the last tab and all the tabs do not occupy the equal width within the screen. Does any have solution to this or better approach to make tabs scrollable in xamarin.forms.?

Position of InitializeComponent

$
0
0

I have question with regards to the position InitializeComponent in the App.xaml.cs ?

If I place InitializeComponent below the MainPage statement, the style.css styles will be be applied in all the pages. Is this a bug or work by design ? If it is a work by design then there should be a big warning in the Docs as I can cause hours or days of head banging to locate the issue.

public App()
{
InitializeComponent();

MainPage = new NavigationPage( new MyOwnPage());

}

<Application.Resources>
           <StyleSheet Source="/Assets/style.css"/>
 </Application.Resources>

Device.StartTimer async

$
0
0

Hi,

Is there any trick to use Device.StartTimer with async?

Device.StartTimer(TimeSpan.FromMinutes(1), async () =>
{
        await DisplayAlert("","","");
}

It doesn't compile: Cannot convert async lambda to delegate type Func

Any help?

Xamarin.Forms

$
0
0

Hi guys,
I'm trying to call a method in my MainPage.cs from the webview.
I read on some guide that you have to modify the manifest file specifying the intent-filter, but the error that I return is always the same:

NET::ERR_UNKNOWN_URL_SCHEME

and this is my manifest

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.ScanCustomer" android:installLocation="auto"> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" /> <uses-permission android:name="android.permission.CAMERA" /> <application android:label="ScanCustomer.Android"> <activity android:name=".MyUriActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="scanapp" android:host="com.companyname.ScanCustomer.MainPage" /> </intent-filter> </activity> </application> </manifest>

i call my method in webpage JS:

var tags = {
user_type: 'test'
};

window.location.href = 'ScanApp://alert?tags=tags';

and my method:

public void alert(string tags) { ..... }


Update a certain variable in code behind (xaml.cs) after an event is launched in another project.

$
0
0

Hello,

The context of the problem:

I'm developing a solution where I use the SerialPort class (System.IO.Ports) to Scan Barcodes through serial connection. This class is only available in UWP projects so I integrated this class with dependency service and I can use it from the main project. This class has an event ( DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) ) which successfully launches when i scan any barcode. No problem with this.

Problem:

The problem is that when i am running the app and from a certain view i scan something, the event launches (uwp) and i don't know how to program that this scanned value actualize the entry variable (in an xaml.cs file) I was when the event was triggered.

Any idea? I'm really stucked here

Thanks!

Upgarding to xamarin forms nightly version causes null reference exception

$
0
0

We have created a custom control and used customrender for converting it forms to native. We faced null reference exception only when using the 3.5.0.979221-nightly version and it works fine when using 3.3.0.912540. On further analysis we found that the null reference exception occurs in all Xamarin forms nightly version. Can any one please explain the difference between the Xamarin forms nightly version and normal xamarin forms version. We don't know what the reason for this. Could anyone please help to resolve the issue. The sample code is given below

public static IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid)
{
IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty);
if (render == null)
{
render = Platform.CreateRenderer(source);
source.SetValue(RendererProperty, render);
var p = PlatformProperty.GetValue(valid);
PlatformProperty.SetValue(source, p);
IsPlatformEnabledProperty.SetValue(source, true);
}

        return render;
    }

I have also attached the image showing the issue.

Binding to an element of an array (or List)

$
0
0

After much googling, I haven't found an answer to this.

I have an array of colors. I want to bind a Button's BorderColor to a specific element within an array.
What is the syntax to achieve this?

Xaml:

 BorderColor="{Binding ButtonColors[11], Converter={Services:ByteToBorderColourConverter}}"

ViewModel:

private List<byte> buttoncolors;

public List<Byte> ButtonColors
    {
        get => buttoncolors;
        set
        {
            buttoncolors = value;
            OnPropertyChanged();
        }
    }

...

ButtonColors[11] = (Byte)Data[3];

I've also tried implementing this with List, but it also doesn't work.
I think the xaml binding syntax is incorrect maybe?

System.FormatException: One of the identified items was in an invalid format.

$
0
0

Hi Everyone.
I am trying to make a location application on visual studio 2017. All of my code is running fine but at compile time I keep getting this error System.FormatException: One of the identified items was in an invalid format. Has anyone got any idea what it means? I will post code below

Thanks a million in advance

xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Plugin.Geolocator;

namespace Location
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();

    }

    private async void Location_Clicked(object sender, EventArgs e)
    {
        await getLocation();
    }

    private async Task getLocation()
    {
        var locationLocator = CrossGeolocator.Current;

        //gets locaton accurate to 20 meters
        locationLocator.DesiredAccuracy = 20;

        //if you do not recieve a location in 10 seconds the function will time out
        var position = await locationLocator.GetPositionAsync(TimeSpan.FromSeconds(10000), null, true);

        //gets the lattitude and longitude through the "position" then adding the value to the label txt lat and concerting it to a string.
        Lattitude.Text = "Your Lattitude is: " + position.Latitude.ToString();
        Longitude.Text = "Your Longitude is: " + position.Longitude.ToString();


    }

}

}

Binding to an element of an array (or List)

$
0
0

After much googling, I haven't found an answer to this.

I have an array of colors. I want to bind a Button's BorderColor to a specific element within an array.
What is the syntax to achieve this?

Xaml:

 BorderColor="{Binding ButtonColors[11], Converter={Services:ByteToBorderColourConverter}}"

ViewModel:

private List<byte> buttoncolors;

public List<Byte> ButtonColors
    {
        get => buttoncolors;
        set
        {
            buttoncolors = value;
            OnPropertyChanged();
        }
    }

...

ButtonColors[11] = (Byte)Data[3];

I've also tried implementing this with List, but it also doesn't work.
I think the xaml binding syntax is incorrect maybe?

Weird behavior when using MasterDetailPage ToolbarItems navigate to other pages

$
0
0

Hi guys, recently I met a problem when I am trying to navigate from MasterDetailPage to another pages via ToolbarItems.

Btw, sorry for my bad english ah...

Here is the first image which before I perform navigating, it working fine.

Here is the second image which after I perform navigating, as you can see the ToolbarItems "fly" to the top left corner.

I will really appreciate if you guys can help me out from this. Thanks a lot guys :smile:

MasterDetailPage XAML Coding
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="AMC.Common.pgeMainPage" xmlns:pages="clr-namespace:AMC.Common;assembly=AMC.Common"> <MasterDetailPage.ToolbarItems> <ToolbarItem Name="tbiQRScanner" Order="Primary" Icon="ic_action_scan.png" Priority="0" Clicked="tbiQRScanner_Activated" /> <ToolbarItem Name="tbiAuthenticator" Order="Secondary" Text="Authenticator" Priority="1" Clicked="tbiAuthenticator_Activated" /> <ToolbarItem Name="tbiActivation" Order="Secondary" Text="Activation" Priority="1" Clicked="tbiActivation_Activated" /> </MasterDetailPage.ToolbarItems> <MasterDetailPage.Master> <pages:pgeMainPageMaster x:Name="MasterPage" /> </MasterDetailPage.Master> <MasterDetailPage.Detail> <pages:pgeMainPageDetail /> </MasterDetailPage.Detail> </MasterDetailPage>

MasterDetailPage Behind Coding
`public pgeMainPage()
{
InitializeComponent();
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
}

    private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        try
        {
            var item = e.SelectedItem as clsMainPageMenuItem;
            if (item == null)
                return;

            //var page = (Page)Activator.CreateInstance(item.TargetType);
            //page.Title = item.Title;
            Detail = (Page)Activator.CreateInstance(item.TargetType);
            MasterPage.ListView.SelectedItem = null;
            IsPresented = false;
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("ListView_ItemSelected: " + ex.Message);
        }
    }

    private void tbiQRScanner_Activated(object sender, EventArgs e)
    {
        try
        {
            clsCommonFunction.LaunchQRScanner(this);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("tbiQRScanner_Activated: " + ex.Message);
        }
    }

    private void tbiAuthenticator_Activated(object sender, EventArgs e)
    {
        try
        {
            var objAuthenticatorPage = new pgeAuthenticator();
            NavigationPage.SetHasNavigationBar(objAuthenticatorPage, false);
            Navigation.PushAsync(objAuthenticatorPage);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("tbiAuthenticator_Activated: " + ex.Message);
        }
    }

    private void tbiActivation_Activated(object sender, EventArgs e)
    {
        try
        {
            var objActivationPage = new pgeSignUpActivation();
            NavigationPage.SetHasNavigationBar(objActivationPage, false);
            Navigation.PushAsync(objActivationPage);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("tbiActivation_Activated: " + ex.Message);
        }
    }`

How to get absolute path of a file stored in application?

$
0
0

Hello,

I am working on Xamarin.Forms application.

I have a folder named "ProjectsDoc" in my PCL project. There are two files in it - File1.pdf and File2.doc.

Now I need to get the path of these files and open them in the default app installed in user's phone when user click on specific button. I have checked over different posts/articles but could not find how to do so. Can you please help me how can I get the path of these files?

Thanks


Showing DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT when loading a page

$
0
0

Redirecting to App.g.i.cs when loading a page in xamarin UWP. Code control comes to the following if block.

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };
#endif

If I mouse over the e showing {Windows.UI.Xaml.UnhandledExceptionEventArgs}

I am not understanding what is the problem? Is this related to some error in XAML? This issue is only on the windows app, Android and IOS apps parts are working fine.

Thanks in advance :)

Keyboard is not hiding when click background in xamarin forms IOS

$
0
0

In the normal case of xamarin forms ios app, the keyboard is hiding when taps on the background. Also, scrolling works perfectly when the keyboard is on.

But when the page contains listview, the keyboard is not closing when background tap and scrolling is not working in the same case.

How can I fix this issue? I need to close the keyboard when clicking the background and need scrolling feature when the keyboard is on. Attaching a screenshot having listview and keyboard.

Wait for Device.BeginInvokeOnMainThread

$
0
0

Hello,

I have an interface IPicture which I uses on Android and iOS.

I implemented with dependecy service a way to save a photo in device.

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foundation;
using UIKit;
using System.IO;
using System.Threading.Tasks;
using System;
using Xamarin.Forms;


[assembly: Xamarin.Forms.Dependency(typeof(MyApp.iOS.Picture_iOS))]

namespace MyApp.iOS
{
    public class Picture_iOS: IPicture
    {
        public Int16 SavePictureToDisk(string filename, byte[] imageData)
        {
            var chartImage = new UIImage (NSData.FromArray (imageData));
            Int16 response = 0;


            Device.BeginInvokeOnMainThread (() => {


                chartImage.SaveToPhotosAlbum ((image, error) => {
                    //you can retrieve the saved UI Image as well if needed using
                    //var i = image as UIImage;
                    if (error != null) {
                        Console.WriteLine (error.ToString ());
                        response = 0;
                    } else
                        response = 1;
                });
            });

            return response;
        }
    }
}

My problem is that I need it to return a Int16 as response... but just after the Device.BeginInvokeOnMainThread runs...

I can't use await because it is void...

How I can do that?

Loading an Image from a Resource in xaml

$
0
0

I have a resource called biglogo.png added via the Resource menu and now it's in the Resources folder of my project.

I want to use it via xaml but neither

nor

seem to work. Is there a straightforward way to make it work?

Wait for Device.BeginInvokeOnMainThread

$
0
0

Hello,

I have an interface IPicture which I uses on Android and iOS.

I implemented with dependecy service a way to save a photo in device.

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foundation;
using UIKit;
using System.IO;
using System.Threading.Tasks;
using System;
using Xamarin.Forms;


[assembly: Xamarin.Forms.Dependency(typeof(MyApp.iOS.Picture_iOS))]

namespace MyApp.iOS
{
    public class Picture_iOS: IPicture
    {
        public Int16 SavePictureToDisk(string filename, byte[] imageData)
        {
            var chartImage = new UIImage (NSData.FromArray (imageData));
            Int16 response = 0;


            Device.BeginInvokeOnMainThread (() => {


                chartImage.SaveToPhotosAlbum ((image, error) => {
                    //you can retrieve the saved UI Image as well if needed using
                    //var i = image as UIImage;
                    if (error != null) {
                        Console.WriteLine (error.ToString ());
                        response = 0;
                    } else
                        response = 1;
                });
            });

            return response;
        }
    }
}

My problem is that I need it to return a Int16 as response... but just after the Device.BeginInvokeOnMainThread runs...

I can't use await because it is void...

How I can do that?

Viewing all 91519 articles
Browse latest View live


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