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

Xamarin Forms: Is it possible to save and retrieve an EpubBook data using SettingsPlugin?

$
0
0

I am using SettingsPlugin for saving values to local DB. Using this plugin I have saved an EpubBook data like below:

CrossSettings.Current.AddOrUpdateValue("epub", epubBook.ToString());

Retrieved the value like below:

string epubString = CrossSettings.Current.GetValueOrDefault("epub", string.Empty);
if (!string.IsNullOrWhiteSpace(epubString))
{
    //Need to convert string epub data to EpubBook data
}

I need to convert the string epub data to EpubBook? Is this possible? This is for caching the EpubBook data.

I have done the same using Application.Current.Properties and saving and retrieving is working fine there. Please see below code:

//Saving value
Application.Current.Properties["epub"] = epubBook;
//Retriving value
EpubBook epubBook = (EpubBook)Application.Current.Properties["epub"];

But the Application.Current.Properties values are clearing automatically after closing the app. That's why I start working on SettingsPlugin. So is there any way to save and retrieve an EpubBook using SettingsPlugin? If no suggests a way to caching the EpubBook data?


UseSafeArea not working correctly

$
0
0

I have a CollectionView, which contains a CollectionView, which contains a FlexLayout.
The top CollectionView is being used as a Carousel to contain the other CollectionViews.

When I use ios:Page.UseSafeArea="true", it does not handle adding the additional safe area correctly.

If I turn the iPhone to landscape mode, with the notch on the right, then the right edge of the FlexLayout is cut off by the safe area. The left edge starts at the safe area as it should.

It's as if the FlexLayout does not realize that the area it is to be drawn into, has been made shorter by UseSafeArea.

So what is going on and how do I fix it?

shell tabbar double click problem?

$
0
0

on shell tabbar I have problem that color state is changing when I click double , have to be one click only why you think this problem? Thanks

How to Scroll A grid

$
0
0

I created a grid of buttons in XAML. in portrait mode it works great. in landscape, there is not enough space for all the buttons.
How can I allow the grid to scroll so that all the buttons would be visible and selectable?
Here is the XAML:
<ContentPage.Resources>

        <Style x:Key="ButtonSettings" TargetType="Button">
            <Setter Property= "VerticalOptions" Value="Center" />
            <Setter Property= "BackgroundColor"  Value= "Orange"/>
            <Setter Property= "TextColor" Value="Black" />
            <Setter Property= "FontSize" Value="Large"  />
            <Setter Property= "BorderRadius" Value="10"/>
            <Setter Property= "BorderWidth" Value="2"/>
            <Setter Property= "BorderColor" Value="Black"/>
            <Setter Property= "HorizontalOptions" Value="Center"/>
        </Style>

    </ResourceDictionary>
</ContentPage.Resources>

<ContentPage.BindingContext>
    <local:MainPageViewModel />
</ContentPage.BindingContext>

<Grid BackgroundColor="Chocolate">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height=".5*" />
        <RowDefinition Height=".5*" />
        <RowDefinition Height=".5*" />
    </Grid.RowDefinitions>

........

Can Liquid swipe be done in Xamarin.forms?

$
0
0

as the animation is very cool and can be done in flutter.

image
can it be done in Xamarin?

UWP (Xamarin.Forms) - Failing to create msixupload/appxupload files with x64-x86-arm configurations

$
0
0

When enabling arm in the release architectures build is failing and msixupload/appxupload files are not generating where as selecting x86 & x64 are fine.

Getting following error when enabling ARM

Error ILT0005: '.nuget\packages\runtime.win10-arm.microsoft.net.native.compiler\2.2.3\tools\ARM\ilc\Tools\nutc_driver.exe @obj\ARM\Release\ilc\intermediate\MDIL\MyApp.UWP.rsp' returned exit code 1 MyApp.UWP .nuget\packages\microsoft.net.native.compiler\2.2.3\tools\Microsoft.NetNative.targets

Thanks.

Cannot seem to get Xamarin.Forms to work with WPF

$
0
0

I've followed the instructions here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/other/wpf

But, I'm stuff on probably a simple problem: In my MainWindow.xaml.cs file, on this line:
LoadApplication(new App4.App());
I get the error:
Argument 1: cannot convert from 'App4.App'

This is becaue the "App" from App.xaml.cs is derived from type System.Windows.Application

Should I be changing app.xaml / app.xaml.cs ?

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)


It’s possible convert Xamarin Forms app to Nuget package?

$
0
0

I developed Xamarin Forms app with Android and iOS platforms. I would like to know if it’s possible convert this app in a nuget package and run my app in other app. Of course it would be a nuget package per platform. I know that importing one project into another can, but I want to protect code. I also don't know if nuget packages can have UI.

My application is created with MVVMCross, it has four subprojects: Android, ios, core and UI.
In the UI project has the XAML and CS of views and in the core the viewmodels. On iOS and Android it contains customrenders, interfaces and resources. In addition to the loading of certain plugins in the MainActivity and Appdelegate.
Would I have to rewrite my app to create this? I have tried to create a multi-platform library but I have lost ..... :(

Can you help me??

Thanks a lot

Can't select same item twice on CollectionView

$
0
0

I use a CollectionView control to display a list of files, if users click an item a popup appears displaying information about the file and a button to download it, the problem is that i use the SelectionChanged method of the CollectionView to run this action, but if users close the popup and click again on the same item nothing happens. Back when we use ListView control, the ItemTapped event runs every time the users click the same item, but i need to changed to CollectionView because later we'll change the file item from a single row to multiple columns (2 or 3).

It is possible to make the users click on the same item multiple times ?

P.D: also try to set the SelectedItem to null but the app crashes if the users select the same item.

//xamarin103.rssing.com/chan-50717177/article76111-live.html

$
0
0

Hello all,

I am not asking how to but rather why I am not getting the expected $###.## currency format I am supposed to get using either

That is the solution I know and the one every one is proposing. What am I missing?

Thank you!

Xamarin Forms IOS - NSData from a json string

$
0
0

I'm trying to get an NSData from a json string, to use it later to create an MGLShape (From Mapbox SDK) like this:

MGLShape.ShapeWithData(jsonData, 4, out error); //jsonData is the NSData, 4 is the nuint for the type of encoding and ou error is a plain NSError.

But i'm not able to serialize the json string into NSData using NSJsonSerialization, the json string is corrected and validated before, (but when i use an NSString from the string, it adds an extra pair of brackets "{ //json }", which i can remove before trying the NSJsonSerialization, here is how i'm trying to achive my goal:

string jsonSerialized = JsonConvert.SerializeObject(fc);//Valid Json
NSString json = new NSString(jsonSerialized);//Adds the extra pair of brackets
NSData jsonData = NSJsonSerialization.Serialize(json, NSJsonWritingOptions.SortedKeys, out error);

But it gives me the following error:

Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: *** +[NSJSONSerialization dataWithJSONObject:options:error:]: Invalid top-level type in JSON write

This error happens with, or without the extra pair of brackets (removed the first and last chars from the NSString), here is a shortned version of my json:
(i used https://jsonformatter.curiousconcept.com/ to test the json)

{"type":"FeatureCollection","crs":null,"features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[-9.000000,38.000000]},"properties":{"id":1,"icon":"MyIcon.png"}}]}

What am i doing wrong here? how can i parse an json string into an NSData?

Convert a byte array to a Image on Forms.

$
0
0

So, i saw many examples here and i am trying to adapt to my code ! But, when appears the image, comes blank... i am a newbie, so... lol
I just want to show the image after click on the button !! Is not to save on the smartphone.

The .cs code:

ApiCall apiCallFoto = new ApiCall();
            ImageSource imagem = null;

            btnFoto.Clicked += async (sender, e) =>
            {
               await apiCallFoto.GetFoto<byte[]>("Nomes", "Foto", envolvID).ContinueWith(t =>
                {
                    //Aqui verificamos se houve problema ne requisição
                    if (t.IsFaulted)
                    {
                        Debug.WriteLine(t.Exception.Message);
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Falha", "Ocorreu um erro na Requisição :(", "Ok");
                        });
                    }
                    //Aqui verificamos se a requisição foi cancelada por algum Motivo
                    else if (t.IsCanceled)
                    {
                        Debug.WriteLine("Requisição cancelada");

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Cancela", "Requisição Cancelada :O", "Ok");
                        });
                    }

                    //Caso a requisição ocorra sem problemas, cairemos aqui
                    else
                    {
                        //Se Chegarmos aqui, está tudo ok, agora itemos tratar nossa Lista
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            byte[] fotoBytes = t.Result;
                           // Image image = new Image();
                            imagem = ImageSource.FromStream(() => new MemoryStream(fotoBytes));


                            Navigation.PushAsync(new FotoEnvolvido(imagem));

                        });

                    }
                });
            };

The FotoEnvolvido.cs :

public partial class FotoEnvolvido : ContentPage
    {
        private ImageSource imagem;

        public FotoEnvolvido(ImageSource imagem)
        {
            InitializeComponent();
            this.imagem = imagem;
            BindingContext = imagem;

        }
    }

The FotoEnvolvido.xaml :

<Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*"/>
      <RowDefinition Height="100"/>
    </Grid.RowDefinitions>
    <Image Source="{Binding imagem}" x:Name="fotoperfil"/>

</Grid>

UWP ONLY: How Change Default Background Color On a ListView Item Click/Tap (Selection Animation)?

$
0
0

It's going to be a little tricky explaining this, but stick with me, folks! :) I have a ListView that I'm wanting to customize in a UWP version of a Xamarin Forms application (this is not a problem with my Android or iOS versions; neither of them displays the following behaviors). It seems that when an item in the ListView is clicked/tapped (and then held down momentarily), it reveals a default blue background that fills the view area. I want to change that background to Color.Gold but haven't been able to find any reliable way to make that happen.

My first thought was maybe a VisualStateManager could be used, but I didn't find anything to support my particular situation. I'm wanting to change the color on a click/tap animation for the "outer" view cell while the animation is happening and after it has ended. I am not concerned with any subview controls that are in that same view cell. (Right now such subview controls are inside a Frame and they're not giving me any problems.)

Here's an illustration of what I'm talking about:

The above happens pretty quickly, of course - I've attempted to slow it down here.

I don't think the solution requires a CustomRenderer; it seems that would be overkill for something so simple in theory. But I've searched my entire project for occurrences of the string "Blue" and I didn't see any that were associated with the ListView control.

Each of my view cells contains a styled Frame object (hence the gray rounded rectangles you see in the screen shots above). But I'm hoping there's a way to change those blue flashes to gold ones.

Does anyone at Xamarin have any suggestions for an approach to this? Thanks!!!

Get record from Xamarin.iOS in Xamarin.Forms

$
0
0

Hello,

i need to get record from keychain via: SecureStorage.GetAsync("xxx");

In Xamarin.iOS app i have this:

 var s = new SecRecord(SecKind.GenericPassword)
                {
                    Label = "Item Label",
                    Description = "Item description",
                    Account = "Account",
                    Service = "Service",
                    Comment = "Your comment here",
                    ValueData = NSData.FromString("Something"),
                    Generic = NSData.FromString("foo")
                };

                var err = SecKeyChain.Add(s);

I tried make native iOS app and i can get from Keychain value of "Account", but no in Xamarin.Forms. Where Xamarin.forms store encrypted data please? Is possible to get(share) some values from iOS in Forms? For example FCM token from Firebase?

Iam new in Xamarin

Thank you for response


How to design a custom Master Page

$
0
0

Hello Everyone,
I am trying to Design a custom master page. I have attached the image. In this image when user clicks arrow button that time master page should open. and after hiding master page also arrow strip should display as default in all page. But i am not able find any solution for that. Any suggestion please.

How to animate CollectionView items positions in Xamarin Forms

$
0
0

I'm using Xamarin Forms CollectionView in a vertical grid layout.

I have a dynamic grid where the number of columns changes dynamically and each item is sized according to subsequent available width.

I'm trying to animate the respositioning of items within the CollectionView after such column count changes.

Tried to tap into X/Y property changes on the root element of each DataTemplate but got nothing.
Any idea would help!

Here's a sample code of such grid:

<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             SizeChanged="CollectionSizeChanged"
             x:Name="CollectionRoot"
             x:Class="App.Views.DynamicGrid">
    <CollectionView VerticalOptions="FillAndExpand"
                    VerticalScrollBarVisibility="Never"
                    HorizontalScrollBarVisibility="Always"
                    ItemsSource="{Binding CollectionItems}">
        <CollectionView.ItemsLayout>
            <GridItemsLayout Orientation="Vertical" 
                             HorizontalItemSpacing="0"
                             VerticalItemSpacing="0"
                             Span="{Binding NumColumns, Source={x:Reference CollectionRoot}}"/>
        </CollectionView.ItemsLayout>
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <ContentView Padding="0" Margin="0">
                    <Frame BackgroundColor="Green"
                           BorderColor="Red"
                           CornerRadius="0"
                           Margin="0"
                           Padding="0"
                           VerticalOptions="Center"
                           HorizontalOptions="Center"
                           HeightRequest="{Binding ItemHeight, Source={x:Reference CollectionRoot}}"
                           WidthRequest="{Binding ItemWidth, Source={x:Reference CollectionRoot}}"/>
                </ContentView>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentView>

How to change the android bottom tabbar height in Xamarin.Forms

$
0
0

I spent hours searching a way to increase the bottom tabbar height in android in my Xamarin.Forms project. I did not find any Custom Renderer for that instead I found this

<android.support.design.widget.TabLayout 
    ...
    android:minHeight="300dp"
    />

but it also didn't work for me. Can someone has a solution for this please.

How to change the TitleColor in the TitleView in Xamarin.Forms.Shell?

$
0
0

is it Shell.TitleColor property? I set it to white but nothing changed.

PopToRootAsync with Modal

$
0
0

Navigation.PopToRootAsync() throws and exception when the page on top of the stack is a modal. Is there any work around for this?

Viewing all 79144 articles
Browse latest View live


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