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

xamarin.forms custom url schemes?

$
0
0

Hi everyone!

I'm making an application that implements a payment gateway. When a payment is completed the payment provider returns a result url. This url can be set to be a custom url scheme such as: myapp://. For android and ios dealing with these links can be set in the androidmanifest and plist respectively.
Like so:
<activity android:icon="@drawable/Icon" android:label="RedirectActivity" android:name="walletapp.RedirectActivity"> <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="myapp" /> <del></del></intent-filter> </activity>
After which the activity specified in the manifest(RedirectActivity) will be started when a link with the custom scheme is clicked(directed to?).

So how would I go about implementing this in a xamarin.forms application(pcl)?


Multiple projects in same solution

$
0
0

I have a feeling that there is a very simple answer to this, but after trying a few different things without success and googling around for a while I decided to ask here. The situation is that I am building 4 different apps for 4 different clients, but the code base is essentially the same - all that changes is a few settings and some assets. I am using a .NET Standard solution, and right now I have an App.Android and an App.iOS project. What I want is essentially to have a list of projects (App_A.Android, App_B.Android, App_C.Android, etc) that all reference the same shared code base. What is the best way to go about this? Any recommendations for keeping the solution easily maintainable?

Thanks in advance, hope you have a nice day

Place patterns on polyline in iOS using Xamarin.forms.maps

$
0
0

Im using Xamarin.forms.maps and successfully getting the polyline but I want to get some patterns on it as arrows and not able to achieve it.
Can anyone please help me in solving this issue and my code is as below.

    formsMap.DrawPolyLine = () =>              
    {                 
    if (nativeMaps == null)               
    {                       
    nativeMaps = Control as MKMapView;                   
    }                   
    nativeMaps.OverlayRenderer = GetOverlayRenderer;
                CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[IOSMapViewModel.DeviceTrackData.Count];
                int index = 0;
                foreach (var position in IOSMapViewModel.DeviceTrackData)
                {
                    coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude);
                    index++;
                }

                routeOverlay = MKGeodesicPolyline.FromCoordinates(coords);
                if (nativeMap.Overlays != null)
                    nativeMaps.RemoveOverlays(nativeMap.Overlays);
                IMKOverlay overlay = routeOverlay;

                nativeMaps.AddOverlay(routeOverlay, MKOverlayLevel.AboveLabels);
            };
            nativeMap.GetViewForAnnotation = GetViewForAnnotation;
            nativeMap.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped;
        }
    }


    MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlayWrapper)
    {
        if (polylineRenderer == null && !Equals(overlayWrapper, null))
        {
            var overlay = Runtime.GetNSObject(overlayWrapper.Handle) as IMKOverlay;
            Foundation.NSNumber[] dashValues = { 3, 6 };
            polylineRenderer = new MKPolylineRenderer(overlay as MKGeodesicPolyline)
            {
                FillColor = UIColor.Orange,
                StrokeColor = UIColor.Orange,
                LineWidth = 3,
                Alpha = 1f,
                LineDashPattern = dashValues
            };
            //polylineRenderer.CreatePath();
        }
        return polylineRenderer;
    }

How can I get files belonging to a specific mail with OneDrive API using ADAL?

$
0
0

In the pcl project I used the Graph API to get my mails successful. I showed my mail's body in a webview, but I do not see the files sent with mail. How can I get files to be displayed in a special mail with the one drive API?

How trigger the DateSelected event of DatePicker only if the user tap on "Done" on iOS?

$
0
0

Hello,

How trigger the DateSelected event of DatePicker only if the user tap on "Done" on iOS?

Currently the event is triggered if you change the year, month or date

Best regards.

LoginPage doesn't work fine.

$
0
0

My App call the loginpage, but doesn't renderize.

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="Operacional.Views.LoginPage" BackgroundColor="#072638" NavigationPage.HasNavigationBar="False">
        <ContentPage.Content>
            <StackLayout>
                <Image Source="logoestaparlogin.png" Scale="0.6"></Image>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="0.8*"/>
                    </Grid.ColumnDefinitions>
                    <Entry Grid.Column="1" Grid.Row="0" IsPassword="False" x:Name="txtUsuario"  Text="27643580839" TextColor="White" />
                    <Image Grid.Column="0" Grid.Row="0" Source="personwhite.png" WidthRequest="40" HeightRequest="40" />
                    <Entry Grid.Column="1" Grid.Row="1" IsPassword="True" x:Name="txtSenha"  Text="123456" TextColor="White" />
                    <Image Grid.Column="0" Grid.Row="1" Source="lockedwhite.png" WidthRequest="40" HeightRequest="40" />
                </Grid>
                <Button Text="Entrar" x:Name="btnLogin"  BackgroundColor="#01E200" TextColor="#005400" BorderRadius="4"  Clicked="Login_Clicked" ></Button>
                <Label x:Name="lblErroLogin" TextColor="Red" ></Label>
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>

but in the xaml.cs file, this page inherited ContentPage, but in my .cs file isn't good. The class name ContentPage it is not green color.

public partial class LoginPage : ContentPage ===>>> HERE ISN'T GREEN COLOR
    {
        public LoginPage ()
        {
            InitializeComponent ();
        }

        public  void Login_Clicked(object sender, EventArgs e)
        {
            LoginService svc = new LoginService();
            LoginRS res = svc.Login(txtUsuario.Text, txtSenha.Text);
            if (res != null && res.Success  )
            {
                App.LooggedUser = res;

                //MasterDetailPage fpm = new MasterDetailPage();
                //fpm.Master = new MainPage(); // You have to create a Master ContentPage()
                //fpm.Detail = new NavigationPage(new Detail()); // You have to create a Detail ContenPage()
                Application.Current.MainPage = new MainPage();

                //await Navigation.PushAsync(new MainPage());
            }
            else if(res != null && ! res.Success)
            {
                lblErroLogin.Text = res.Exception;
            }
            else
            {
                lblErroLogin.Text = "Não foi possível realizar o Login, por favor verifique sua conexão com a Internet";
            }
        }


    }

Can I see that ContextActions starts on Android in Xamarin.Forms?

$
0
0

I want to prevent other items from clicking when ContextAction starts.

So when ContextActions is displayed I want to stop clicking on the ListView after receiving the event.

open source TreeView for Xamarin.Forms - looking for contributors

$
0
0

Hey Xamarin.Forms gurus!

I needed a TreeView control for Xamarin.Forms and couldn't find one, so I did a spike and came up with a working prototype and demo app.

It its current version, data binding isn't set up, and the item template for the node header isn't separated out, but I think the demo provides a really good sense of the potential of this approach to building a TreeView as a set of nested StackLayouts (TreeNodeView inherits from StackLayout).

There's a screen image that I checked in with the source code, and I designed the layout of the demo for my 7" tablet, but it should squeeze down okay to smaller devices.

Here's the github repository:
https://github.com/danvanderboom/Xamarin-Forms-TreeView

KEY POINT: If you're familiar with best practices in building custom controls for Xamarin.Forms and you're interested in shaping the future of an open source TreeView control, let me know!


How to Redirect to a specific Page through local notification tap in xamarin forms

$
0
0

Hi, am developing a xamarin forms application. i have implemented local notifications in the app. I have used xam.plugins.notifier to display the local notifications. How to navigate to a specific page when the user taps on the local notification? How can i generate an event to navigate to a specific page? Is this possible in xamarin forms? Can someone please help me out in this?

Crash when removing the last element of an ObservableCollection

$
0
0

Hi,
After a ot of debuging, I realize that my app crash when I remove the last element of an ObservableCollection.

I saw this post from 2012 : https://social.msdn.microsoft.com/Forums/en-US/fc353ec5-8037-4d5d-8980-23b31b6f017f/ui-crashes-after-last-element-of-observable-collection-is-removed?forum=winappswithcsharp

They say that this crash is known and it'll be patch in the next version. But 4 years after, this bug is still here.
Anyone find a solution to patch this or I should just use something else like an array and don't use ObservableCollecction anymore ?

GSM Conference/Multi-party call in Xamarin.Forms

$
0
0

My aim is to make a conference/multi-party call using GSM (not VOIP/SIP/video conference, etc...) using Xamarin.Forms. I know how to make a call to a single party using the Messaging plugin. I need to know how to merge single calls into one conference call. Any help you may provide will be much appreciated.

How to perform a delay in the App constrictor?

$
0
0

Hi,

I am using OneSignal in my app and I am initializing it in the App.Xaml.cs like this:

public App()
{
    InitializeComponent();

    OneSignal.Current.StartInit("xxxxxx-xxx-xxx-xxxxx-xxxxxxxxxxx")
        .Settings(new Dictionary<string, bool>() {
        { IOSSettings.kOSSettingsKeyAutoPrompt, false } })
            .EndInit();
}

After the OneSignal.Current.StartInit I want to make a delay for few seconds and then I want to run:

OneSignal.Current.IdsAvailable((playerID, pushToken) =>
{
    id = playerID;
    App.Current.MainPage.DisplayAlert("playerId", id.ToString(), "OK");
});

because it's faking to get the IdsAvailable that quick.

How can I do that please?

Thanks,
Jassim

buttons like windows phone for(to) xamarin.forms

$
0
0

Hi all,
How can i do a layout like below screenshot? Is possible to create buttons and insert label as shown?

Anybody knows any link or tutorial?

Exception thrown when binding to text property of Lable tag inside a grid viiw

$
0
0

Am new to Xamarin development. While developing a sample app below piece of code throws an error. Any help regarding what I am doing wrong is highly appreciated .

<Label Text="{Binding FuelDetailList[0].Type, Mode=OneWay}" TextColor="#626263" FontAttributes="Bold" Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />

Button IsEnabled Binding

$
0
0

The problem arises only on iOS platform. I have 4 buttons which should be enabled/disabled regarding to the parameter. For this to work I have a converter. When the page is first loaded I can see with debugger that the converter is used 4 timers for each button and it gives the correct boolean value. The problem is that the view is not correctly updated. If the value which defines how many buttons should be enabled is changed again then the view updates correctly. The android platform works without problem. If I change the IsEnabled to IsVisible and don't do any other changes, then the buttons are correctly visible also at the first time. What is the difference between IsEnabled and IsVisible when it comes to update the view?

Code for the Buttons and for the converter:

<Button
    Text="String1"
    IsEnabled="{Binding NumberOfStrings,
    Converter={StaticResource IntToBoolWithParameter},
    ConverterParameter=1}"
    Command="{Binding StringTapped}"
    CommandParameter="1" />

<Button
    Text="String2" 
    IsEnabled="{Binding NumberOfStrings,
    Converter={StaticResource IntToBoolWithParameter},
            ConverterParameter=2}"
    Command="{Binding StringTapped}"
    CommandParameter="2" />

<Button
    Text="String3" 
    IsEnabled="{Binding NumberOfStrings,
    Converter={StaticResource IntToBoolWithParameter},
            ConverterParameter=3}"
    Command="{Binding StringTapped}"
    CommandParameter="3" />

<Button
    Text="String4" 
    IsEnabled="{Binding NumberOfStrings,
    Converter={StaticResource IntToBoolWithParameter},
            ConverterParameter=4}"
    Command="{Binding StringTapped}"
    CommandParameter="4" />


public class IntToBoolWithParameterConverter : IValueConverter
{
    public object Convert(object value, Type targetType,
                object parameter, CultureInfo culture)
    {
        string strParam = parameter as string;
        int reference = 0;

        if (!String.IsNullOrEmpty(strParam))
        {
            Int32.TryParse(strParam, out reference);
        }

        bool answer = false;

        if (!value.Equals(null))
            answer = reference <= (int)value;

        System.Diagnostics.Debug.WriteLine(answer + " " + parameter);

        return answer;
    }

    public object ConvertBack(object value, Type targetType,
                        object parameter, CultureInfo culture)
    {
        return 0;
    }
}

Animate Listview item position change - Xamarin Forms

$
0
0
If I have a listview with items such as a leader board. What is the best way to take control of animations when positions on the leader board change?

I.e. When the item's position index changes in the listview.

How can i create event click like a button to grid

$
0
0

I have this grid layout

<ContentPage.Content>
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <BoxView Color="Red" Grid.Row="0" Grid.Column="0" />
                        <BoxView Color="Green" Grid.Row="0" Grid.Column="1" />
                        <BoxView Color="Green" Grid.Row="1" Grid.Column="0" />
                        <BoxView Color="Green" Grid.Row="1" Grid.Column="1" />

                        <BoxView Color="Green" Grid.Row="2" Grid.Column="0" />
                        <BoxView Color="Green" Grid.Row="2" Grid.Column="1" />
                        <BoxView Color="Yellow" Grid.Row="3" Grid.Column="0" />

                        <Label Text="Desvio" Grid.Row="0" Grid.Column="0" TextColor="White" FontAttributes="Bold"/>
                        <Label Text="Faturamento" Grid.Row="0" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>
                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ContentPage.Content>

each row/colum i need to create an event and each event will go call a rest service and to do something. How can i declare this events for each row/column?

Off topic - > how can i use RowSpan to design my layout in the example above?

Assertion error for ViewCell.Tapped

$
0
0

I'm getting a weird error for what feel like should be something straightforward. I have a ListView with a DataTemplate shown below. For some reason when I run this, and tap on a cell, it closes immediately with

Assertion at [Long Path]/xamarin-android/external/mono/mono/metadata/marshal.c:7928, condition `mono_method_signature (method)->pinvoke' not met

in the Output.
The XAML in question:

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell x:Name="_vcellBlock"
                              Tapped="_vcellBlock_Clicked">
                        <StackLayout x:Name="_stkCellBlock"
                                     Orientation="Horizontal">

                            <StackLayout Orientation="Vertical"
                                         HorizontalOptions="StartAndExpand">
                                <Label Text="{Binding Name}"
                                       FontSize="Medium"/>
                                <Label Text="{Binding Description}"/>
                            </StackLayout>

                            <Frame
                                WidthRequest="75"
                                Padding="0"
                                HorizontalOptions="End">
                                <Label x:Name="_lblListQty"
                                       Text="{Binding QuantityToString}"
                                       HorizontalOptions="Center"
                                       VerticalOptions="Center"
                                       FontSize="Large"
                                   />
                            </Frame>

                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>

_vcellBlock_Clicked is defined, but it doesn't seem to matter since break points put on the function are never hit. The assertion is killing it before the event handler ever gets called.

Edit: Other event handlers works fine (like those in the toolbar).

Additional edit: Swapping the event out for an ItemTappedEvent attached to the ListView "solves" the problem in the sense that it no longer fails the assertion. I'd still like to know why though.

Themes leaking WeakReferences (I think)

$
0
0

I've been spending a lot of time trying to track down memory leaks in our Xamarin.Forms app on Android. After a lot of blind alleys and false dawns, I think I may have come across something which is causing the problem.

Using Xamarin Profiler, I can see that as soon as I create a Style and apply it to a control (or in fact just an implicit style), we get Multiple WeakReferences remaining 'Live' - i.e. not garbage collected.

Note that I assume that the objects to which they refer have been GC'd (because the reference to the object is weak), but the WeakReferences themselves are remaining.

Now of course WeakReferences are small I know - but when you have hundreds created on every iteration of a page push/pop, then the memory adds up and we have a significant leak.

Here are the details.
Using Xamarin.Forms 2.3.4.270 (we haven't upgraded because we want to keep with known issues!)
Running on Android - physical device.

App.xaml:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:ProfiledFormsApp2;assembly=ProfiledFormsApp2" 
     x:Class="ProfiledFormsApp2.App">
    <Application.Resources>
        <ResourceDictionary>
            <Style TargetType="Label">
                <Setter Property="FontSize" Value="Large" />
                <Setter Property="TextColor" Value="Blue" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

Page XAML:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage Title="Plain Page" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ProfiledFormsApp2.PlainPage">
    <ContentPage.Content>
        <StackLayout>
            <StackLayout Orientation="Horizontal">
                <Label Text="Core Navigation"/>
                <Label Text="Number of items:" />
                <Label Text="{Binding ItemsCount}" />
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

When I navigate to the above page and back 3 times, we have the following WeakReference (and related) classes created - the screenshot below is from a Profiler snapshot.

Note we have 55 WeakReferences. Drilling into these shows:

What is interesting is that these WeakReferences seem to be created as part of Behavior and Trigger attaching. Looking at the call tree for the top one gives:

So it appears that the WeakReference was created as part of setting a BindableObject's value and the subsequent setting of the Style.

And it also appears that the WeakReference is still in memory and being referenced by something - the Behavior collection?

Using Profiler, I'm can see that we don't have Labels remaining un GC'd. It seems to be something in the Theme/Behavior/Trigger processing.

I haven't looked at the Xamarin.Forms code on GitHub yet - that might have to be my next action.

Has anyone observed this or got a solution?

@NMackay, @JohnHardman You may be interested in this as this could be the underlying cause of the memory leak I thought I observed some time ago and mentioned in a post here.

How can i load two or more image in the grid

$
0
0

I have this layout

<ContentPage.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>



            <BoxView BackgroundColor="Red" Grid.Row="0" Grid.Column="0"  />

            <Label Text="(-1M)" Grid.Row="0" Grid.Column="0" TextColor="White" FontAttributes="Bold"/>
            <Label Text="Desvio de Faturamento" Grid.Row="0" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>

            <BoxView BackgroundColor="Green" Grid.Row="0" Grid.Column="1" />

            <Label Text="80%" Grid.Row="0" Grid.Column="1" TextColor="White" FontAttributes="Bold"/>
            <Label Text="Ocupação" Grid.Row="0" Grid.Column="1" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>


            <BoxView BackgroundColor="Green" Grid.Row="1" Grid.Column="0" />

            <Label Text="75" Grid.Row="1" Grid.Column="0" TextColor="White" FontAttributes="Bold"/>
            <Label Text="Tickets Cancelados" Grid.Row="1" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>

            <BoxView BackgroundColor="Green" Grid.Row="1" Grid.Column="1" />

            <Label Text="956" Grid.Row="1" Grid.Column="1" TextColor="White" FontAttributes="Bold"/>
            <Label Text="Pendências" Grid.Row="1" Grid.Column="1" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>


            <BoxView BackgroundColor="Green" Grid.Row="2" Grid.Column="0" />

            <Label Text="56" Grid.Row="2" Grid.Column="0" TextColor="White" FontAttributes="Bold"/>
            <Label Text="Limpeza de Pátio" Grid.Row="2" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>


            <BoxView BackgroundColor="Yellow" Grid.Row="2" Grid.Column="1" />

            <Label Text="(-15)/30" Grid.Row="2" Grid.Column="1" TextColor="Black" FontAttributes="Bold"/>
            <Label Text="Check List" Grid.Row="2" Grid.Column="1" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="Black" FontAttributes="Bold"/>


            <BoxView BackgroundColor="Green" Grid.Row="3" Grid.Column="0" />

            <Label Text="37%" Grid.Row="3" Grid.Column="0" TextColor="White" FontAttributes="Bold"/>
            <Label Text="Prestação de Contas" Grid.Row="3" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>

            <StackLayout Spacing="10" Padding="10" VerticalOptions="Center">

                <Image Source="{local:ImageResource My_namespace.Images.ico-cobranca-mensalista.png}" Grid.Row="0" Grid.Column="0" >
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Tapped="OnTapGestureReconizerTapped" NumberOfTapsRequired="1"></TapGestureRecognizer>
                    </Image.GestureRecognizers>
                </Image>

            </StackLayout>

            <StackLayout Spacing="10" Padding="10" VerticalOptions="Center">
                <Image Source="{local:ImageResource My_namespace.Images.ico-contrato.png}" Grid.Row="0" Grid.Column="1" >
                    <Image.GestureRecognizers>
                        <!--<TapGestureRecognizer Tapped="OnTapGestureReconizerTapped" NumberOfTapsRequired="1"></TapGestureRecognizer>-->
                    </Image.GestureRecognizers>
                </Image>

            </StackLayout>

        </Grid>
    </ContentPage.Content>

the first image is loaded correctly, but others images don't load. Only the first image is shown. I did many attempts and i didn't get success.

Viewing all 58056 articles
Browse latest View live


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