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

Internet Connection Status & Network Change Receiver in xamarin.forms by broadcast receiver.

$
0
0

I want to show internet status in a message with the help of toast using broadcast receiver.when user turn on mobile data or wifi then message should be show that wifi enabled or mobile data enabled with the help of toast using a broadcast receiver and when user turn off the mobile data or wifi then message should be show with the help of toast that no internet connection..



I use this code but this is not working properly..please suggest me for this scenario


Show pins on google map based on how far its maximized(zoom)

$
0
0

I want to achieve like you all know, google maps show country in normal view and whenever it maximized it showing city, and further streets, shops.
In my application i am showing pins, and i wanna show pins like, if 10 pins in nearest and its showing collide in normal view i just need to show one pin,
according to that, then i maximize it need to show multiple pins how far i zoom. How can i achieve this , please help me.

How to open one mobile app from another mobile app in Xamarin Forms ?

$
0
0

How to open one mobile app from another mobile app in Xamarin Forms ?

Is there how to debug xaml?

$
0
0

I have a xaml file and this file doen't work. But i don't know what's happening, then i ask: Is there how to debug this file? I need to know where is broken, where is issue. I use Visual Studio 2017 and Xamarin.Forms

xamarin forms linker and prism.dryioc

$
0
0

Soo, when we use Xamarin Forms, we want a small apk size. To achieve that we have Linker and Proguard.
But using Prism.Dryioc I got stuck, I really don't know how to properly setup my Link configuration file.

With this file(linker configuration) I just got a "System.TypeInitializationException: The type initializer for 'Registry' threw an exception."
Can someone help me to find the way to make Linker works?

Xamarin Forms: Hide a Stack While Scrolling a list

$
0
0

I have a Xamarin forms Page which is divided in 2 sections, the top 40% contains the Search controls inside a stack layout , the other 60% contains a list view. While scrolling the list view up i want to hide the Stack Layout at top covering 40% of the screen.

I achieved to implement scroll events of list from a reference on Stackoverflow and GitHub.

I am able to hide the stackLayout but there is lot of flickering. Any idea how can i stop the flickering? the output is not crisp and stable.

Cannot Crop or Resize Images on Windows Universal (UWP)

$
0
0

I have spent 2 days trying to resize and crop an image on UWP. I have it working on iOS and Android, but nothing seems to work on UWP. I am trying to use WritableBitmapExtensions from Nuget, but I cannot find the right combinations of calls to make it work. My left arm for a snippet showing how to:

byte[] image -> WritableBitmap.Crop -> back to image byte[]

This is a Xam.Forms project and I am trying to do the resizing in the Windows Universal project.

Thank you so much!

Line below group header

$
0
0

Can it be true that this bug still not have been corrected on Forms-iOS?
I use a custom listview renderer, if I remove separator line the lines between list view items disappear but below group headers the lines are still present. The lines are pure white, color can't be changed, and that is not very nice compared to my color palette on pages...
Please advice Xamarin crew.


Problem creating a renderer for a custom Switch using XamarinForms

$
0
0

So, I'm working on a Android app project in which I need to create a Switch control with customized text for the toggled options. I've tried creating a custom text Switch using a custom Renderer, but have had an exception whenever I try using my custom control.

I've created a custom TextSwitch control:

using System;
using AutoLogSchedulingMobile.Resources;
using Xamarin.Forms;


namespace AutoLogSchedulingMobile.CustomControls
{
    public class TextSwitch : Switch
    {
        public string TextOn
        {
            get { return "OK"; }
        }

        public string TextOff
        {
            get { return "NÂO OK"; }
        }
    }
}

And for the renderer:

using System;
using Android.Content;
using Android.Widget;
using AutoLogSchedulingMobile.CustomControls;
using AutoLogSchedulingMobile.Droid.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Switch = Android.Widget.Switch;

[assembly: ExportRenderer(typeof(TextSwitch), typeof(TextSwitchRenderer))]
namespace AutoLogSchedulingMobile.Droid.Controls
{

    public class TextSwitchRenderer : ViewRenderer<TextSwitch, Switch>
    {
        public TextSwitchRenderer(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<TextSwitch> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null)
            {
                this.Element.Toggled -= ElementToggled;
                return;
            }

            if (this.Element == null)
            {
                return;
            }

            var switchControl = new Switch(Context)
            {
                TextOn = this.Element.TextOn,
                TextOff = this.Element.TextOff
            };

            switchControl.CheckedChange += ControlValueChanged;
            this.Element.Toggled += ElementToggled;

            this.SetNativeControl(switchControl);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.Control.CheckedChange -= this.ControlValueChanged;
                this.Element.Toggled -= ElementToggled;
            }

            base.Dispose(disposing);
        }

        private void ElementToggled(object sender, ToggledEventArgs e)
        {
            this.Control.Checked = this.Element.IsToggled;
        }

        private void ControlValueChanged(object sender, EventArgs e)
        {
            this.Element.IsToggled = this.Control.Checked;
        }
    }

}

I am however getting a System.Reflection.TargetInvocationException whenever I try using this custom Switch control in any xaml page in my app. I'm not sure where the mistake is or if there is another way to implement a custom Switch with text using Xamarin forms. I'm attaching a copy of the output in a text file. I'd be grateful for any pointers.

How to show current slider value on thumb

$
0
0

Hello,

I checked the forum and did a search on the web but couldn't find something similar to what I want to achieve. Below is an image of what I want:
Image: vgy.me/0GUNVB.png

It's basically a slider where the current value is shown on the thumb.
Can it be done with custom renderers? If yes, is anyone have example project that I can examine the codes?

Thanks.

TabbedPage binding to SelectedItem - no response

$
0
0

I have the following in my xaml:

<TabbedPage SelectedItem="{Binding CurrentTab}">
<Children>
    <local:HomepageView />
    <local:OtherPageView />
</Children>
</TabbedPage>

In my viewModel I've got:

private Page currentTab;

    public Page CurrentTab
    {
        get
        {
            return currentTab;
        }

        set
        {
            currentTab = value;
            OnPropertyChanged("CurrentTab");
        }
    }

However, the binding never fires! Anyone know what needs to be done to make this work?

ListView and AlternatingRowBackground - How to Refresh?

$
0
0

I have a ListView of items, where i want the alternating rows to have a different background color.
I have achieved this, using a CustomConverter and then updating the BackgroundColor there.

Unfortunately, this is not updated after I delete an item from the Row.
Can anyone offer suggestions on how to force a Refresh or how to Trigger the Converter again?


I Added my Custom Converter as a Global Resources in my App.xaml file
<Color x:Key="BorderColor">#FF0000</Color>
<infrastructure:BackgroundConverter x:Key="bgColorPicker" OddRowColor="{StaticResource BorderColor}"/>

The Code for my BackgroundConverter class:
The ObservableProperty is a custom class the supplies the SetProperty function, to save code.

public class BackgroundConverter : ObservableProperty, IValueConverter
{
    Color _evenRowColor = Color.White;
    Color _oddRowColor = Color.Gray;
    public Color EvenRowColor
    {
        get { return _evenRowColor; }
        set { SetProperty(ref _evenRowColor, value, nameof(EvenRowColor)); }
    }

    public Color OddRowColor
    {
        get { return _oddRowColor; }
        set { SetProperty(ref _oddRowColor, value, nameof(OddRowColor)); }
    }

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        int index = 0;
        foreach (var itm in (parameter as ListView).ItemsSource)
        {
            if (itm != value)
                index++;
            else
            {
                return (index % 2 == 0) ? EvenRowColor : OddRowColor;
            }
        }
        return EvenRowColor;
    }

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

Google in App purchases in Amazon Store

$
0
0

Is it possible to use google in app purchases in amazon store? maybe just for basic usage for example in app purchases is for removing ads.
Or we have to implement Amazon in app purchases. Is there any xamarin plugin for that?

Performance - Embedded Images or Local images best

$
0
0

For better performance of the application (mostly for Android) which is best way (Embedded Images or Local images) to access the image file.

Help with Implementing google login

$
0
0

Hi,

I want to implement google auth so that I can upload files to google drive or identify user. Can any one help me providing any working resources.

I tired to use xamarin.auth. However, it does not support .net standard so I'm looking for other methods.

thanks in advance..


Details Page of MasterDetail setup not showing anything

$
0
0

I'm trying to implement a masters detail page, but the detail pages are not showing anything, even though the rest of it, including the menu works fine.

MastersDetail Page

         <?xml version="1.0" encoding="utf-8" ?>
         <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                      x:Class="Compas_Mobile.MasterDetailPage1"
                      xmlns:pages="clr-namespace:Compas_Mobile">
           <MasterDetailPage.Master>
             <pages:MasterDetailPage1Master x:Name="MasterPage" />
           </MasterDetailPage.Master>


             <MasterDetailPage.Detail>
             <NavigationPage>
              <x:Arguments>
                 <pages:MasterDetailPage1Detail />
               </x:Arguments>
             </NavigationPage>
           </MasterDetailPage.Detail>


        </MasterDetailPage>

MastersDetail Page CS

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;

        using Xamarin.Forms;
        using Xamarin.Forms.Xaml;

        namespace Compas_Mobile
        {
            [XamlCompilation(XamlCompilationOptions.Compile)]
            public partial class MasterDetailPage1 : MasterDetailPage
            {
                public MasterDetailPage1()
                {
                    InitializeComponent();
                    MasterPage.ListView.ItemSelected += ListView_ItemSelected;




                }

                private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
                {
                    var item = e.SelectedItem as MasterDetailPage1MenuItem;
                    if (item != null)
                    {
                        Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
                        MasterPage.ListView.SelectedItem = null;
                        IsPresented = false;
                    }

                    /*if (item == null)
                        return;

                    var page = (Page)Activator.CreateInstance(item.TargetType);
                    page.Title = item.Title;

                    Detail = new NavigationPage(page);
                    IsPresented = false;

                    MasterPage.ListView.SelectedItem = null;*/
                }
            }
        }

Master Page

        <?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="Compas_Mobile.MasterDetailPage1Master"
                     Title="Master">
            <StackLayout  x:Name="MasterStackLayout"  >
                <StackLayout Padding="0,10" HorizontalOptions="FillAndExpand" BackgroundColor="#d5dfe7">
                    <Image Source="compas_logo.png" Margin="0, 60, 0, 0" />
                </StackLayout>


                <ListView x:Name="MenuItemsListView"
                      SeparatorVisibility="None"
                      HasUnevenRows="true"
                      ItemsSource="{Binding MenuItems}">



                    <ListView.ItemTemplate>
                <DataTemplate>
                  <ViewCell>

                                <StackLayout Padding="15,10" HorizontalOptions="FillAndExpand">
                                    <Label VerticalOptions="FillAndExpand" VerticalTextAlignment="Center" Text="{Binding Title}" FontSize="20" FontFamily="Lato"/>
                                </StackLayout>
                            </ViewCell>
                </DataTemplate>
              </ListView.ItemTemplate>
            </ListView>


            </StackLayout>
        </ContentPage>

Master Page CS

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    using Xamarin.Forms;
    using Xamarin.Forms.Xaml;

    namespace Compas_Mobile
    {
        [XamlCompilation(XamlCompilationOptions.Compile)]
        public partial class MasterDetailPage1 : MasterDetailPage
        {
            public MasterDetailPage1()
            {
                InitializeComponent();
                MasterPage.ListView.ItemSelected += ListView_ItemSelected;




            }

            private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
            {
               if (item == null)
                    return;

                var page = (Page)Activator.CreateInstance(item.TargetType);
                page.Title = item.Title;

                Detail = new NavigationPage(page);
                IsPresented = false;

                MasterPage.ListView.SelectedItem = null;
            }
        }
    }

Detail Page

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage

        xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms"
                 xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
                   xmlns:local="clr-namespace:Compas_Mobile"
                 x:Class="Compas_Mobile.MasterDetailPage1Detail"
                 Title="Pulse Page">

                    <ContentPage.Content>
                        <StackLayout>
                            <Label Text="Contacts data goes here" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
                        </StackLayout>
                    </ContentPage.Content>



    </ContentPage>   

Detail Page CS

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    using Xamarin.Forms;
    using Xamarin.Forms.Xaml;

    namespace Compas_Mobile
    {
        [XamlCompilation(XamlCompilationOptions.Compile)]
        public partial class MasterDetailPage1 : MasterDetailPage
        {
            public MasterDetailPage1()
            {
                InitializeComponent();
                MasterPage.ListView.ItemSelected += ListView_ItemSelected;




            }

            private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
            {
               if (item == null)
                    return;

                var page = (Page)Activator.CreateInstance(item.TargetType);
                page.Title = item.Title;

                Detail = new NavigationPage(page);
                IsPresented = false;

                MasterPage.ListView.SelectedItem = null;
            }
        }
    }

Consuming a WCF web service

$
0
0

Hi,

I'm currently trying to consume a WCF web service from a PCL project. (using Visual Studio 2017 v15.2)

What I did :

I tried several things to add the service reference.
First, I tried the solution from the walkthrough (SLsvcUtil.exe) with no success. The tool throws an error :

Error: An error occurred in the tool.

Error: Object reference not set to an instance of an object.

Then, I tried adding the WS reference from VS2017 (Right-Click 'Connected Services' in PCL > Add Service Reference)
This seemed to work, all proxy classes are generated (the WSClient, ect), all methods correspond to the WS definition.
But when using the generated Client, the 'Completed' event throw an error :

System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.  Check InnerException for exc…

InnerException : There was an error on processing web request: Status code 404(NotFound): Not Found

Any help would be appreciated !

Best regards

Show Touches (iOS)

$
0
0

Hello,

I am trying to find a way to automatically show touches and gestures (iOS only) like this code is trying to accomplish:

http://forums.xamarin.com/discussion/50254/ios-show-touches-free-library

Seems easy enough to get working, but I have a feeling it wasn't designed for Xamarin Forms projects? Using the above code I can either get the touches to show OR get my app controls to respond to the touches (but never both at the same time).

Has anyone done anything similar? Is there a way to capture all touches (to be handled on one layer - the animation) and then pass the touches along so the app behaves as normal? I am trying to find a way to do it once and have it work with the entire application. I want to try and avoid doing special touch handling and animation on each page separately.

I have also tried using a custom UIWindow (along side the default one) and calling MakeKeyAndVisible(). I had SendEvent overridden and calling window.SendEvent(evt) where 'window' is the default UIWindow that Xamarin Forms creates. However, the touches are not received by the app controls.

I have a feeling I'm misunderstanding something so any help would be appreciated.

Thanks,
Kevin

xamarin form soap service help

$
0
0

I want to consume SOAP service through xamarin form, It seem like the way it consume web service from xamarin form is similar to window app. So I tried to consume the webservice but nothing work. It just crash right away without giving any error. Here is the code:

Myservice.WebServiceSoapClient myserv = new Myservice.WebServiceSoapClient();
LoginButton.Clicked += async delegate {
Customer customer = new Customer();
customer.getUsername =customer.getUsername;
customer.getPassword = customer.getPassword;

            myserv.CustomerLoginCompleted+= (object sender, CustomerLoginCompletedEventArgs e) => {

                    //**without code it will not crash but whenever I put any code in here, the app just crash**

            };
            myserv.CustomerLoginAsync(customer);

Any suggestion?

Android Application Crash | InTune Wrapper or SDK

$
0
0

Hi Team,

We are facing issue in android application developed using Xamarin forms. Normal APK is working fine, But facing crash issue when launching the app after build is wrapped using InTune wrapper tool.

We followed below two way to convert the InTune supported application.

Wrapped the application using the InTune wrapper tool after successfully create the APK in release mode. The steps are available in the below link to wrap the application.

https://docs.microsoft.com/en-us/intune-classic/deploy-use/prepare-android-apps-for-mobile-application-management-with-the-microsoft-intune-app-wrapping-tool
Integrated InTune SDK for Xamarin forms android application available as a Nuget package (Microsoft.InTune.MAM.Remapper.Tasks). Followed the steps which are available in the below link.

https://docs.microsoft.com/en-us/intune-classic/develop/intune-app-sdk-xamarin#enabling-mam-in-your-android-mobile-app / https://components.xamarin.com/gettingstarted/Microsoft.Intune.MAM/true
When trying the first way, the app did not launch and crashed. Please let me know if the second method is the correct approach and if it can be used to create apk for InTune environment.

Viewing all 58056 articles
Browse latest View live


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