Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to stop firing the parent click event when click on child

$
0
0

I have BoxView inside the Stacklayout and Stacklayout has the click event which changes the color of BoxView.
I don't have any click event on BoxView. Though If I click on BoxView it fires StackLayout click event.
How can I stop firing parent click event when clicking on child ? (I don't want to do anything when click on BoxView)


share Authentication access token

$
0
0

Hi
I Have xamarin forms application, authenticate with asp.net membership and give accesstoken after authenticate.
In other platforms (ex silverlight, javascrip libs ....), this token access shared accross all requests to server (ex webclient,httpclient, image source request and ...) and all requests send it to server automaticaly
how can I share this token on xamarin forms for all requests?
I cant set cookies for all requests handly. because some of them like imagesource does not have any way to set it

How to auto resize control out srollview when scrolling

$
0
0

Hi guy, how to auto resize control out srollview when scrolling like contact detail in ios?
i design 2 stacklayout, one contain control need resize and the other contain scrollview

like this:

any ideas and solutions

Cannot open storyboard

$
0
0

I have desperately tried to get Storyboards to display in Visual Studio 2017. They failed to display, so I upgraded to 2019. They still failed to display, but with a new error message. I tried 2019 Preview and still get the same error message. These problems occur both with my project and a simple test project generated by Visual Studio itself. How can I finally rid myself of these problems? What is the workaround in the meantime? Is there a way to remotely have Visual Studio display them on the Mac build machine?

https://developercommunity.visualstudio.com/content/problem/1002102/xamarin-cannot-open-storyboard.html

An error occurred while initializing the frame's content System.ArgumentException: 'ZoomMenu_100 ' is not a valid value for property 'Name'. at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at Xwt.WPFBackend.WidgetBackend.set_Name(String value) at Xwt.Widget.set_Name(String value) at Xamarin.Designer.VisualItems.ToolbarZoomBar.UpdateButtons() at Xamarin.Designer.VisualItems.ZoomBar.OnDesignerAttached() at Xamarin.Designer.VisualItem.set_Designer(DesignerSurface value) at Xamarin.Designer.DesignerSurface.InternalAddVisualItem(VisualItem item) at Xamarin.Designer.DesignerSurface.AddVisualItem(VisualItem item) at Xamarin.Designer.DesignerSurface.AddBar[TBar](TBar& storeBar, TBar bar, Point position) at Xamarin.Designer.DesignerSurface.SetZoomBar(IZoomBar bar) at MonoTouch.Design.Client.IPhoneDesignerWidget..ctor(IPhoneDesignerSession session, IPhoneDesignerSurface customSurface) at Xamarin.VisualStudio.IOS.Designer.MonoTouchDesignerPane.Initialize() at Microsoft.VisualStudio.Shell.WindowPane.InternalSetSite(IServiceProvider p) at Microsoft.VisualStudio.Shell.WindowPane.Microsoft.VisualStudio.Shell.Interop.IVsWindowPane.SetSite(IServiceProvider psp) at Microsoft.VisualStudio.Shell.WindowPane.Microsoft.VisualStudio.Shell.Interop.IVsUIElementPane.SetUIElementSite(IServiceProvider p) at Microsoft.VisualStudio.Platform.WindowManagement.UIElementDocumentObject.SetSite(DocumentObjectSite site) at Microsoft.VisualStudio.Platform.WindowManagement.DocumentObjectSite.InitializeDocumentObject(Object punkView) at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.InitializeDocumentSite(Boolean creatingStubFrame, Boolean replacingStubView, Object punkView, Object punkData, IServiceProvider pServiceProvider, IVsUIHierarchy pUIHierarchy, UInt32 vsid) at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.CreateContentPane(FrameMoniker frameMoniker, Boolean isDocument, String lpstrMkDoc, UInt32 eCreateWindowFlags, Object punkView, Object punkData, IServiceProvider pServiceProvider, IVsUIHierarchy pUIHierarchy, UInt32 vsid, Guid rguidCmdUI, ViewGroup parent, IVsWindowFrame& ppWindowFrame)

Master Detail Default Example

$
0
0

Hey guys, I want to know why in the new project with the master detail template there is a delay for android in the MainPage.xaml.cs and some especific code for iOS in the MainPage.xaml. I'm using the most updated version of visual studio 2019.

Here is the portion of MainPage.xaml:

<MasterDetailPage.Detail>
    <NavigationPage>
        <NavigationPage.Icon>
            <OnPlatform x:TypeArguments="FileImageSource">
                <On Platform="iOS" Value="tab_feed.png"/>
            </OnPlatform>
        </NavigationPage.Icon>
        <x:Arguments>
            <views:ItemsPage />
        </x:Arguments>
    </NavigationPage>
</MasterDetailPage.Detail>

Here is the portion of MainPage.xaml.cs:

public async Task NavigateFromMenu(int id)
{
    if (!MenuPages.ContainsKey(id))
    {
        switch (id)
        {
            case (int)MenuItemType.Browse:
                MenuPages.Add(id, new NavigationPage(new ItemsPage()));
                break;
            case (int)MenuItemType.About:
                MenuPages.Add(id, new NavigationPage(new AboutPage()));
                break;
        }
    }

    var newPage = MenuPages[id];

    if (newPage != null && Detail != newPage)
    {
        Detail = newPage;

        if (Device.RuntimePlatform == Device.Android)
            await Task.Delay(100);

        IsPresented = false;
    }
}

NavigationPage TitleView Template

$
0
0

I want it to look like the photo on the right.
How can I make distances between them?

Get pending AlarmManager items

$
0
0

I'm using the Alarm Manager to raise reminders for shortly into the future (i.e. 15 minutes to 2 hours) - setting and raising the alarms is going swimingly - no issues there - I set the alarm using this method:

public void AddReminder(long pSecondsInTheFuture, string pTitle, string pMessage)
{
    Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReceiver));
    alarmIntent.PutExtra("message", pMessage);
    alarmIntent.PutExtra("title", pTitle);

    PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);

    AlarmManager alarmManager = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);
    alarmManager.SetExact(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + pSecondsInTheFuture * 1000, pendingIntent);
}

cool - now I want to get the next soonest alarm (i.e. if there are several set, I want the one that will happen next). At first the "NextAlarmClock" call off the AlarmManager looked promising:

AlarmManager alarmManager = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);
 var oAlarm = alarmManager.NextAlarmClock;

However when I execute that I get "{Java.Lang.NoSuchMethodError: no method with name='getNextAlarmClock' signature='()Landroid/app/AlarmManager$AlarmClockInfo;' in class Landroid/app/AlarmManager;"

which is a little odd. So I moved on to using the PendingIntent framework like this:

var pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, new Intent(Forms.Context, typeof(AlarmReceiver)), PendingIntentFlags.NoCreate);

which works (i.e. returns null if no pending alarms and a PendingIntent if there is) - however I'm unable to figure out how to pull anything meaningful about the alarm using that PendingIntent - I really just want the "message" and "title" name value pairs I put on the intent when making the alarm and it's date time - I don't need to cancel it or edit it or anything of the sort, I just want to show what the next alarm is that will fire (currently mostly for debugging purposes).

Can anyone point me in the right direction? Something obvious I overlooked?
thanks.

Xamarin.Essentials reports wrong Orientation on emulator

$
0
0

I've created this very little application that should tell me the orientation of the device using Xamarin.Essentials. It works fine on my Huawei P30 Pro Phone. Is this an emulator related problem?

The Emulators are the Pixel_3_q_10_0_-_api_29 and tablet_m-dpi_10_1in_pie_9_0

Here's the code:

using System.ComponentModel;
using Xamarin.Forms;

namespace OrientationProblem
{
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            Xamarin.Essentials.DeviceDisplay.MainDisplayInfoChanged += DeviceDisplay_MainDisplayInfoChanged;

            Orientation.Text = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Orientation.ToString();
        }

        private void DeviceDisplay_MainDisplayInfoChanged(object sender, Xamarin.Essentials.DisplayInfoChangedEventArgs e)
        {
            Orientation.Text = e.DisplayInfo.Orientation.ToString();
        }
    }
}


<?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:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="OrientationProblem.MainPage">

    <StackLayout>
        <!-- Place new controls here -->
        <Label x:Name="Orientation"
               HorizontalOptions="Center"
               VerticalOptions="CenterAndExpand"
               FontSize="Large"/>
    </StackLayout>

</ContentPage>


Wrong AppIcon and splash screen on local device?

$
0
0

Hey there.

I made a custom AppIcon and SplashScreen. On Simulator - it's working fine. I see correct AppIcon and SplashScreen.
When I connect an iPhone to my machine, and debug to that local device, then it's using stock Xamarin app icon and splash screen.
If I remote debug to same iPhone over network, It shows correct app icon and no splash screen.

How to change DateTime AM PM format?

$
0
0
    DateTime Mor_Time = DateTime.Now;
            TimeSpan ts = new TimeSpan(10, 30, 0);
            Mor_Time  = Mor_Time .Date + ts;        // OutPut :  {5/22/2020 10:30:00 AM}

            DateTime Nigh_Time  = DateTime.Now;
            TimeSpan ts1 = new TimeSpan(10, 30, -1);
            Nigh_Time  = Nigh_Time.Date + ts1;      //OutPut :  {5/22/2020 10:30:00 AM}

I want to following Output format
Mor_Time = 5/22/2020 10:30:00 AM

Nigh_Time =5/22/2020 10:30:00 PM

AAR Bindings does not implement interface - help

$
0
0

I have created all my .gradle files (.jar and .aar) through Android Studio.

The .jar files compile to .dll files through the android bindings in Xamarin without any issues - and I can expand them in object explorer Visual Studio when including them as references.

My problem is with the .aar files.

I have the mapbox-android-core-1.4.0.aar file from the gradle in my Jars folder in Visual Studio.

The build action is set to "LibraryProjectZip" and under references I have included Xamarin.Android.Support.v7.AppCompat which then included all other android support dependencies.

The Android Compile version is Android 9.0 Android class parser: class-parse Android codegen target: XAJavaInterop1

When I build i get the following error:

Error CS0535 'FileUtils.LastModifiedComparator' does not implement interface member 'IComparator.Compare(Object, Object)'

The official Xamarin troublehsooting says I must add the managed return to metadata which I did as follows:

java.lang.Object

With this added it still has exactly the same error, so I am not sure where I am going wrong.

I added the following to the Additions folder:
LastModifiedComparator.cs - Not sure what the file name should be so I named it the same as per the error
inside this file:

public partial class LastModifiedComparator
{
public void Compare(Java.Lang.Object a, Java.Lang.Object b)
{
// IComparator.Compare(a, b);
}
}

I first of all cannot add the IComparator here - it says that:
Error CS0120 An object reference is required for the non-static field, method, or property 'IComparator.Compare(Object, Object)'

If I comment it out and try to do the bindings again -- I still get the does not implement interface error as above.

Build log says the following: First item might be of value
\Xamarin\Bindings\MapBox\XamBindings\Okes.Mapbox.Android.Core\Transforms\Metadata.xml(10, 4) warning BG8A04: matched no nodes.

I wonder why the matched no nodes is here? Have I not added it correctly?

What's the best and easiest way to implement PayPal in a Xamarin Forms App?

$
0
0

Hi guys,

I would like to allow paypal, what's a good and easy way to do in Xamarin Forms?

Best regards
Chris

App is not resuming, Refresh everytime with splash screen in physical device.

$
0
0

Hi
I am working an application which is working fine on simulator but app is not resume after installed ipa in physical device.
Tried with these in Appdelegate
public override void WillEnterForeground(UIApplication application)
{
base.WillEnterForeground(application);
}
public override void OnActivated(UIApplication uiApplication)
{
base.OnActivated(uiApplication);
}

Image Source always picking image from cache.

$
0
0

Hi , I am using Image control in Xamarin forms android app. Used at two places one on hamburger slider and another on a content page. i am resolving image from webapi and using the code below:
private void OnPresentedChanged(object sender, EventArgs e)
{

            ImgProfile.Source = new UriImageSource()
            {
                Uri = new Uri(Constants.ProfilePicUrl),
                CachingEnabled = true,
                CacheValidity = new TimeSpan(5,0,0,0)
            };
        }

I tried aove code with both the conditions CachingEnabled = true/false . Here is what I observed:

  1. CachingEnabled = False : Each time the image control flickers and reloads the image. I can see a time gap of second or two between image reload from web url. Similary in the slider menu.
  2. CachingEnabled = true: My image control keeps on displaying the cached version even if the url has newer/different image, as its profile page and user can change his/her profile image N times a day.

So #1 solves my problem but the flickering part is annoying. Also please note , profile image is taken and uploaded from camera so there no way of uploading a customized image with lesser size to eliminate the delay..

I hope , my problem is clear to you guys.

Is there a way to know if user rated app?

$
0
0

Hello,
I implemented rating functionalities for both iOS and Android. In iOS, I used SKStoreReviewController and in Android, users directed to the Playstore.
Is there a way to know if user rated the app? If yes how can I know the point(or stars) user rated my app?

I want to show rating pop-ups to user if user rated less than 4 stars to my app in earlier version. Is this possible in both platforms?


FreshMVVM - Tabbed Navigation ViewIsAppearing not getting fired on initial tab click

$
0
0

I have implemented tabbed navigation using FreshMVVM. When my app launches, I could notice that the 'ViewIsAppearing' method is getting invoked for all the tabs. If I switch to one tab, the 'ViewIsAppearing' in its ViewModel is not getting called. But if go to some other tab and switch back to this same tab, then it works. i.e. 'ViewIsAppearing' is not getting invoked in the initial tab change click. How do I make it invoke in the first attempt itself.
I have come across a github issue similar to this. Just adding for reference
github.com/xamarin/Xamarin.Forms/issues/3855

VS2019 the specified path file name or both are too long error !

$
0
0

Hi everyone !

I'm archiving to publish ios from my Xamarin forms project, but I get an error ;

I've put my project on a shorter path to fix this error. (In :C). But , I keep getting errors. Because I think archive files are being created in a very different place. I couldn't solve this problem. How do I move the archive files? Ultimately these files in AppData. Wouldn't it be a mistake to relocate them?

My project location

My project archive location

What should I do. Please help me !

Unable to use Toast, Activity Indicatior

$
0
0

I have a simple Xamarin Form app with a .net standard project and Android Project. I am facing a problem since day of development is that , I am unable to pull Toast and Activity Indicator on form. I dont know why. I tried almost all major plugins as well.

Here's my login code where I want to see a toast. I have used UserDialogs, Forms.Plugin etc and now using Plugin.Toast.

  protected void BtnLogin_Clicked(object sender, EventArgs e)

        {
            try
            {
                CrossToastPopUp.Current.ShowToastMessage("Message"); // Plugin.Toast package
                var userName = TxtUserName.Text.Trim();
                var password = TxtPassword.Text.Trim();
                userController.DoLogin(userName, password);
            }
            catch (NullReferenceException)
            {
                DisplayAlert("Mobile # and Password, both are required.", "JCAA", "OK");

            }
            catch (Exception ex)
            {
                DisplayAlert(ex.Message, "JCAA", "OK");
                Crashes.TrackError(ex);
            }


        }

GZip Decompression/Deserialisation from Mobile application side

$
0
0

Hi,

I am working on Xamarin forms and My app consume WEB API which used GZIP to compress data.
How can I decompress this.
HttpClientHandler httpHandler = new HttpClientHandler()
{
AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate
};

But this is not working. Please help me with the correct solution for this

Is there any Xamarin.Forms Camera2 sample that actually works, including all the features I need?

$
0
0

Hi,

for the past 12 months I've been looking into upgrading my Xamarin.Forms app that uses the deprecated Camera API in the android renderer to the new Camera2 API. I've tried many samples, but none of them were exactly what I needed. Some didn't work at all, some did, but were missing key features.

What do I need?
Pretty much a clone of the native camera app minus the camera settings. I need a camera view that is showing the photo preview, can take photos (take photo button) and has some additional information overlayed on top of the camera preview (just some TextViews).

The best of the samples I've found (the UNIT-23 sample) still wasn't as reliable as I'd like. It worked, however, sometimes it would just crash for no apparent reason and the stack trace wasn't very useful. The other ones either had fewer features implemented or were only Xamarin.Android examples.

The samples I've tried were (I can't post links, so here are the repository names):

  • The official Xamarin Camera2 Basic sample
  • The official Xamarin Camera2 Raw sample
  • UNIT-23/Xam-Android-Camera2-Sample
  • vtserej/Camera2Forms
  • HofmaDresu/AndroidCamera2Sample
  • thekeviv/CameraFeed

I've also searched this forum, Xamarin.Forms docs, StackOverflow, and Google with no 100% working results.

Is there an example that could help me achieve the thing I want?
Thank you

Viewing all 204402 articles
Browse latest View live


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