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

Custom base App Class

$
0
0

Hello all,

is there any way to derive the App class from a custom base class (of course that inherits from Xamarin.Forms.Application)?

I'm using visual studio and the autogenerated code in App.xaml.g.cs always refer to a global::Xamarin.Forms.Application no matter what I try to do?

Any advice?


HorizontalTextAlignment not working after 4.3.0.908675 update for android

$
0
0

After updating Xamarin.Forms to 4.3.0.908675 (or greater) from 4.2.0.910310, HorizontalTextAlignment = TextAlignment.Center no longer works for Entry views on Android. Labels and Pickers apparently, are not affected.

Any Ideas why?

open Webview links in external Browser if target is set to _blank

$
0
0

Hi,

i know how to open links in the external browser, but i want to do it only if the target of the link is set to _blank.
Any idea how to do that?

Thanks

Helge

What can I put into the blue area at top of app?

$
0
0

There's a blue rectangle above my first control in my pages. My question is whether I can put things, for example a menu or picture. Also, what is this are called? Here, the Xaml for my opening page (the blue rectangle is above the label with the text "Welcome to Rodney Pix":

<?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:local="clr-namespace:TestXamarinFormsProject"

         x:Class="TestXamarinFormsProject.MainPage">

<ScrollView>
    <StackLayout  x:Name="sl" Orientation="Vertical">
        <Label Text="Welcome to Rodney Pix" HorizontalOptions="Center"
       VerticalTextAlignment="Start" VerticalOptions="Start"></Label>

        <ListView x:Name="lstDirectories" ItemTapped="LstDirectories_ItemTapped"
                  SelectedItem="{Binding SelectedListItem,Mode=TwoWay}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>

                        <StackLayout Padding="5" Orientation="Horizontal">
                            <Label Text="{Binding FriendlyDirectoryName}" TextColor="Black"/>
                        </StackLayout>

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

    </StackLayout>

</ScrollView>


How to find the child controls from StackLayout dynamically ?

$
0
0

I am using Xamarin.Forms (PCL project). I have created the stacklayout with some child controls. How can I get any control from this stacklayout dynamically (like findbyName , findbyID or Type) ?

Open Source Zebra RFID SDK for Xamarin Forms

$
0
0

Hello,

Zebra Technologies have SDKs for their RFID Scanners on platforms including native iOS, native Android and Xamarin.Android however not for Xamarin.iOS or Xamarin.Forms.

We are currently building a Xamarin.Forms app which critically requires the use of the RFID Scanner (RFD8500 model to be precise) on iOS. Our understanding is that this can be achieved by creating an iOS Binding Library for Zebra's existing Objective-C iOS SDK. I have personally attempted to bind this library through two methods, one being the classic iOS Binding method and two, creating a local C# Nuget Package for consumption. Due to lack of Objective-C experience, both attempts were unsuccessful.

What we would like to know is:

  • Is what we are trying to do even possible? (i.e would a binding library be enough to get the RFID scanners to work with a .forms app)
  • If so, what is the scale of effort?
  • As we lack the technical skills for it, would anybody be up for getting involved in this Open Source? (doing the actual work)

I think this would be a great project to do as over the last few months, I have found that a LOT of developers/companies have suffered from this same issue.

Thank you
Ridhwan

How to execute javascript code in html source of Webview?

$
0
0

My app receives articles from wordpress, through a converter I clean the html code and then with StringBuilder I create the new html string that I feed to a WebView, here I'd like to add an ADV javascript widget (the script is external). Do you believe it is possible?

Only one page is showing in webview from Google docs

$
0
0

Hello,

I have a document in docs from Google , when page it is opening it is downloading with a progress bar and showing in a Webview.

For so far so good.

But when i make the document longer then one page it is only showing the first page ? and i can't scroll to the next page nr 2

<ContentPage.Content>
    <local:PinchToZoomContainer>
        <local:PinchToZoomContainer.Content>

            <ScrollView>
                <StackLayout>
                    <ProgressBar Progress="0.2"  
             HorizontalOptions="FillAndExpand"  
             x:Name="progress"  
                     ProgressColor="Maroon"
             IsVisible="True"/>
                    <WebView x:Name="Webview"  
         HeightRequest="1000"  
         WidthRequest="1000"  
         Navigating="OnNavigating"  
         Navigated="OnNavigated"  
         VerticalOptions="FillAndExpand"/>
                </StackLayout>
            </ScrollView>
        </local:PinchToZoomContainer.Content>
    </local:PinchToZoomContainer>
</ContentPage.Content>

`

`public Nieuwsbrief()
{
InitializeComponent();
Webview.Source = "https://docs.google.com/document/d/1JtPBbacWjjE1RnqT7MlliexLFk618iNS5yUBBCkh1bs/edit?usp=sharing";
}
protected async override void OnAppearing()
{
base.OnAppearing();

        await progress.ProgressTo(0.9, 900, Easing.SpringIn);
    }

    protected void OnNavigating(object sender, WebNavigatingEventArgs e)
    {

        progress.IsVisible = true;

    }

    protected void OnNavigated(object sender, WebNavigatedEventArgs e)
    {

        progress.IsVisible = false;

    }


}`

Force Change of android:textColor at runtime

$
0
0

I have the a TabbedPage Application and want to change the textcolor at runtime.

<Label Text="Color change works for this label, as i set textcolor" TextColor="{DynamicResource MyTextColor}"/>
<Label Text="but i want to have it work for all labels and other elements without DynamicResource=MyTextColor"/>

public partial class TabPage : ContentPage
protected override void OnAppearing()
{
    // this works
    Resources["MyTextColor"] = DarkTheme ? Color.Red : Color.Blue;

    // this does not work at runtime, textcolor defined in styles <item name="android:textColor">#43d5e6</item> does not update at runtime
    SetTheme(DarkTheme ? Resource.Style.MainTheme_Dark: Resource.Style.MainTheme_Light);
}

item name="android:textColor> is differently defined in MainTheme_Dark and MainTheme_Light and gets at once applied to new Pages (for example Navigation.PushModalAsync(new NavigationPage(new NewPage())), but it gets not applied to existing TabPage. I have to close my app and only afterwards, it correctly applies the new "item name=android:textColor> from the selected MainTheme.

How can I force to change android:textColor at runtime in the OnAppearing()-event?

Share from Xamarin Essentials mysteriously quit working after updates, but only on iPad on iOS13.2

$
0
0

I updated my iPad to 13.2, updated to latest XCode on my mac, updated VS, updated to XF 4.3.

I know, not smart.

Everything appeared to work, until I tried the SHARE function of my app on iPad. The pop-over does not appear. An older version of my app works OK, and the new version works OK on my iPhone running 13.1.3.

I did try rolling back XF to what I was using (since it was easy), no help there.

Oh, and well there's another part to this mystery. To share multiple files, I wrote my own code using the iOS api, including creating an Activity Vew Controller (the pop-over). This doesn't work either.

Is there some kind of iPad settings or Info.plist thing I'm missing here? Got me very confused.

Facing error while using Plugin.Media.Abstractions.PickMediaOptions,System

$
0
0

Severity Code Description Project File Line Suppression State Suppression State
Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void ChallengeApp.Core.Services.AppServices.ImagePickerService/d__1::MoveNext()' in assembly: 'ChallengeApp.Core.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Threading.Tasks.Task`1<Plugin.Media.Abstractions.MediaFile> Plugin.Media.Abstractions.IMedia::PickPhotoAsync(Plugin.Media.Abstractions.PickMediaOptions,System.Threading.CancellationToken)
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() 0

How to add a ToolbarItem on one platform (Android), but not on the other (iOS)?

$
0
0

Hi there

I have a Xamarin.Forms App for Android and iOS. On one of my Pages I like to add some secondary ToolbarItems for the Android version. I don't want to add them into the Toolbar of an iOS app cause the Xamarin Secondary Toolbar for iOS does not work with the new App Shell.

But with the following XAML I get a NullReferenceException in Page.cs OnToolbarItemsCollectionChanged when I navigate to the page on iOS.

<ContentPage.ToolbarItems>
    <OnPlatform x:TypeArguments="ToolbarItem">
        <On Platform="Android">
            <ToolbarItem Command="{Binding LaunchRocketCommand}" Text="Launch Rocket" Order="Secondary" Priority="3"/>
        </On>
    </OnPlatform>
</ContentPage.ToolbarItems>

Digging into Page.cs I see that the error occurs when the OnToolbarItemsCollectionChanged wants to set item.Parent but I assume item is null cause I did not specify for iOS. Can I somehow manipulate the args.Action? Is it a bug? Does anyone have an idea for a workaround?

    void OnToolbarItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
    {
        if (args.Action != NotifyCollectionChangedAction.Add)
            return;
        foreach (IElement item in args.NewItems)
            item.Parent = this;
    }

Xamarin.Forms: 4.3.0.947036 (latest stable)

Cheers

Error unexpected element found in

$
0
0

I have a problem, migrate my project code VS 2017 to VS 2019.
And I have an error in the Android Manifest of a style.

Xamarin.forms Firebase analystics.

$
0
0

Hi,

I have implemented a firebase analytics tool in Xamarin. forms application and I am not able to track my custom event activity. Referred some tutorials based on implemented the Interface and firebase classes. Please help me out on how to track custom events.

var analyticsService = DependencyService.Get();
analyticsService.LogEvent("app_open", "content_type", "Login Attempted"); Event name , Paramater name , Value

Thanks,

Issue with Android 10

$
0
0

I've been experiencing this issue with my current app after setting target framework to android:targetSdkVersion="29". I've double checked that this happens with a sample application for easier debugging. This is replicated with the WorkingWithNavigation sample app.

Anytime a page is pushed or popped off the navigation stack this error occurs. I'm assuming this has to do with the animation of the navigation.
Any ideas or thoughts on how to fix this issue?

11-09 11:57:51.138 W/avigation.Droi(18447): Accessing hidden field Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener; (greylist-max-p, reflection, denied)
11-09 11:57:51.139 E/FragmentManager(18447): No field with the name mListener is found in Animation class
11-09 11:57:51.139 E/FragmentManager(18447): java.lang.NoSuchFieldException: No field mListener in class Landroid/view/animation/Animation; (declaration of 'android.view.animation.Animation' appears in /system/framework/framework.jar!classes3.dex)
11-09 11:57:51.139 E/FragmentManager(18447): at java.lang.Class.getDeclaredField(Native Method)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.setHWLayerAnimListenerIfAlpha(FragmentManager.java:1283)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.completeShowHideFragment(FragmentManager.java:1746)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1822)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
11-09 11:57:51.139 E/FragmentManager(18447): at android.os.Handler.handleCallback(Handler.java:883)
11-09 11:57:51.139 E/FragmentManager(18447): at android.os.Handler.dispatchMessage(Handler.java:100)
11-09 11:57:51.139 E/FragmentManager(18447): at android.os.Looper.loop(Looper.java:214)
11-09 11:57:51.139 E/FragmentManager(18447): at android.app.ActivityThread.main(ActivityThread.java:7356)
11-09 11:57:51.139 E/FragmentManager(18447): at java.lang.reflect.Method.invoke(Native Method)
11-09 11:57:51.139 E/FragmentManager(18447): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
11-09 11:57:51.139 E/FragmentManager(18447): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)


is there a good way to use mapbox in xamarin forms

$
0
0

im making and ios android app and want to use mapbox because most xamarin forms maps look horrible and are expensive and also mapbox is very customizeable. i hear the defualt xamarin forms mapbox sdk is very glitchy and has not been updated and was wondering if there was a better way such as installing ios and android nuget mapbox sdks on their own platform and some how implementing them seprately in the designer. or good maps other recomendation that dont look like they were made 2005 lol.

How to interrupt bluetooth file transfer in android?

$
0
0

Somebody, please guide how to interrupt or cancel at mid of the file transfer in Bluetooth programmatically. My idea is to close the socket. anybody, please guide better idea

CollectionView Span with Binding Not Working

$
0
0

I'm having a play around with the CollectionView and have encountered an issue where binding to the Span is not working. Basically - if the device is in portrait mode, I would like to see Span="2", and in Landscape mode Span="3", however, the binding doesn't seem to be working... Is this a bug? or is there another way to achieve my requirement? My VM's NumberOfColumns is changing correctly but is not reflected by the control.

            <CollectionView ItemsSource="{Binding Items}" Margin="6">
                <CollectionView.ItemsLayout>
                    <GridItemsLayout Orientation="Vertical" Span="{Binding NumberOfColumns}" HorizontalItemSpacing="6" VerticalItemSpacing="6"/>
                </CollectionView.ItemsLayout>
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Frame CornerRadius="9" BackgroundColor="PaleGoldenrod"/>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>


        protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);

            if (BindingContext is MainViewModel mv)
            {
                mv.LayoutMode = width < height
                ? LayoutMode.Portrait
                : LayoutMode.Landscape;
            }
        }


        public LayoutMode LayoutMode
        { 
            get
            {
                return layoutMode;
            }

            set
            {
                layoutMode = value;
                OnPropertyChanged();
                NumberOfColumns = layoutMode == LayoutMode.Portrait
                    ? 2
                    : 3;
            }
        }

        public int NumberOfColumns
        {
            get => numberOfColumns;
            set
            {
                numberOfColumns = value;
                OnPropertyChanged();
            }
        }

Shell close animation stuttering on Android

$
0
0

Hi,

today I experimented a bit with the "new" (not that new anymore) shell component in order to set up a simple hamburger menu.
I'm facing the same issue as with the MasterDetailPage in the past, were the animation of closing the menu is stuck for a second before actually closing.
For the Masterdetail it was solved by adding a delay (which was bad already) but I can't find a way to solve it for shell.

Does anyone know how to improve the closing animation? Right now it is unusable.

Here is my xaml setup:

<?xml version="1.0" encoding="UTF-8"?>
<Shell BackgroundColor="#D4503B"  xmlns="http://xamarin.com/schemas/2014/forms" xmlns:page="clr-namespace:MyApp.ContentPages" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.AppShell">
    <FlyoutItem Title="Dashboard" >
            <Tab>
                <ShellContent ContentTemplate="{DataTemplate page:Page1}"/>
            </Tab>
    </FlyoutItem>
    <FlyoutItem Title="Train ticket request">
            <Tab>
                <ShellContent ContentTemplate="{DataTemplate page:Page2}" />
            </Tab>
    </FlyoutItem>
    <FlyoutItem Title="Parking spot reservation">
            <Tab>
                <ShellContent ContentTemplate="{DataTemplate page:Page3}" />
            </Tab>
    </FlyoutItem>
</Shell>

Page 1 is almost empty, just two buttons without any styling are shown there but the same problem. Page2 and 3 are a bit more complex but still not overwhelmingly crazy.

One of my ideas was to manually tell when to open and close and navigate but I didn't find a way how to implement it (For example, how to get the menu icon click event?)
Any ideas?

I'm using Xamarin.Forms 4.3.0.947036

References confirming the bug (One is marked as solved but clearly isn't):
https://github.com/xamarin/Xamarin.Forms/issues/7521
https://github.com/xamarin/Xamarin.Forms/issues/5216

References to fix MasterDetail in the past:
https://github.com/xamarin/Xamarin.Forms/issues/4398
https://stackoverflow.com/questions/48115810/how-can-i-make-the-masterdetailpage-faster-on-android

Flip An Image

$
0
0

Has anyone figured out a way to flip in Image in Xamarin Forms? Not rotate it - I use that for something else - but to flip it on the vertical axis? It does not appear that Xamarin supports the ScaleTransform I could use to do this w/ MSFT.

thanks!

Viewing all 91519 articles
Browse latest View live


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