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

How to assign a toolbar items on to the left for android in xamarin forms?

$
0
0
Hi,

In xamarin forms project, I want to assign the toolbar items to the left. I was able to do it for ios through custom renderer but did not find solution for android.

Any help is appreciated.

Thanks

GridItemsLayout in CollectionView to be flexible and Frame or border around collectionview item

$
0
0

Question 1. - Is there a way to get the Frames to be flexible ? I mean to get the frames in the bottom line to be closer to the upper line to close the gap.

Question 2. - Is there a way to get the collectionview items to separate frames or to get them a border like the frames has ?

<CollectionView IsGrouped="True" ItemsSource="{Binding DLHY_VYPIS}">
            <CollectionView.ItemsLayout>
                <GridItemsLayout Orientation="Vertical" Span="4" />
            </CollectionView.ItemsLayout>
            <CollectionView.GroupHeaderTemplate>
                <DataTemplate>
                    <Label x:Name="vyslednasuma" FontAttributes="Bold" Text="{Binding VyslednaSuma}" TextColor="{DynamicResource PrimaryTextColor}">
                        <Label.Triggers>
                            <DataTrigger TargetType="Label" Binding="{Binding Bool_farba_textu}" Value="True">
                                <Setter Property="TextColor" Value="{DynamicResource RedText}"/>
                            </DataTrigger>
                        </Label.Triggers>
                    </Label>
                </DataTemplate>
            </CollectionView.GroupHeaderTemplate>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <StackLayout VerticalOptions="FillAndExpand">
                    <Frame CornerRadius="10" OutlineColor="{DynamicResource PrimaryTextColor}" Padding="5" Margin="5">
                        <StackLayout BackgroundColor="{DynamicResource PageBackgroundColor}" Padding="5">
                            <Label Text="{Binding Popis}" Margin="0" TextColor="{DynamicResource PrimaryTextColor}" BackgroundColor="{DynamicResource PageBackgroundColor}"/>
                            <Label Text="{Binding KEDY}" Margin="0" TextColor="{DynamicResource PrimaryTextColor}" BackgroundColor="{DynamicResource PageBackgroundColor}"/>
                            <Label Text="{Binding KOĽKO,StringFormat='{0:N}€'}" Margin="0" TextColor="{DynamicResource PrimaryTextColor}" BackgroundColor="{DynamicResource PageBackgroundColor}"/>
                            <!--<Button Text="DELETE" Command="{Binding Source={x:Reference DLHY_USER_}, Path=BindingContext.TEST}" CommandParameter="{Binding ID}"/>-->
                            <Image Source="delete_bin_icon" WidthRequest="15" HeightRequest="15" HorizontalOptions="End">
                                <Image.GestureRecognizers>
                                    <TapGestureRecognizer  Command="{Binding Source={x:Reference DLHY_USER_}, Path=BindingContext.TEST}" CommandParameter="{Binding ID}"/>
                                </Image.GestureRecognizers>
                            </Image>
                        </StackLayout>
                    </Frame>
                    </StackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

Call a parent method from a list item class

$
0
0

Hi,

I have a main view with a big list of items. These items are in a ListView. This view has the view model MainPageViewModel.

Each item has a view model called ListItemViewModel, and an "OK" button, when the user clicks the OK button something happens in the ListItemViewModel. However, I also want to remove the item from the main big list, i.e MainPageViewModel.

So my question is, how can I from ListItemViewModel call a method in MainPageViewModel in order to update the main big list after a user clicked OK (event happened in the ContentView class of list item class). Shall I pass an instance somehow? I create the ListView and its items in XAML. Another way would be if I could call the refresh method of the big list directly in my ContentView class for the list items.

Didn't find "class com.google.android.gms.common.GoogleApiAvailability" exception

$
0
0

Hi,
After i upgraded visual studio 2019 to latest version 16.6.1
I am using Android Xamarin 10.3.1.4
I got this error on building my app.
XA1011: Using ProGuard with the D8 DEX compiler is no longer supported. Please update $(AndroidLinkTool) to r8.
According to Microsoft https://docs.microsoft.com/en-us/xamarin/android/release-notes/10/10.3#may-19-2020--xamarinandroid-10310
i added in .csproj

<PropertyGroup>
  <AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup

This error is gone but when i try to debug the app i get a new error on code line

GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this);

"Java.Lang.ClassNotFoundException: 'Didn't find "class com.google.android.gms.common.GoogleApiAvailability" on path: DexPathList ..."

Any suggestions please.

Thanks

Json Deserializing

$
0
0

Hello Xamarin Team,

I have a json and i want to deserialize to object.

{
  "workshops": {
    "Export Dealers": {
      "Phuentsholing": [
        {
          "pincode": "12345",
          "name1": "1S2021",

        },
        {
          "pincode": "12345",
          "name1": "1S2021",

        }
      ],
      "Phuent": [
        {
          "pincode": "12345",
          "name1": "1S2021",

        },
        {
          "pincode": "12345",
          "name1": "1S2021",

        }
      ]
    },
    "Dealers": {
      "Phuentsholing": [
        {
          "pincode": "12345",
          "name1": "1S2021",

        },
        {
          "pincode": "12345",
          "name1": "1S2021",

        }
      ]
    }
  }
}

I impleplement some code

public class WorkShopGroupModel
{
    public Dictionary<string, WorkShopGroup> workshops { get; set; }
}

public class WorkShopGroup
{
    public Dictionary<string, WorkCity> work_shops_city { get; set; }
}

public class WorkCity
{
    public string city { get; set; }
}

in this code work_shops_city return null, i reached at only Export Dealers and Dealers.

var result = JsonConvert.DeserializeObject<WorkShopGroupModel>(Data);

anyone have idea to complete deseriaze this json.

textview bold issue xamarin forms

$
0
0

I have textview with this text.

Now its showing like this

I need to bold this text using **. Is this support only for labels?

Xamarin forms and Firebase: read rules

$
0
0

Hi!

I'm having trouble understanding and configuring the Firebase cloud Firestone security rules.
I'm using Plugin.CloudFirestore.

My Firebase:

With security fully released I can access. See the rule and code:

`match /{document=**} {
        allow read: if true;
        allow write: if true
}`

`public async Task<IQuerySnapshot> GetCollection(string collection)
    {
        var group = await CrossCloudFirestore.Current
                                 .Instance
                                 .GetCollectionGroup(collection)
                                 .GetDocumentsAsync();

        return group;
    }`

now, with the rule below is not allowed, access is denied for lack of permission:

`match /Categorias/{document=**} {
        allow read: if true;
        allow write: if true
}`

like this: match / Categorias / {document = **} - I can only get data from specifying the document, I can't get the list of documents.

Please help me understand what I'm missing.

How to open url in chrome browser by defalut in xamarin forms

$
0
0

Hi,

How to open url in chrome browser by defalut in xamarin forms ?

Thanks


List all .mp3 files from Music folder of my Android device

$
0
0

Hi,
I am developing a music player app in Xamarin.Forms that uses MediaManager plugin. How can I list all .mp3 files from Music folder in my Android device and play it respectively. Also, can I get metadatas of an .mp3 files name, title, album, artist etc?

Map.openasync does not popup app selection in ios

$
0
0
Hi
I am implemented the email and map functionality for the email and address hyperlink. When click the email or address hyperlink it's showing recommend app that we installed in Android app and we are able to select whatever app we want. It is working fine in the Android but it is not working in ios, when click email or address hyperlink it is redirected to the iOS default application. I have searched internet a lot but I did not get any solution. Please help me on this

How to disable the Slide Menu functionality in iOS Xamarin.Forms

$
0
0

Hello,

I'm facing some issue with Slide menu in Masterdetail page. I want to disable the functionality in iOS.

In Android, I'm able to disable. But, in iOS it's not working.

"IsGestureEnabled="False" - This Property is working in Android. But not in iOS.

Please help me out this issue.

Thanks,

How to: Label IsVisible based on multiple values

$
0
0

Hello Folks,

I have a label on a Forms Page, the code for the label below. How can i set the IsVisible property based on combined result of the two property values, below is what i want to do, i know i can't bind two properties at the same time but what is the proper way of doing this?

<Label IsVisible="{Binding NoData && !IsBusy}" Text="{Binding Filter, StringFormat='There are no {0} requests'}" Style="{StaticResource NoDataWarningStyle}" HorizontalOptions="Center" />

Both NoData and IsBusy are bool types. It is probably simple to achieve this but i'm not sure how to. I have searched but not familiar with the correct terminology yet to find the right results. (New to .net land from java.)

Thanks for your time.

Xamarin Forms Android Project Build Failed

$
0
0

Hi, i try to build my xamarin.forms android project but i got some errors.
Can any one help me?

Xamarin Forms Version: 4.7.0.968
Compile version : Android 9
My Target framework : Android 9
Minumun Android version : Android 6
Dex compiler : d8
Code shrinker : none
Aot compilation : none
Linking : none

Severity Code Description Project File Line Suppression State
Error The Java type mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. Mobile.App.Android
Severity Code Description Project File Line Suppression State

Error mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor generated by: Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.AndroidX.Media, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Mobile.App.Android

Severity Code Description Project File Line Suppression State
Error mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor generated by: Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null SKI.CrossPlatForm.Mobile.App.Android

Azure App Service AD Authentication

$
0
0

I have a Xamarin Forms App that authenticates users against Azure AD using MSAL.NET and it works. This application also needs to access a .NET Core Web API running in Azure App Service and uses Azure AD for authentication. I was able to create a service principal for this app service, my mobile app and provide API access. Also, I set the API scope in code and I was able to get a token. But my requests to the App Service using this token fail with 401. Anyone has any thoughts?

Msal Authentication of Xamarin Form and then pass on that token to AppService

$
0
0

I have xamarin form application and followed https://github.com/Azure-Samples/active-directory-xamarin-native-v2 to implement Client Side Azure AD authentication. It is working fine.

For backed End Azure App Service, I have secured the app service using Authentication/Authentication menu and Express option. To test that , I created the
access token in postman : https://medium.com/agilix/getting-started-with-windows-azure-ad-authentication-using-postman-e37a185b642d and it is working fine.

Now, I want to integrate the xamarin form authentication with App Service. That means, If user have authenticated in Xamarin Form then the token should pass on to the app service in the background and work seamlessly. Please share your thoughts.


Automatic expandable editor

$
0
0

Basically I want an input field, which expands whenever the user puts too much text in it. There are several approaches out there trying to achieve this. The problem exists in web developement too and it's pretty basic (as seen by an user).

I went with the most logical (well, for me) approach I found. Extend the Changed-event.

private void OnTextChanged_Grow(object inSender, TextChangedEventArgs inEventArgs)
{
      InvalidateMeasure();
}

But this heavily affects the performance! The power needed to invalidate the view each time the user presses a key is just too much.

Is there any other clean way to do it? Maybe even a change to the design / architecture?

Thanks in advance.

UWP Setting Custom Icon in MapRenderer

$
0
0

I'm trying to draw text on a custom image and set it as a map icon. I've done this with Android and IoS; however, in UWP I've encountered some issues.
The UWP renderer mapIcon.Image requires a uri, stream or file. I've tried several different ways. The following is attempting to return a stream:

public async Task WriteTextOnImage(string uri, string text, Windows.UI.Color color)
{
Uri uriSource = new Uri(uri);
using (CanvasBitmap bitmap = await CanvasBitmap.LoadAsync(CanvasDevice.GetSharedDevice(), uriSource).AsTask().ConfigureAwait(false))
using (CanvasRenderTarget target = new CanvasRenderTarget(CanvasDevice.GetSharedDevice(), (float)bitmap.Size.Width, (float)bitmap.Size.Height, bitmap.Dpi))
{
using (var ds = target.CreateDrawingSession())
{
ds.Clear(Colors.White);
ds.DrawImage(bitmap);
ds.DrawText(text, new System.Numerics.Vector2(150, 150), color);
}
byte[] arr = target.GetPixelBytes();
MemoryStream stream = new MemoryStream(arr);
return stream.AsRandomAccessStream();
}
}

The image is not appearing. I'd appreciate any ideas on this issue.

Android app icon with frames

$
0
0

Hello

i m using samsung s8 and it supports icons with frames.
i made a test app named "KAYAAPP" to see the icon.
when i select the " show icon with frams" in phone settings, as you see in the image, KAYAAPP's background of the icon becames white, although the Mobile.de app looks without frames. I dont want any frame background of my icon. How can i do it. thank you.

choose camera or gallery webview

$
0
0

i have webview for video call which is i am using in xamarin form app. In video call both user can share file, i need to add option for user to choose image from gallery or from camera where user can capture image and send.

here is my code

    public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)

        {





            this.message = filePathCallback;
            Intent chooserIntent = fileChooserParams.CreateIntent();
            chooserIntent.AddCategory(Intent.CategoryOpenable);

            this.mContext.StartActivity(Intent.CreateChooser(chooserIntent, "File Chooser"), filechooser, this.OnActivityResult);
            return true;
        }
        private void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (resultCode != Android.App.Result.Ok)
            {
                this.message.OnReceiveValue(null);
                return;
            }
            if (data != null)
            {
                if (requestCode == filechooser)
                {
                    if (null == this.message)
                    {
                        return;
                    }

                    try
                    {
                        this.message.OnReceiveValue(WebChromeClient.FileChooserParams.ParseResult((int)resultCode, data));

                    }
                    catch (Exception)
                    {

                        throw;
                    }
                    this.message = null;
                }
            }
        }

with this code it only open gallery i need to know how i can add camera option with it

Exception using FilePicker plugin in iOS

$
0
0

I am getting the following exception when using Xam.Plugin.FilePicker in iOS:

System.NotImplementedException
Message=This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.

I just followed the steps detailed here.

Viewing all 79144 articles
Browse latest View live


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