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

How To Consume API in Xamarin

$
0
0

Hi,Plz help about "Consume API in Xamarin App".App UI made with XAML and Database made in SQL Server.


Error: The specified path, file name, or both are too long. The fully qualified file name must be le

$
0
0

I have installed the VS 2015 and getting this error after the Xamarin update.
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
I tried to run the solution in xamarin studio - It also fails with the same error.

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 !

Path too long Xamarin iOS Distribute

$
0
0

Help me pls i can't distribute because my paths are too long.
I tried to change them but it didn't help.
I'm really out of ideas.
That's the error:
Unable to copy file "C:\Users\cunnin\AppData\Local\Xamarin\MonoTouch\Archives\2019-10-18\ZAsetMobile.iOS 10-18-19 10.22 AM.xcarchive\mSYMs\ZAsetMobile.iOS.app.mSYM\b5883af4fb74101e3ffa838fae7f2094\Microsoft.Extensions.DependencyInjection.Abstractions.dll.msym" to "obj\iPhone\AppStore\archives\ZAsetMobile.iOS 10-18-19 10.22 AM.xcarchive\mSYMs\ZAsetMobile.iOS.app.mSYM\b5883af4fb74101e3ffa838fae7f2094\Microsoft.Extensions.DependencyInjection.Abstractions.dll.msym". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I don't finds a way to change the path in xamarin settings.

Button Text Padding (Short Text) on Android

$
0
0

Hi there,

I'm trying to make the button fit the text inside it, but for some reason it's not working correctly on short text in Android only. (iOS works as expected)

In the example below, I'm expecting the button edges to be touching or at least very close to the labels.

Am I missing something, or is this a bug?

XF. 4.7.0.1239

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

<Grid>
    <CollectionView HeightRequest="0" ItemsLayout="HorizontalList" HorizontalOptions="Start" HorizontalScrollBarVisibility="Never" >
        <CollectionView.ItemsSource>
            <x:Array Type="{x:Type x:String}">
                <x:String>Monkey</x:String>
                <x:String>الكل</x:String>
                <x:String>قيمة</x:String>
                <x:String>ن</x:String>
                <x:String>A</x:String>
                <x:String>Howler</x:String>
                <x:String>very long item name</x:String>
            </x:Array>
        </CollectionView.ItemsSource>
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Grid Padding="0,0,0,0" Margin="0,0,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="35" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"  />
                    </Grid.ColumnDefinitions>
                    <Button
                                Text="{Binding .}"
                                BorderColor="#F1F1F1"
                                BorderWidth="1"
                                Padding="0,0,0,0"
                                Margin="0,0,0,0"
                                MinimumWidthRequest="1"
                                MinimumHeightRequest="1"
                                FontAttributes="Bold">
                    </Button>
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</Grid>


`

Nuget restore fails (Arm Mac)

$
0
0

This is a long shot, but does anyone else have access to Apple's ARM Mac DTK? I'm trying to build my Xamarin project in VS for Mac, but nuget restore fails:

error MSB4057: The target "GenerateRestoreGraphFile" does not exist in the project

Happy to hear any suggestions - even if you don't have access to the Mac in question.

how to show details for selected item in carouselview

$
0
0

hello, i have a crouselview that display few items, i wanna show details for that item i selected, but no property for it.
thanks

Does xamarin ever call finalizers?

$
0
0

Finalizer in this basic code, written in a template project doesnt get called ever.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
var vm = new VM();
DisplayAlert("", File.Exists(vm.P).ToString(),"cancel");
}

    ~MainPage()
    {
        File.WriteAllText(((VM)BindingContext).P, "Test");
    }
}

How to optimize the build time for Android project?

$
0
0

I have a solution which contains various projects, every individual project takes milliseconds to built but for droid project it takes approx 1 hour to build. I tried to have detailed summary while building the project from terminal(command line) , it says under Task Performance summary Core compile alone took 54 minutes to complete. What project settings do i need to configure to reduce the build time significantly. Any help will be much appreciated.
@JamesMontemagno @JohnMiller @JonDouglas @JonathanPeppers

[Skiasharp] How to get consistent canvas scale across multiple aspect ratios?

$
0
0

I'm currently developing a cloth editor for a friend's tailor shop using skiasharp. I wanted to use the ClipPath to prevent users from placing images or text outside of the bounds of the cloth that is being edited or some other effects. The problem is that I haven't been able to consistently align the path with the cloth design across different devices with different aspect ratios. Here are some images to show better the problem and below the code I'm currently using:

Samsung Galaxy J2 Pro - 540 x 960 pixels, 16:9 ratio (~220 ppi density)

While it is not perfect, the result is very acceptable.

Samsung Galaxy A20s - 720 x 1560 pixels, 19.5:9 ratio (~264 ppi density)

But in this case the clip path is completely not aligned with the bitmaps of the shirt

Here is the code for the Paint Surfce event:

void SKCanvasView_PaintSurface_Post(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info = args.Info;
            SKSurface surface = args.Surface;
            SKCanvas canvas = surface.Canvas;

            canvas.Clear();
            canvas.SetMatrix(matrix);

            if (AreBitmapsLoaded) //Make sure that bitmaps that are being loaded in a different thread are ready.
            {
                if (IsManipulating) //This draws a copy of the bitmap if it can be manipulated so it can be seen even if outside the clip path
                {
                    foreach (TouchManipulationBitmap manipulationBitmap in Bitmaps)
                    {
                        if (manipulationBitmap.Interactable && current == manipulationBitmap)
                        {
                            manipulationBitmap.Paint(canvas, info.Width, info.Height, painto);
                            break;
                        }
                    }
                }

                //Cliping canvas to path
                if (!CalculateClippingOnce)
                {
                    TestPath.GetTightBounds(out bounds);
                    TranslateCanvasX = info.Width / 2f;
                    TranslateCanvasY = info.Height / 2f;

                    ratio = bounds.Width >= bounds.Height
                    ? info.Height / bounds.Height
                    : info.Width / bounds.Width;

                    CalculateClippingOnce = true;
                }

                canvas.Translate(TranslateCanvasX, TranslateCanvasY);
                canvas.Scale(0.85f * ratio);
                canvas.Translate(-bounds.MidX, -bounds.MidY);
                canvas.ClipPath(TestPath, SKClipOperation.Intersect, true);
                canvas.ResetMatrix();

                Bitmaps = Bitmaps.OrderBy(b => b.ZOrder).ToList(); //A questionable way of having a Z order.

                foreach (TouchManipulationBitmap manipulationBitmap in Bitmaps)
                {
                    manipulationBitmap.Paint(canvas, info.Width, info.Height);
                }

                if (current == null)
                {
                    current = Bitmaps[0];
                }
            }


            if (TakeAndSaveSnapshot)
            {
                TakeAndSaveSnapshot = false;

                SKPixmap pixmap = surface.PeekPixels();

                Render = new SKBitmap();
                Render.InstallPixels(pixmap);

                Task.Run(async () =>
                {
                    await ProcessDesign();
                });
            }
        }

I think it will be useful to share the code for the Paint function in the TouchManipulationBitmap class:

public void Paint(SKCanvas canvas, int infoWidth, int infoHeight, SKPaint paint = null)
        {
            canvas.Save();
            SKMatrix matrix = Matrix;
            canvas.Concat(ref matrix);

            if (ShouldColor) // The shadow details in the shirt should not be colored for example.
            {
                if (TargetColor == null)
                {
                    TargetColor = SKColors.White;
                }

                paint = new SKPaint();

                var tableRed = new byte[256];
                var tableGreen = new byte[256];
                var tableBlue = new byte[256];

                for (int i = 0; i < 256; i++)
                {
                    tableRed[i] = TargetColor.Red;
                    tableGreen[i] = TargetColor.Green;
                    tableBlue[i] = TargetColor.Blue;
                }

                paint.ColorFilter = SKColorFilter.CreateTable(null, tableRed, tableGreen, tableBlue);
                paint.FilterQuality = SKFilterQuality.Low;
            }

            if (!IsText) // if the bitmap does not represent text.
            {
                if (!CalculateDrawOnce)
                {
                    float scale = Math.Min((float)infoWidth / bitmap.Width, (float)infoHeight / bitmap.Height);
                    float x = (infoWidth - scale * bitmap.Width) / 2;
                    float y = (infoHeight - scale * bitmap.Height) / 2;

                    rect = new SKRect(x, y, x + scale * bitmap.Width, y + scale * bitmap.Height);

                    Scale = scale;
                    X = x;
                    Y = y;

                    CalculateDrawOnce = true;
                }

        canvas.DrawBitmap(bitmap, rect, paint);
            }
            else
            {
                float x = (infoWidth -  bitmap.Width) / 2;
                float y = (infoHeight - bitmap.Height) / 2;

                X = x;
                Y = y;

                canvas.DrawBitmap(bitmap, x, y, paint);
            }

            canvas.Restore();
        }

Some other useful Information:

-> The shirt is a mix of bitmaps that are being draw one on top of the other and they align perfectly just as I designed in Figma.
-> The TestPath fits perfectly the contour of the bitmaps when made in Figma, but won't align once I try inside the app.
-> The reason there are foreach loops it's because the user can upload their own images to make a design, or add text or change the cloth type (let's say a short) so the bitmaps to be draw are not fixed. I feel it is probably not the best approach and while it is not the main focus of my question, if you have any feedback on this I would love to listen to it.

This is my first attempt at coding anything with Skiasharp so my code is a mix of tutorials I found around and changes I made to fulfill the needs of the app, so any guidance on how to solve my problem will be nice, Thanks!

Invalid Bundle Structure with Firebase Nuget Packages

$
0
0

I am trying to solve for this error from Apple:

ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'XXXXX.app/FirebaseCrash' is not permitted. Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles.

I cannot seem to figure this one out. My app has nuget packages for Firebase -- Crashlytics, Analytics, etc and Google Tag Manager. Whenever I update these packages and Xamarin.Build.Download to the latest, the app package contents will include this "FirebaseCrash" exe. I don't understand why this exe gets included in the package contents from MSBuild on the latest version of these packages, whereas it doesn't if I stick to what is supported on version 0.4.11 of Xamarin.Build.Download.

Accessing iCloud in XF using Dependency Service

$
0
0

I was following @LandLu post in this forum thread.

The following line is giving a Null Exception:

//Get the iCloud's url
var filePath = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null).Append("Documents", true);

Even replacing the 'null' in the argument of GetUrlForUbiquityContainer with my container id which is of the form "iCloud.com.companyname.appname" didn't help.

What am I doing wrong?

I am using automatic provisioning. Is that wrong?

Also one more question:
In the following code in the same post, what is the namespace of File and Path?

//Here I write a test string in this document folder
File.WriteAllText(Path.Combine(filePath.Path, "test.txt"), "test");

How to raise click event on nested listview ?

$
0
0

Hello all,

Can anyone please help me to understand how to call nested item click event in prism?

How to create an Expandable ListView?

$
0
0

Currently, I have a listview with an "itemtapped" event for each item, which allows to navigate to other views depending on which item I tap. However, I want to "group" these and divide in sections (a listview containing listviews). I've been doing some digging on google and other forums, but can't really make this work. Thanks!

ListView.xaml.cs

public ObservableCollection listaA { get; set; }

public ListView()
{
InitializeComponent();

        listaA= new ObservableCollection<Categorias>();
        listaA.Add(new Categorias { Seccion = "1", Subseccion = "question1's detail", QuizType = Type.type1 });
        listaA.Add(new Categorias { Seccion = "2", Subseccion = "question2's detail", QuizType = Type.type2 });
        listaA.Add(new Categorias { Seccion = "3", Subseccion = "question3's detail", QuizType = Type.type3 });
        listaA.Add(new Categorias { Seccion = "4", Subseccion = "question3's detail", QuizType = Type.type4 });

private async void MainListView_ItemTapped(object sender, ItemTappedEventArgs e)
{

        Categorias model = (Categorias)e.Item;

        if (model.QuizType == type1)
        {
            await Navigation.PushAsync(new TYPE1());

//....

ListView.xaml

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Padding="20" HorizontalOptions="Fill" >
                            <Label HorizontalOptions="Center" VerticalOptions="CenterAndExpand" TextColor="Black" FontSize="25" Text="{Binding Seccion}"/>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Reset Picker with no value

$
0
0

Have a Picker with some value , how do i reset the Picker with no value when i want to use it again .

After selecting an item a listview is filled and the Picker Isvisible is false.

But what do i change to start with the Title "Kies een team ↓ " like the first time

 <Picker x:Name="picker"

        Title="Kies een team ↓ "
        TitleColor="{AppThemeBinding Light=Black, Dark=White}" FontSize="Medium" BackgroundColor="Transparent" SelectedIndexChanged="picker_SelectedIndexChanged" AbsoluteLayout.LayoutBounds=".5,.25,.70,.15" AbsoluteLayout.LayoutFlags="All" HorizontalOptions="Center" >
                                <Picker.ItemsSource>
                                    <x:Array Type="{x:Type x:String}">
                                        <x:String>1e elftal</x:String>
                                        <x:String>2e elftal</x:String>
                                        <x:String>JO16-1</x:String>
                                        <x:String>JO15-1</x:String>
                                        <x:String>JO13</x:String>
                                        <x:String>JO11</x:String>
                                        <x:String>JO10</x:String>
                                        <x:String>JO7</x:String>
                                    </x:Array>
                                </Picker.ItemsSource>
                            </Picker>

 async void mysub()
        {
            Selecteer.Text = picker.SelectedItem.ToString();
            picker.IsVisible = false;

     ///// fill a Listview with the Text depending on Selecteer.Text 

}

To start again

  picker.IsVisible = true;


Xamarin.Forms Themes No embeddedresource found

$
0
0

I'm transitioning my app from using AppThemeColor to ResourceDictionary.

I followed the steps from https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/theming

I created the LightTheme.xaml & DarkTheme.xaml with code behind using Visual Studio for Mac. Everything is working fine on the mac, both with the simulator and a real iOS device.

When I run for UWP, using Microsoft Visual Studio Community 2019, when loading any of the theme xaml classes, I get the following error:

Xamarin.Forms.Xaml.XamlParseException
  HResult=0x80131500
  Message=No embeddedresource found for RealityMMA.Themes.LightTheme
  Source=Xamarin.Forms.Xaml
  StackTrace:
   at Xamarin.Forms.Xaml.XamlLoader.Load(Object view, Type callingType)
   at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml](TXaml view, Type callingType)
   at RealityMMA.Themes.LightTheme.InitializeComponent() in C:\Source\Reality\cmq-mobile-app\RealityMMA\RealityMMA.UWP\obj\x64\Debug\LightTheme.xaml.g.cs:line 21
   at RealityMMA.Themes.LightTheme..ctor() in C:\Source\Reality\cmq-mobile-app\RealityMMA\RealityMMA\Themes\LightTheme.xaml.cs:line 9

I get the error regardless of the theme.

I notice that in the XamlFilePathAttribute, that it has the right path, but the XamlResourceIdAttribute is inserting .UWP into the name.

I also tried using Microsoft Visual Studio Community 2017 on another Windows machine, but get all the same.

How to target MacOS and Windows using Xamarin Forms?

$
0
0

I want to use Visual Studio for Mac to write a c# .net Forms type application that will run on both MacOS and Windows.
Ca I do this with Xamarin and VS for Mac? Is there a template somewhere for a Hello World that will do this? Run on both targets?

AndroSpy V1.0 | Xamarin-C# | Android RAT

$
0
0

Hi, I am new in Forum. If i open this topic into the not correct sub Forum, I am sorry :) I have made an Android RAT that written completely in C#.

githıb uri: https://github.com/qH0sT/AndroSpy/

Min supported android ver: Android 4.0
Max // // // : Android 9.0

Tested on all Android version in Nox App Player: it is OK.
Tested on some physical Device (6.0, 9.0, 7.1.2) : it is OK.

I'm using this RAT in my physical Device and it is useful in my opinion and it is also stable :)

Images

How to use safe area in xamarin.forms android?

$
0
0

I am using xamarin.forms shell and the page is a shell page.

here is the code:
<StackLayout> <CarouselView ItemsSource="{Binding Banners}" IsSwipeEnabled="True" IsScrollAnimated="True" IsBounceEnabled="True" HeightRequest="214.67"> <CarouselView.ItemTemplate> <DataTemplate> <Frame IsClippedToBounds="True" CornerRadius="10" Margin="0" Padding="0" BackgroundColor="Orange"> <ff:CachedImage VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Margin="0" DownsampleToViewSize="True" Aspect="AspectFit" Source="{Binding ImageUrl}" HeightRequest="214.67"/> </Frame> </DataTemplate> </CarouselView.ItemTemplate> </CarouselView> </StackLayout>
and here is the renderer:

Question 1:

how to use the safearea in the top?(android) I want to the Image in the top.

Question 2:

How to make the image full of the screen width? there is a orange place .I want to the image full of the whole width?

thank you.

why the two elements' width not equal? in a collectionview line ?

$
0
0

Here is my code:
<CollectionView Margin="10.33,0,10.33,0" ItemsSource="{Binding Items}" VerticalScrollBarVisibility="Never"> <CollectionView.ItemsLayout> <GridItemsLayout Span="2" Orientation="Vertical" HorizontalItemSpacing="22.5" VerticalItemSpacing="10" SnapPointsAlignment="Center"/> </CollectionView.ItemsLayout> <CollectionView.ItemTemplate> <DataTemplate> <StackLayout BackgroundColor="Orange" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> <ff:CachedImage HeightRequest="96.33" HorizontalOptions="FillAndExpand" Source="{Binding ImageUrl}" Aspect="AspectFit" VerticalOptions="FillAndExpand"/> <StackLayout MinimumHeightRequest="44"> <Label Text="{Binding Name}" TextColor="#000000" FontSize="14" Margin="0,7.67,16,7" LineBreakMode="TailTruncation" MaxLines="2" MinimumHeightRequest="31.33"/> </StackLayout> <FlexLayout JustifyContent="SpaceBetween" AlignItems="Center"> <StackLayout Orientation="Horizontal"> <Label Text="¥" FontSize="8.67" TextColor="#ff0000" VerticalOptions="CenterAndExpand"/> <Label Text="{Binding Price}" TextColor="#ff0000" FontSize="14"/> </StackLayout> <Image Source="icon_cart.png" WidthRequest="19.67" HeightRequest="16"/> </FlexLayout> </StackLayout> </DataTemplate> </CollectionView.ItemTemplate> </CollectionView>

Here is the view:

The first one 's width is bigger than the second one

Viewing all 204402 articles
Browse latest View live


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