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

Xamarin Live Reload Previewer is not connecting.

$
0
0

Hello everyone,
I'm trying to use Xamarin Live Reload Previewer but I'm not getting any success.

Desktop:
=> I am emulating a Windows 10 through Virtual Box.
=> I disabled the real Windows firewall and the emulator.
=> Both the actual device (which I use to build) and the computer are on the same wifi. (NOTE: I ping the device through the computer and the 2 talk).

Using the address "localhost: 1883" and opening a XAML file I get the following message: "Live Reload is enabled but not listening on localhost: 1883".

Searching a little on the internet I found some people stating that putting address "broker.hivemq.com:1883" will also work, however when I use this address I get the message: "Live Reload is enabled but not connected to broker.hivemq.com : 1883 ".

I have already uninstalled and installed but nothing comes into effect.

In another VM I have done a test and it worked normal.


Can we make a cross platform app for cab application like Ola and Uber?

$
0
0

If yes, then which type of libraries we add to it?

Global Styles with ONIDIOM not working on recent updates?

$
0
0

I recently upgraded my forms version for from 2.5.91635 to XF 3.0 and the global styles which I have defined stopped working . However styles with OnPlatform are working and styles which are having OnIdiom in it , its not working. I'm currently using .NEt standard?
Any idea?

Xamarin Forms Android showing Tabbed Page inside Master Details Page is showing blank empty screen

$
0
0

In my Xamarin Forms application I am having Tabbed Page as first Detail page of Master Details Page. So, while running my Droid application it is showing empty blank screen for few seconds and after that it is showing the correct Tabbed Page. However, if I run the same project in iOS it is not showing any Empty or blank screen; Tabbed page is rendering fast.

What I have tried

If I set any other normal Content Page as first Detail page instead of Tabbed Page means that page is rendering fast in Droid

and also I have tried after updating the Xamarin.Forms from v2.5.1.444934 to v3.1.0.697729 but no luck.

So, I confirmed that the Empty or Blank screen is showing in Droid App for few seconds because of Tabbed Page. Is there any work around to resolve the problem. Thanks in advance.

Xamarin.Auth in UWP

$
0
0

Hello,

I’m trying to implement Xamarin.Auth (OAuth 2) with Google in UWP.
After login, the browser close and I go back to my app but the event “Completed” is not fired.

Here is my code :

The “ButtonClicked” event of my “Google Login” button :

if (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.iOS)
{
App.OOAuth = new OAuth2Authenticator(App.CIdClientGoogleIOSUWP,
string.Empty,
"email",
new Uri(App.CUrlAuthorizeGoogle),
new Uri(App.CUrlRedirectGoogleIOSUWP.Trim()),
new Uri(App.CUrlTokenGoogle),
isUsingNativeUI: true);
}

App.OOAuth.Completed -= AuthGoogle_Completed;
App.OOAuth.Completed += AuthGoogle_Completed;

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(App.OOAuth);

My redirect url is custom : “com.XXXX.apps:/oauth2redirect”.

I added the right protocol in “Package.appxmanifest” :

  <Extensions>
    <uap:Extension Category="windows.protocol">
      <uap:Protocol Name="com.XXXX.apps" />
    </uap:Extension>
  </Extensions>

In “App.xaml.cs” of the UWP project, I overrided the OnActivated event :

protected override void OnActivated(IActivatedEventArgs args)
    {
        Frame rootFrame = Window.Current.Content as Frame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();

            rootFrame.NavigationFailed += OnNavigationFailed;

            Xamarin.Forms.Forms.Init(args);

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (args.Kind == ActivationKind.Protocol)
        {
            var protocolArgs = args as ProtocolActivatedEventArgs;
            rootFrame.Navigate(typeof(MainPage), protocolArgs.Uri);
        }
        else
        {
            rootFrame.Navigate(typeof(MainPage));
        }

        // Ensure the current window is active
        Window.Current.Activate();
    }

So, the redirection is Ok but my event “AuthGoogle_Completed” is not triggered.

Did I do something wrong ? Or did I miss something ?

Thanks in advance for your help.

Xamarin.Auth in UWP

$
0
0

Hello,

I’m trying to implement Xamarin.Auth (OAuth 2) with Google in UWP.
After login, the browser close and I go back to my app but the event “Completed” is not fired.

Here is my code :

The “ButtonClicked” event of my “Google Login” button :

if (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.iOS)
{
App.OOAuth = new OAuth2Authenticator(App.CIdClientGoogleIOSUWP,
string.Empty,
"email",
new Uri(App.CUrlAuthorizeGoogle),
new Uri(App.CUrlRedirectGoogleIOSUWP.Trim()),
new Uri(App.CUrlTokenGoogle),
isUsingNativeUI: true);
}

App.OOAuth.Completed -= AuthGoogle_Completed;
App.OOAuth.Completed += AuthGoogle_Completed;

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(App.OOAuth);

My redirect url is custom : “com.XXXX.apps:/oauth2redirect”.

I added the right protocol in “Package.appxmanifest” :

  <Extensions>
    <uap:Extension Category="windows.protocol">
      <uap:Protocol Name="com.XXXX.apps" />
    </uap:Extension>
  </Extensions>

In “App.xaml.cs” of the UWP project, I overrided the OnActivated event :

protected override void OnActivated(IActivatedEventArgs args)
    {
        Frame rootFrame = Window.Current.Content as Frame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();

            rootFrame.NavigationFailed += OnNavigationFailed;

            Xamarin.Forms.Forms.Init(args);

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (args.Kind == ActivationKind.Protocol)
        {
            var protocolArgs = args as ProtocolActivatedEventArgs;
            rootFrame.Navigate(typeof(MainPage), protocolArgs.Uri);
        }
        else
        {
            rootFrame.Navigate(typeof(MainPage));
        }

        // Ensure the current window is active
        Window.Current.Activate();
    }

So, the redirection is Ok but my event “AuthGoogle_Completed” is not triggered.

Did I do something wrong ? Or did I miss something ?

Thanks in advance for your help.

Xamarin.Auth in UWP

$
0
0

Hello,

I’m trying to implement Xamarin.Auth (OAuth 2) with Google in UWP.
After login, the browser close and I go back to my app but the event “Completed” is not fired.

Here is my code :

The “ButtonClicked” event of my “Google Login” button :

if (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.iOS)
{
App.OOAuth = new OAuth2Authenticator(App.CIdClientGoogleIOSUWP,
string.Empty,
"email",
new Uri(App.CUrlAuthorizeGoogle),
new Uri(App.CUrlRedirectGoogleIOSUWP.Trim()),
new Uri(App.CUrlTokenGoogle),
isUsingNativeUI: true);
}

App.OOAuth.Completed -= AuthGoogle_Completed;
App.OOAuth.Completed += AuthGoogle_Completed;

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(App.OOAuth);

My redirect url is custom : “com.XXXX.apps:/oauth2redirect”.

I added the right protocol in “Package.appxmanifest” :

  <Extensions>
    <uap:Extension Category="windows.protocol">
      <uap:Protocol Name="com.XXXX.apps" />
    </uap:Extension>
  </Extensions>

In “App.xaml.cs” of the UWP project, I overrided the OnActivated event :

protected override void OnActivated(IActivatedEventArgs args)
    {
        Frame rootFrame = Window.Current.Content as Frame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();

            rootFrame.NavigationFailed += OnNavigationFailed;

            Xamarin.Forms.Forms.Init(args);

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (args.Kind == ActivationKind.Protocol)
        {
            var protocolArgs = args as ProtocolActivatedEventArgs;
            rootFrame.Navigate(typeof(MainPage), protocolArgs.Uri);
        }
        else
        {
            rootFrame.Navigate(typeof(MainPage));
        }

        // Ensure the current window is active
        Window.Current.Activate();
    }

So, the redirection is Ok but my event “AuthGoogle_Completed” is not triggered.

Did I do something wrong ? Or did I miss something ?

Thanks in advance for your help.

Every time I start a new project I get "namespace could not be found 'App'" What am I doing wrong?

$
0
0

This just started happening. I'm not sure what to do. I've tried changing the namespace, and I get the same error with the new namespace. I would post an imgur link but it does not allow me to post a link. Can anyone walk me through this? Is Xamarin just broken?


Bottom Tabbed page issues

$
0
0

I am trying to use a bottom Tabbed Page for Xamarin Forms (Android).
I have this error message:
'IPlatformElementConfiguration<Android, TabbedPage>' does not contain a definition for 'SetToolbarPlacement' and no extension method 'SetToolbarPlacement' accepting a first argument of type 'IPlatformElementConfiguration<Android, TabbedPage>' could be found (are you missing a using directive or an assembly reference?)
Anyone have the same issue here?
looks like my 'Toolbarplacement' is missing

Xcode 9.4.1 seems to break Styles on iOS

$
0
0

I've upgraded from Xcode 9.2 to Xcode 9.4.1, and am finding that Styles defined in my App.xaml no longer work. There is a workaround, which is to create an OnPlatform resource for each setter. However, this is clearly not optimal!

Has anyone else observed this and got a better fix? It should also be logged as a bug I think. There is a similar bug here on GitHub.

It could be an iOS version problem - I'm using different simulators for the two Xcode versions, iOS 11.2 for Xcode 9.2 and iOS 11.4 for Xcode 9.4.1. I haven't tried changing simulators yet.

Edit - This is with Forms version 2.5.0.121934 and Xamarin.iOS version 11.12.0.4

Code to reproduce it is below.

App.XAML:

<Application.Resources>
        <ResourceDictionary>
            <OnPlatform
                x:Key          ="ButtonBackgroundColor"
                x:TypeArguments="Color"
                Android        ="#ff0180a5"
                iOS            ="#ff0180a5"
                WinPhone       ="#ff0180a5" />
            <OnPlatform
                x:Key          ="ButtonTextColor"
                x:TypeArguments="Color"
                Android        ="White"
                iOS            ="White"
                WinPhone       ="White" />
            <Style
                x:Key     ="StyleButtonWithPlatformSetters"
                TargetType="Button">
                <Setter
                    Property="TextColor"
                    Value   ="{StaticResource ButtonTextColor}" />
                <Setter
                    Property="BackgroundColor"
                    Value   ="{StaticResource ButtonBackgroundColor}" />
            </Style>
            <Style
                x:Key     ="StyleButtonWithPlainSetters"
                TargetType="Button">
                <Setter
                    Property="TextColor"
                    Value   ="White" />
                <Setter
                    Property="BackgroundColor"
                    Value   ="#ff0180a5" />
            </Style>
            <OnPlatform
                x:Key          ="LabelBackgroundColor"
                x:TypeArguments="Color"
                Android        ="Red"
                iOS            ="Red"
                WinPhone       ="Red" />
            <Style
                x:Key     ="StyleLabelWithPlatformSetters"
                TargetType="Label">
                <Setter
                    Property="BackgroundColor"
                    Value   ="{StaticResource LabelBackgroundColor}" />
            </Style>
            <Style
                x:Key     ="StyleLabelWithPlainSetters"
                TargetType="Label">
                <Setter
                    Property="BackgroundColor"
                    Value   ="Red" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>

Page:

    <ContentPage.Content>
        <StackLayout>
            <Label
                HorizontalOptions="Center"
                Style            ="{StaticResource StyleLabelWithPlainSetters}"
                Text             ="Label with plain setters" />
            <Button
                Style       ="{StaticResource StyleButtonWithPlainSetters}"
                Grid.Column ="0"
                Margin      ="20"
                WidthRequest="100"
                Text        ="Show Products"
                Command     ="{Binding ButtonClickCommand}" />
            <Label
                HorizontalOptions="Center"
                Style            ="{StaticResource StyleLabelWithPlatformSetters}"
                Text             ="Label with OnPlatform setters" />
            <Button
                Style       ="{StaticResource StyleButtonWithPlatformSetters}"
                Grid.Column ="0"
                Margin      ="20"
                WidthRequest="100"
                Text        ="Show Products"
                Command     ="{Binding ButtonClickCommand}" />
        </StackLayout>
    </ContentPage.Content>

Result using Xcode 9.4.1 - the top label and button don't use OnPlatform

Result using Xcode 9.2

Disable UI of the whole app

$
0
0

What DisplayAlert does to Disable UI of the whole app?

Not able to deselect xlabs radio button

$
0
0

Hi Guys,
I am using Xlabs radio button in my project i have followed the steps given in below link
https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/samples/XLabs.Samples/XLabs.Samples/Pages/Controls/RadioButtonPage.xaml.cs#L48

i am able to select the radio button but not able to deselect the radio button.
Here is my code

                <control:BindableRadioGroup x:Name="ansPicker"
                                     Grid.Row="1"
                                     FontName="AmericanTypewriter"
                                     SelectedIndex="{Binding ItemSelected}"
                                     TextColor="#3150af"
                                            CheckedChanged="ansPicker_CheckedChanged"
                                            VerticalOptions="Start" />

        ansPicker.ItemsSource = new[]
                {
                                "Red"         
                };

            private void ansPicker_CheckedChanged(object sender, int e)
            {
                var radio = sender as CustomRadioButton;


                if (radio == null || radio.Id == -1)
                {
                    return;
                }

                DisplayAlert("Info", radio.Text, "OK");
            }

Please help me to solve this issue

How to generate an image from a StackLayout

$
0
0

I'm brand new at Xamarin Forms and have been struggling in how to create an image from a StackLayout. I have a result page with some labels and i need to save them to a image.
Is that possible in Xamarin?

Command binding in button not working

$
0
0

Using Xamarin Forms with Visual Studio 2017.

Button click on iOS is not calling the Command action.

It works on Android but iOS not.

I am using Linker Behavior: Link All

This is my code:

XAML

 <StackLayout Orientation="Vertical" >
                                <Button x:Name="btnSignIn" Text="Log in" BackgroundColor="#0072BD" TextColor="White" FontSize="20" FontAttributes="Bold"  HorizontalOptions="CenterAndExpand" Command="{Binding LoginCommand}"/>
                            </StackLayout>

XAML.cs

public LoginPage()
    {
            InitializeComponent();         
            BindingContext = viewModel = new LoginPageViewModel();
            viewModel.Navigation = this.Navigation;
            PasswordEntry.Text = string.Empty;

            EmailEntry.Focus();
            EmailEntry.Completed += (s, e) => PasswordEntry.Focus();           
            switchRemember.Toggled += switchremember_toggled;
    }

ViewModel

            public LoginPageViewModel()
                {
                        RememberChecked = false;
                       LoginCommand = new Command(Login);          
                        IsBusy = false;
                }

    public async void Login()
        {

                if (Settings.IsConnected)
                {
                    IsBusy = true;

                  ..... //Complementary code

                    IsBusy = false;
                }
                else
                    ShowAlert("Failed connection", "Check your internet connection.");

        }

I tried the answer from @christopherpolska
https://forums.xamarin.com/discussion/88071/mvvmcross-not-binding-barbutton-click-event-on-device

but didn´t work for me.

How to put shadow (elevation) on android bottom tabs?

$
0
0

Hi guys! Im using the new Android platform specific bottom tabs (xamarin 3.1) as described here. But as background color of page and menu is the same, I would like to se a separator between them (divider). I know that Android has a "elevation" property but Im now figured out how to put it on tab render. Can someone help me with it?


Is it possible to center image/icon in Action bar on both Android and ios?

$
0
0

I'm trying to accomplish something similar to the image. Is this possible and how would you then do it?

How to identify mock location is enabled in android?

$
0
0
  1. I have written below code which always return 0.
    var isMock = Android.Provider.Settings.Secure.GetString(contentResolver, Android.Provider.Settings.Secure.AllowMockLocation);

HttpRequestException "Connection reset by peer" on web requests after updating app

$
0
0

Hi all,

We have a self-hosted Apple Enterprise Developer based iOS app that was released around six weeks ago. We're working on the next version of the app and are seeing problems when people update to the new test version. An HttpRequestException is thrown with a message that reads "Connection reset by peer" whenever calls over HTTPS that include a bearer token are made. The call stack shown in the MS App Center error report provides very little info to go on:

Main thread
System.Net.Sockets
Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags)
System.Net.Sockets
NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size)

The initial web request to sign the user in appears to be working. It is the only request that doesn't include a bearer token in the headings. All subsequent requests in a given session cause this exception to be thrown.

We have found that users can resolve the error by removing the currently released version of the app from their phone before installing the new version. The error no longer occurs in the new version once that is done. We've also received a couple of reports of users getting the error even without upgrading the version of the app. It seems to occur for those users after not having used the app in a while.

We have tried to reproduce the error by following the same steps of installing the new test version on top of the released version on our devices and it works fine.

Our project manager has the issue on her personal device. She has been testing new versions without upgrading to see if the exception is no longer thrown. We have tried the following to resolve the problem without success:

  • Removed all local caching of previous web request results, forcing live requests at all times
  • Switching from the iOS NSUrlSession implementation of HttpClient back to the default managed implementation
  • Verifying the HttpClient base URI and individual request URIs are what are expected
  • Verifying the bearer token value is assigned to the HttpClient Authorization default headers when the calls are made

Has anyone had this happen to them, or maybe can shed some light on possible causes of this exception being thrown? Thanks a ton for any help provided. It is driving us crazy! :smile:

Required CCAvenue payment Integration for Xamarin form

$
0
0

I have create xamarin application and need for ccavenue payamnt integration for xamarin forms. Please help me for any idea related to payment gateway integration

How to display video from database

$
0
0

Hi Xamarin forum how can I call my vid from database then into my video player

Viewing all 79144 articles
Browse latest View live


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