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

How to not let ImageButton get stretched sideways.

$
0
0

On the iPhone 11:
On iPad Pro:

I have these search bars and image buttons using Xamarin Forms, but the image button is getting stretched out, and I don't know how I can fix it with the XAML set up that I have.

` <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="40" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
      </Grid.ColumnDefinitions>

  <SearchBar Grid.Row="0" Grid.Column="0"
             Placeholder="Search"
             Text="{Binding SearchText}"
             FontSize="Medium"
             VerticalOptions="Center"
             Margin="0,4,0,0"/>
  <ImageButton Grid.Row="0" Grid.Column="1" 
               Margin="4,5,4,4"
               Aspect="AspectFit"
               Command="{Binding Filter}" Source="filter.png" BackgroundColor="Transparent">`

The problem is, that if I set the image button to a specific width, to make it universal among devices, I don't know how to tell XAML to just stretch the search bar up to the image. What can I do?

The Android phones and tablets both look like it's supposed to.


how to make observablecollection to update UI without using MVVM....

$
0
0

i don't want to use MVVM,,please anyone suggest me how to achieve that???
here is my code

public class ClassInfos
{
public int Id { get; set; }

    public string ClassName { get; set; }
}

///////////////////////////////in main page/////////////////////////

FirebaseClient firebase = new FirebaseClient("https://url~~~~/");

    ObservableCollection<ClassInfos>listOfClass = new ObservableCollection<ClassInfos>();
      public ClassInfoPage()
      {
        InitializeComponent();
        this.BindingContext = listOfClass;
       }

    protected async override void OnAppearing()
    {
        base.OnAppearing();
        try
        {
                       ///getting the list from firebase database/////////////////

            var data = (await firebase.Child("Class").OnceAsync<ClassInfos>()).Select(item => new ClassInfos
            {
                ClassName = item.Object.ClassName,
                Id = item.Object.Id,
            }).ToList();


           if(listOfClass != null)
           {
                listOfClass.Clear();
                foreach (var item in data)
                {
                    //////add the data into ObservableCollection<ClassInfos>listOfClass//////////////
                    listOfClass.Add(new ClassInfos
                    {
                        ClassName = item.ClassName,
                        Id = item.Id,
                    });
                }

            }
            ClassList.ItemsSource = listOfClass;


        }

//////////////////////deleting the item ////////////////
private async void DeleteMenuItem_Clicked(object sender, EventArgs e)
{
var menuitem = sender as MenuItem;
var Deletcontent = menuitem.CommandParameter as ClassInfos;
var deletefirebase = (await firebase.Child("Class").OnceAsync()).Where(item => item.Object.Id == Deletcontent.Id).FirstOrDefault();
await firebase.Child("Class").Child(deletefirebase.Key).DeleteAsync();
}

Able to populate data in some pages but not in others, doing the same things. Using AzureDB.

$
0
0

So I can populate a listview just fine in several instances including this one:

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Dunjin.Model;
using Newtonsoft.Json;
using Xamarin.Forms;

namespace Dunjin
{
public partial class CampaignSelection : ContentPage
{
Characters characters;
public CampaignSelection()
{
InitializeComponent();

        campaignListView.ItemTapped += new EventHandler<ItemTappedEventArgs>(CampaignClicked);
    }

    protected override async void OnAppearing()
    {
        base.OnAppearing();

        var campaigns = await App.MobileService.GetTable<Campaigns>()
            .Where(camp => camp.UserId == App.user.Id).ToListAsync();
        campaignListView.ItemsSource = campaigns;

    }

    private async void newCampaign_Clicked(System.Object sender, System.EventArgs e)
    {
        await Navigation.PushAsync(new NewCampaign());
    }


    private async void CampaignClicked(object sender, ItemTappedEventArgs e)
    {
        Campaigns campaign = (Campaigns)e.Item;

        await Navigation.PushAsync(new HomeDM(campaign));

    }

}

However, here it isn't working:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Xamarin.Forms;
using Dunjin.Model;
using Xamarin.Forms.Xaml;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.MobileServices;

namespace Dunjin
{

public partial class HomeDM : TabbedPage
{
    Campaigns campaign;
    Characters characters;

    public HomeDM(Campaigns campaign)
    {
        InitializeComponent();

        this.campaign = campaign;

        charactersListView.ItemTapped += new EventHandler<ItemTappedEventArgs>(CharacterClicked);
        //campaignDetails.Text = campaign.CampaignName;           
    }


    protected override async void OnAppearing()
    {
        base.OnAppearing();

        var characters = await App.MobileService.GetTable<Characters>()
            .Where(cha => cha.CampaignId == App.campaign.Id).ToListAsync();

        charactersListView.ItemsSource = characters;

    }
    private void CharacterClicked(object sender, ItemTappedEventArgs e)
    {
        Characters character = (Characters)e.Item;

    }
}

}

What am I missing here? I can make an OnAppearing var that uses GetTable and it will populate the HomeDM list, so I know it has something to do with not being able to reach the Characters data correctly? I've just been at this for many hours and can't figure it out.

I can provide more info if needed, but I coudl really use the help.

Thanks

Cannot distribute the APK - Missing input APK

$
0
0

Using VS 16.5.4. Everything builds OK, I can archive an APK, but signing (choosing "Distribute" in the Archive Manager) fails with "Signing packages failed. Missing input APK".
Another strange thing is that when I fill in my key store information in the Android project properties ("Android Package Signing") the build fails with the "key store has been tampered with" error. I have used the same key store for long time and at least 3 or 4 different projects.

Xamarin.Diagnostics window shows:
"Xamarin.AndroidTools.AndroidSdkToolException: Missing input APK

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.VisualStudio.Android.Services.Publishing.AndroidToolsPublishService.d__4.MoveNext() in E:\A_work\548\s\src\Core\VisualStudio.Android\Services\Publishing\AndroidToolsPublishService.cs:line 41"

Settings from the Android.csproj file:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
    <AndroidLinkMode>None</AndroidLinkMode>
    <AndroidSupportedAbis>arm64-v8a</AndroidSupportedAbis>
    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <AndroidLinkTool>proguard</AndroidLinkTool>
    <AndroidEnableMultiDex>false</AndroidEnableMultiDex>
    <AndroidPackageFormat>apk</AndroidPackageFormat>
    <AndroidDexTool>dx</AndroidDexTool>
    <EnableProguard>true</EnableProguard>
    <AndroidUseAapt2>false</AndroidUseAapt2>
    <AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
  </PropertyGroup>

How to send MultipartFormDataContent data in body to API

$
0
0

In my App, I want to send MultipartFormDataContent to API call. In MultipartFormDataContent contains json data , strings & image file. I know to send json data to API call but i am facing issue with image.

Thanks,
Jagdeesh.

App Store Connect rejecting app due to UIWebView Deprecated API Usage

$
0
0

I have followed the instructions in the link below:
https://docs.microsoft.com/en-gb/xamarin/xamarin-forms/user-interface/webview?tabs=macos#uiwebview-deprecation-and-app-store-rejection-itms-90809

The following is my iOS build settings:

But I still receive email from App Store Connect:

ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

Settings Plugin not persisting between deployments

$
0
0

Hey guys -

I am using the @JamesMontemagno Settings Plugin. Data saves fine, but I lose the data when I deploy from Visual Studio. I do have the "Preserve application data cache on device between deploys" in Studio selected (although I haven't been able to tell if the settings plugin is supposed to use this or not).

So two questions. First, is this the expected behavior? If so, is there a way to make it so that it doesn't lose this data? Since my app uses two factor authentication, I am having to re-authenticate my device each time that I re-deploy - which is quite often when debugging on my phone.

Second - I am concerned that this behavior would also happen when I deploy my app to the app store. I push out updates a couple of times a month and I don't want my user's to have to re-authenticate their devices that often.

I am running Visual Studio 2019 in debug mode and deploying to a Samsung S20+. I have not tried this plugin on iOS yet so I am not sure if this is happening there as well.

Thanks!

How to set up headers in CrossDownload Manager

$
0
0

Hi guys! In my app I implemented a CrossDownload Manager and is working for "open links". Right now I must download a file inside a login website.
I have the AuthCookie and the CookieContainer.

I'm trying that:

var headers = new Dictionary<string, string>
{
{ "Cookie", AuthCookie}

         };

            var file = downloadManager.CreateDownloadFile(FileName, headers);

(...)
But still doesn't work. Anyone can help?
Thank you!


Button trigger all list not selected item

$
0
0

I have A collection view with favorite button an data when the button is triggered and change it's color it affects all list not the item within.

                                <Button Grid.Row="1" Grid.Column="2" VerticalOptions="Center" Text="" 
                                        Command="{Binding Source={x:Reference Page},                                                Path=BindingContext.FavoriteCommand}"
                                        CommandParameter="{Binding}"
                                        BackgroundColor="Transparent" >
                                    <Button.ImageSource>
                                        <FontImageSource FontFamily="FontAwsomeSolid.otf#Font Awesome 5 Free" Glyph="&#xf005;" Color="{Binding Source={x:Reference Page},                                                Path=BindingContext.IsFavColor}"/>
                                    </Button.ImageSource>
                                </Button>

I need it trigger only one cell.

The complete code in the link
Code

UIWebView API Deprecation Warnings

$
0
0

Hi,
As per Apple warning about UIWebView. I had implemented WKWebView in my IOS Project and clear webview from all classes and configure release as per defined on microsoft doc but when i try to upload built on testflight I still get warning for UIWebView. Kindly tell me how can i resolve this ASAP. Thanks

best approach to handle dark theme?

$
0
0

I'm working on an app for UWP, Android, and iOS using Xamarin.Forms.

I just started testing on my iPhone 8 which is set to dark mode and noticed that text in the ListView controls is not visible. The ListView is bound to an ObservableCollection and the custom data template has 2 label controls in a grid. I don't have any color information specified in the XAML, just using defaults. But on the iPhone with dark mode, the list background is black and the text is apparently black as I can't see it. If I switch my iPhone back to light theme I can read the text.

Note that the other controls in the view (outside the list) do not have any problems. I'm using both labels and buttons and they are all readable. Its just the list view which has a black background and the labels within the list view (in the custom data template) apparently have black text on a black background.

My hope would have been that with defaults (no color info set in the XAML) the result would be readable without me having to do anything. Its looking like I will need to have some sort of platform specific code which is also sensitive to theme and then add conditional coloring based on that.

Anyone know of the best, simplest, cross-platform way to achieve this? I'm guessing this will also be an issue for "dark" android and UWP though I haven't tested those.

Shell navigation not retaining hamburger menu

$
0
0

Well, as the title suggest when I navigate from the main pages established in my flyout menu I lose my hamburger menu, it is simply replaced by a back button. Is it possible to maintain the menu button for easy navigation back to core pages of my app?

FileSystem

$
0
0

Hy
Fist of all. I'm very new in Xamarin.
My Question. If i am tring to open some file (.txt, .xlsx, .csv) i always have to add some path.
Where do i find this path in my Phone and how do i can search for the path?

I'm shure it is very easy but i didnt found out that Problem for the last 2 days.

So please help me.

Thank you in advance.

Finding Data

$
0
0

Hy
Fist of all. I'm very new in Xamarin.
My Question. If i am tring to open some file (.txt, .xlsx, .csv) i always have to add some path.
Where do i find this path in my Phone and how do i can search for the path?

I'm shure it is very easy but i didnt found out that Problem for the last 2 days.

So please help me.

Thank you in advance.

How to improve page loading with Shell

$
0
0

In the documentation for Shell it states the following:

In a Shell application, every ContentPage object in a ShellContent object is created during application startup, which can lead to a poor startup experience. However, Shell also allows pages to be created on demand, in response to navigation. This can be accomplished by using the DataTemplate markup extension to convert each ContentPage into a DataTemplate, and then setting the result as the ShellContent.ContentTemplate property value

To test the example provided by the documentation I downloaded the Xaminals example app associated with that same documentation. Sure enough, when starting up, the CatsPage loads and the DogsPage does not.

However, the problem I am having is when switching from one Tab Set to another. It appears that when switching to a different Tab Set, several of the pages in the Tab Set are created, in a similar fashion to what you would get if you did not wrap the page in a DataTemplate. It appears that the pages that do not ‘auto’ load are the ones associated with the first tab set, and perhaps the last page of a Set when that Set is selected.

To test this new problem/theory I modified the Xaminals application slightly by changing the “other” animal tabs as follows in the AppShell.xaml file:

<Tab Title="Other Animals" Route="otheranimals">
        <ShellContent Route="monkeys"
                      Style="{StaticResource MonkeysShell}"
                      Title="Monkeys"
                      Icon="monkey.png"
                      ContentTemplate="{DataTemplate views:MonkeysPage}" />
        <ShellContent Route="elephants"
                      Style="{StaticResource ElephantsShell}"
                      Title="Elephants"
                      Icon="elephant.png"
                      ContentTemplate="{DataTemplate views:ElephantsPage}" />
        <ShellContent Route="bears"
                      Style="{StaticResource BearsShell}"
                      Title="Bears"
                      Icon="bear.png"
                      ContentTemplate="{DataTemplate views:BearsPage}" />
        </Tab>

Then, in the constructor of each “XXXXsPage.xaml.cs” page I added

Debug.WriteLine("Monkeys Page Constructor Called!");

Started the app and found that, just like before the initial Tab set only created the first page, and not the DogPages. However, when I traversed to the “Other Animals” Tab Set the following printed in the output window, yet I had not actually navigated to Elephants:

[0:] Monkeys Page Constructor Called!
[0:] Elephants Page Constructor Called!

This simple test raises few questions for me:
1) What occurs during the “convert each ContentPage into a DataTemplate” action?
2) Why does this only appear to work for the initial Tab Set? Is it restricted to application startup only and once the application is started it reverts to loading all pages in the Set?
3) I would have expected this failure to also create the “BearsPage” but it appears that it did not do this. Why not? The "BearsPage" ShellContent is not defined any differently than the "ElephantsPage" ShellContent.
4) I would like to improve my application performance by limiting the initial load of a Shell Tab Set to just the first page, allowing the subsequent pages in the set to be loaded on demand. How can I accomplish this?
5) Is this a bug in Xamarin Shell?

Related Links:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/tabs#efficient-page-loading

https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-xaminals/


Maps

$
0
0

Hi to all the experts here,

I just would like to ask if anyone has an idea of how to bind the Map in viewmodel. I am using viewmodel in the customMap, but I don't know how to add command on MapClicked event in viewmodel. here is my code:

In View:
`

                <maps:Map.ItemTemplate>
                    <DataTemplate>
                        <maps:Pin Position="{Binding PositionJam}"
                            Address="{Binding Address}"
                            Label="{Binding Description}" />

                    </DataTemplate>
                </maps:Map.ItemTemplate>
            </local1:CustomMap>

`

Reporting tools for Xamarin Forms

$
0
0

Hi,
Is there any third party tool for Xamarin that allows to create and print reports?
I have seen many third party tools as syncfusion, devexpress, telerik, infragistics etc etc, but any of those allows to create and print reports.

I'll appreciate your comments.

I want to place a button above SKCanvasView on the full screen

$
0
0

Images are displayed (full screen) with SKCanvasView.
I want to put controls such as buttons there, but it is displayed at startup, but it disappears when the image is displayed.!

Check Box crashes while loading

$
0
0

Hi guys
We have been working with xamarin.forms 2.5 for many years but recently we decided to upgrade xamarin.forms in to 4.6 (latest version) and converted portable library in to .net core (.net Standard 2.1)
right now we have all the latest versions including visual studio (2019 16.5.4).
We are no trying convert our custom made tools in to xamarin.forms tools such as ImageButton, Checkbox and Radio Button
ImageButton so far successful with conversion but when we tried to use Xamarin.Forms checkbox this issue occurs while loading the page


and error also doesn't say much to resolve
Do you have any suggestion we should do here?

not show image

$
0
0

        <Image Source="https://www.cdn.vatanbgs.com/Content/Images/Products/460_466/637089327869489423.jpg" Aspect="Fill" HeightRequest="150"/>
        <Image Source="https://cdn.vatanbgs.com/Content/Images/Products/460_466/637089327869489423.jpg" Aspect="Fill" HeightRequest="150"/>

        <Image Source="https://www.blogfa.com/static/images/blogfa-logo.gif" Aspect="Fill" HeightRequest="150"/>
        <Image Source="https://blogfa.com/static/images/blogfa-logo.gif" Aspect="Fill" HeightRequest="150"/>

Why don't the photos open? cdn.vatanbgs

android
5
4.3
4.2

Viewing all 89864 articles
Browse latest View live


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