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

How can I use binding with static property ?

$
0
0

I am using this code but its not working :

IsVisible="{x:Static local:GlobalResources.IsUserLoggedIn}"

This is the class :

public class GlobalResources { public static bool IsUserLoggedIn { get; set; } }


Hello World app crashes on Samsung with Android 4.1 (API level 16)

$
0
0

A simple Hello World app made with the latest Xamarin.Forms runs with no problem on an emulator with Android 8.0 (API 26).
On a Samsung GT-18260 with Android 4.1.2 there is an error.
At base.OnCreate(savedInstanceState) the error is Android.Content.Res.Resources+NotFoundException: 'File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f070059'.
Can I repair this, or is there a minimum API level which is supported with the latest Visual Studio and Xamarin.

How to bind Bind Array element inside PICKER in MVVM

$
0
0

Need to ask you a hand with this one. I'm currently developing a Xamarin Forms solution using MVVM.

I've got a Picker with items made by this API response:

{
"status": "200",
"message": "Languages",
"data": [
{
"id": "1",
"language": "Hindi"
},
{
"id": "2",
"language": "English"
}
]
}

My Model Class :

public class Languages
    {
        public string id { get; set; }
        public string language { get; set; }
    }

    public class LanguageModel
    {
        public string status { get; set; }
        public string message { get; set; }
        public List<Languages> data { get; set; }
    }

What I want to achieve is to display a language text created using the Languages list.
Something like

<controls:CustomPicker Title="LANGUAGE"
                    HeightRequest="50"
                    Image="ic_arrow_drop_down"
                    ItemDisplayBinding="{Binding language}"
                    ItemsSource="{Binding LanguageList.data}"
                    SelectedItem="{Binding SelectedLanguage}">
</controls:CustomPicker>

My ViewModel is pretty simple.

public class RegistrationViewModel : BaseViewModel
    {
        private LanguageModel _selectedLanguage;
        private IWebServicesRepository webServicesRepository;

        public LanguageModel LanguageList { get; set; } = new LanguageModel();

        public RegistrationViewModel()
        {
            webServicesRepository = new WebServicesRepository();
            getLanguages();
        }

        public Command NextCommand { get; set; }
        public LanguageModel SelectedLanguage
        {
            get => _selectedLanguage;
            set { _selectedLanguage = value; OnPropertyChanged(); }
        }

        public async void getLanguages()
        {
            LanguageList = await webServicesRepository.GetLanguageList();
        }
}

Contribution Attempt Failure

$
0
0

Hi,
I have tried to participate in fixing bugs but I have already spent 4 days trying to build the Xamarin.Forms successfully and I barely succeeded.
And still I have piles of questions.
I surfed the net for some document to guide me through setting up the project and understand the flow but resources were very limited and expired. One of them was talking about Bugzilla which apparently the Xamarin development team has dumped long time ago.
I think 4 days of each excited developer is a lot to waste. And I am sure a lot of people would give up on contributing by then.
Suggestions:
1- I strongly suggest to create a special Forum for Xamarin Contributors
2- Provide clear and up to date steps to open Xamarin project successfully. Like:
2-a- List required Nuget package sources should be specified
2-b- List required Visual Studio settings should be specified
2-c- List required Android sdk and settings should be specified.
2-d- List errors that do not go away but you still can work with their existence should be noted.
3- Tutorials should be created

A forum is really important and necessary.
I am sure if the above is available , you are going to get thousands of contributors

Update data in a master page.

$
0
0

For example. The app consist of MasterDetailPage , first is a master with the Personal image(Image component) like an Avatar, second is profile page like Detail Page with ProfileModelView like BindingContext object. If the profile page is updated how can we reflect this updates on the master page ? Correct approach.

Access Image inside a View Content

$
0
0

Hi,

I have a ListView

Inside a ListView I have an Image and I have no problem accessing it using:

Image FavoriteImage = (Image)sender;
FavoriteImage.Source = "Favorite.png";

but the problem comes when I want to access this button and try to change the Image source inside it.

<SyncfusionButtons:SfButton x:Name="ButtonHomePageLike" Grid.Column="1" HeightRequest="25" WidthRequest="25" BackgroundColor="White" BorderWidth="0" Clicked="ButtonHomePageLike_Clicked">
    <SyncfusionButtons:SfButton.Content>
        <Grid HorizontalOptions="Center" VerticalOptions="Center">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Image Grid.Row="0" x:Name="ImageButtonHomePageLike" Source="LikeDefault.png" WidthRequest="25" HeightRequest="25" Aspect="AspectFit" HorizontalOptions="Center" VerticalOptions="Center">
                <Image.Style>
                    <Style TargetType="{x:Type Image}">
                        <Style.Triggers>
                            <DataTrigger TargetType="Image" Binding="{Binding ad_liked}" Value="1">
                                <Setter Property="Source" Value="Liked.png"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>
            </Image>
        </Grid>
    </SyncfusionButtons:SfButton.Content>
</SyncfusionButtons:SfButton>

I tried this:

SfButton senderButton = (SfButton)sender;
Grid gridEditor = senderButton.Children[0] as Grid;
Image imagebutton = gridEditor.Children[0] as Image;
imagebutton.Source = "Favorite.png";

but I am getting:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Kindly help..

Thanks,
Jassim

Error tryng to archive app xamarin forms: The "LinkAssemblies" task failed unexpectedly.

$
0
0

I getting error when I try to archieve my xamarin forms app, it seems to be something with the acr.user dialogs
here is the error That I get:

Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Drawing.Color' (defined in assembly 'Acr.UserDialogs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Drawing.Color
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance)
at Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
at Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
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)
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
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() mussika.Android

Which version of SQLite to use when switching from PCL to NET Standard

$
0
0

I currently have a project that has a data PCL that uses SQLite.Net-PCL. When I changed the target to .NET Standard 1.5 it doesn't look like the SQLite library is compatible. What is the recommended version of SQLite to use with .NET Standard for a cross platform app (iOS, Android, UWP)

Thanks


Integrate OAuth2 in Xamarin with WEB API

$
0
0

Hello,

I posted this in "Libraries, Components, and Plugins" and I think that was wrong.
I apologize in advance for any dumb questions or if I'm posting in the wrong location, im new to this forum.

I have a question regarding the integration between OAuth2Authenticator and Web API.
So currently I have a standard ASP.Net Web API running and I use POST/GET/PUT/DELETE methods from my Xamarin mobileapp to register users, change users etc.

I've managed to, with 0Auth2Authenticator, get a working Google and Facebook authentication. I get a access_token in return and that token is used to get profile information, works like a charm.

My only problem is HOW do i save that information in my Web API so that I can know who has registrered through social media login? I understand that some people don't want to save that information anywhere, but I would like to so I can save their settings and their activity.

I Understand that I should be using the /api/Account/RegisterExternal url of the WebAPI, but there are only tutorials, documentation and guides for that using a web application. and in thoose cases they use the customized URL combination of your web api webpage (eg: h t t p : / / WEBSITE.COM/api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=REDIRECT_URL&state=SOME_STRANGE_ID_FROM_WEB_API)

Please could someone guide me to any information?

/Esse

Xamarin Form IAP error the application is not configured for billing through Google Play

$
0
0

I am receiving the above error [0:] Error: Plugin.InAppBilling.Abstractions.InAppBillingPurchaseException: Unable to process purchase.

I am using Plugin.InAppBilling library.
My code looks like this.
public async Task PurchaseItem(string productId, string payload)
{
var billing = CrossInAppBilling.Current;
try
{
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);
if (!connected)
{
//we are offline or can't connect, don't try to purchase
return false;
}

                //check purchases
                var purchase = await billing.PurchaseAsync(productId, ItemType.InAppPurchase, payload);

                //possibility that a null came through.
                if (purchase == null)
                {
                    Console.WriteLine("Purchase canceled!");
                }
                else if (purchase.State == PurchaseState.Purchased)
                {
                    var id = purchase.Id;
                    var token = purchase.PurchaseToken;
                    var state = purchase.State;
                    return true;
                }
            }
            catch (InAppBillingPurchaseException purchaseEx)
            {
                //Billing Exception handle this based on the type
                Debug.WriteLine("Error: " + purchaseEx);
            }
            catch (Exception ex)
            {
                //Something else has gone wrong, log it
                Debug.WriteLine("Issue connecting: " + ex);
            }
            finally
            {
                await billing.DisconnectAsync();
            }
            return false;
        }

For info all the below are checked

AndroidManifest must include "com.android.vending.BILLING" permission.
APK is built in release mode.
APK is signed with the release certificate(s). (Important: with "App Signing by Google Play" it only works if you download directly from GooglePlayStore!)
APK is uploaded to alpha/beta distribution channel (previously - as a draft) to the developer console at least once. (takes some time ~2h-24h).
IAB products are published and their status set to active.
Test account(s) is added in developer console.
My testing app is the same that is currently published in the Play Store

Android archive (.apk)

$
0
0

Hi, I'm trying to get apk file using Archive.
I'm getting the following error:

The archiving process has failed.
The preprocessor token 'rootnamespace' has been given more than one value. Choosing 'MyProject.Droid' as the value.
The preprocessor token 'assemblyname' has been given more than one value. Choosing 'MyProject.Android' as the value.
The preprocessor token 'fullpath' has been given more than one value. Choosing 'D:\MyProject\MyProject.Android' as the value.
The preprocessor token 'outputfilename' has been given more than one value. Choosing 'MyProject.Android.dll' as the value.
The preprocessor token 'filename' has been given more than one value. Choosing 'MyProject.Android.csproj' as the value.
MSB4094: "obj\Release\90\MyProject.Android.dll;obj\Release\90\MyProject.Android.dll" is an invalid value for the "OutputAssembly" parameter of the "Csc" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".

I spent hours trying to search for a solution with no luck.
Thanks in advance

Help with Acr.UserDialogs with Prism and iOS 13.0 issue

$
0
0

My app suddenly throws exceptions every time I use Acr.UserDialogs in iOS.

System.NullReferenceException: Object reference not set to an instance of an object
at BigTed.ProgressHUD.PositionHUD (Foundation.NSNotification notification) [0x000d9] in <529e74e349834b0f9cc9bd7376eedc13>:0
at BigTed.ProgressHUD.ShowProgressWorker (System.Single progress, System.String status, BigTed.ProgressHUD+MaskType maskType, System.Boolean textOnly, BigTed.ProgressHUD+ToastPosition toastPosition, System.String cancelCaption, System.Action cancelCallback, System.Double timeoutMs, System.Boolean showContinuousProgress, UIKit.UIImage displayContinuousImage) [0x00241] in <529e74e349834b0f9cc9bd7376eedc13>:0
at BigTed.ProgressHUD+<>c__DisplayClass18_0.b__0 () [0x00000] in <529e74e349834b0f9cc9bd7376eedc13>:0
at Foundation.NSActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/Foundation/NSAction.cs:62

Anyone having issues? I am not totally sure it's caused by iOS 13.0, but I just can't figure it out. I asked the package developers and they marked it as a non-issue.

Here's a sample:
https://github.com/stesvis/AcrTest

Calling UserDialogs.Instance.Loading works in the code behind, ViewModel constructor, Prism OnAppearing but it blows up in Prism OnNavigatedTo.

Any help would be greatly appreciated, or am I the only one having this issue?

Android Archive (.apk)

$
0
0

Hi, I'm trying to get apk file using Archive.
I'm getting the following error:

The archiving process has failed.
The preprocessor token 'rootnamespace' has been given more than one value. Choosing 'MyProject.Droid' as the value.
The preprocessor token 'assemblyname' has been given more than one value. Choosing 'MyProject.Android' as the value.
The preprocessor token 'fullpath' has been given more than one value. Choosing 'D:\MyProject\MyProject.Android' as the value.
The preprocessor token 'outputfilename' has been given more than one value. Choosing 'MyProject.Android.dll' as the value.
The preprocessor token 'filename' has been given more than one value. Choosing 'MyProject.Android.csproj' as the value.
MSB4094: "obj\Release\90\MyProject.Android.dll;obj\Release\90\MyProject.Android.dll" is an invalid value for the "OutputAssembly" parameter of the "Csc" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".

I spent hours trying to search for a solution with no luck.
Thanks in advance

How to play audio in xamarin forms?

$
0
0

I am trying to play an audio file which is stored locally. I am using Xam.Plugin.SimpleAudioPlayer for playing audio. For UWP and Android, added the files in the Assets folder with the Build Action set to Content and Android Asset respectively.

My Code:

var assenbly = typeof(App).GetTypeInfo().Assembly;
Stream audioStream = assenbly.GetManifestResourceStream("audio.mp3");
var audio = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
audio.Load(audioStream);
audio.Play();

But getting an exception in android and UWP, didn't check in IOS.

UWP Exception:

Exception thrown: 'System.ArgumentException' in Plugin.SimpleAudioPlayer.dll
exception:>>System.ArgumentException: Value does not fall within the expected range.
at Windows.Media.Core.MediaSource.CreateFromStream(IRandomAccessStream stream, String contentType)
at Plugin.SimpleAudioPlayer.SimpleAudioPlayerImplementation.Load(Stream audioStream)
at AudioPlay.MainPage..ctor()

Android Exception:

[0:] exception:>>System.NullReferenceException: Object reference not set to an instance of an object.
at Plugin.SimpleAudioPlayer.SimpleAudioPlayerImplementation.Load (System.IO.Stream audioStream) [0x00050] in C:\dev\open\Xamarin-Plugins\SimpleAudioPlayer\SimpleAudioPlayer\Plugin.SimpleAudioPlayer.Android\SimpleAudioPlayerImplementation.cs:100
at AudioPlay.MainPage..ctor () [0x00037] in C:\Users\sonub\source\repos\AudioPlay\AudioPlay\AudioPlay\MainPage.xaml.cs:23
09-27 12:25:53.918 D/Mono (31523): Assembly Ref addref FormsViewGroup[0x7288bdf300] -> Java.Interop[0x7288fb5b80]: 5

I am using .mp3 file. Am I missing something in this implementation? Please help me to fix this issue?

bold string value issue

$
0
0

I have a string that contains ** instead of bold. I need to Bold these text by replacing **.

I need to bold only This and text words.

I found some example and tried. but not working.

these two not working


Use the parameters passing from shell to content page

$
0
0

I have a problem of reading the parameters get by the shell to the content page.

I have registered the route and pass my parameters from shell to content page like this
await Shell.Current.GoToAsync($"location?code={loc}");

I get the data in my content page like this
[QueryProperty("LocationCode", "code")]
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
private string lc;
public string LocationCode { get {return lc; } set { lc = Uri.UnescapeDataString(value); } }

var check = LocationCode//////// At here I cant get the value of my Location Code.

Any guides on how to fix this or any better ways to get the parameters from the shell?

Emulator Not Working

$
0
0

i am using windows 7 64 bit on my pc i have installed vs 2019 i am new to xamrin i am doing a test run i am not getting any error but but my emulator is not showing any output

How to play Video using Plugin.MediaManager.Forms?

$
0
0

I am trying to play a video using Plugin.MediaManager.Forms and I am referring to this blog.

Step 1: Added Plugin.MediaManager and Plugin.MediaManager.Forms.

Step 2: XAML code - Added a VideoView

<?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:VideoPlayerApp"  
             x:Class="VideoPlayerApp.MainPage"  
             xmlns:forms="clr-namespace:Plugin.MediaManager.Forms;assembly=Plugin.MediaManager.Forms"  
             Title="Video Player">  

    <ContentPage.Content>  
        <StackLayout>  

            <Label Text="Xamarin Forms"  
                   FontSize="40"  
                   TextColor="Azure"/>  
            <Label Text="Video Player Application"  
                   FontSize="58"  
                   TextColor="BlueViolet"/>  
            <Button x:Name="PlayStopButtonText"  
                    Text="Play"   
                    Clicked="PlayStopButton"  
                    TextColor="BlueViolet"/>  
            <forms:VideoView HeightRequest="202"  
                             WidthRequest="202"/>  
        </StackLayout>  
    </ContentPage.Content>
</ContentPage>   

Step 3: xaml.cs code

public partial class MainPage : ContentPage
    {
        private string videoUrl = "https://sec.ch9.ms/ch9/e68c/690eebb1-797a-40ef-a841-c63dded4e68c/Cognitive-Services-Emotion_high.mp4";
        public MainPage()
        {
            InitializeComponent();
        }

        private void PlayStopButton(object sender, EventArgs e)
        {
            if (PlayStopButtonText.Text == "Play")
            {
                CrossMediaManager.Current.Play(videoUrl, MediaFileType.Video);

                PlayStopButtonText.Text = "Stop";
            }
            else if (PlayStopButtonText.Text == "Stop")
            {
                CrossMediaManager.Current.Stop();

                PlayStopButtonText.Text = "Play";
            }
        }
    }

But getting error on this step:

Error CS0103 The name 'MediaFileType' does not exist in the current context

Step 4: Also added VideoViewRenderer.Init();in MainActivity.cs, AppDelegate.cs and MainPage.xaml.cs. But getting following error for this initialization.

The name 'VideoViewRenderer' does not exist in the current context

Am I missing something? I checked some other blogs but same error occuring. I have added a sample project here.

Book page flipping in xamarin forms.

Images with url source not showing on Android

$
0
0

I have used the visual studio with version 16.2, yesterday I updated Visual Studio to the new 16.3 version and now, all the images that have an url source, don't show it on Android. Before to update the visual studio version, all the images work perfectly.

  • I checked the HttpClient Implementation, and I have (Android) but I had tested with (Administrativo).
  • I checked the SSL/TLS Implementation, and I have (Native TLS 12+)
  • I checked all the Xamarin.Android packages and I had to update it to the v28.0.0.3 and now I have all the android packages at the last version

In the iOS emulator, I can see the images, but Android no...

Can anyone help me???

Viewing all 89864 articles
Browse latest View live


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