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

SignaturePad within a template selector

$
0
0

Hello all, I am having an issue with my signaturepad (version 3.0) where when it is part of a data template, if I need to scroll, then it acts as if there is just one shared signature pad. That is, whatever change I do to one, affects the other one that is out of the screen's view. If they are side by side, then there is no problem

I was wondering if anyone has encountered this issue before. One interesting thing, I am not sure if that is just how selectors work, but ondisppearing is called each time the signaturepad is no longer visible within the screen (fair). However, OnAppearing is only called once for the initial render and never again.


Xamarin Forms Language issues on Android

$
0
0

I'm going crazy for hours on an evil problem!!!

I've created a new Xamain Forms prj on Visual Studio for Mac (last version and last update).

I have three AppResources files for corrispondent languages: - AppResources.resx (for default) - AppResources.it.resx (for italian) - AppResources.es.resx (for spanish)

On IOS simulator, works all good. On Android I see always the default string.

This is my simple data on AppResources file:

AppResources.resx:

Default

AppResources.es.resx:

Espanol

AppResources.it.resx:

Italiano

Why on IOS works perfectly and on Android I can see only "default"?!?

Xamarin Forms Language issues on Android

$
0
0

I'm going crazy for hours on an evil problem!!!

I've created a new Xamain Forms prj on Visual Studio for Mac (last version and last update).

I have three AppResources files for corrispondent languages: - AppResources.resx (for default) - AppResources.it.resx (for italian) - AppResources.es.resx (for spanish)

On IOS simulator, works all good. On Android I see always the default string.

This is my simple data on AppResources file:

AppResources.resx:

Default

AppResources.es.resx:

Espanol

AppResources.it.resx:

Italiano

Why on IOS works perfectly and on Android I can see only "default"?!?

Image Aspect AspectFill

$
0
0

Hello,

Coming across a sudden, new issue that I can't quite figure out. Loading an image and setting aspect to "AspectFill" within a set height. Was working well previously and actually same code works well on a different form. Now...only in Android, the AspectFill is not working. "Fill" will work.

<StackLayout Padding="0,5,0,0">
   <Image
       x:Name="imgRoute"
       Aspect="AspectFill"
       HeightRequest="200"
       HorizontalOptions="Fill"
       Source="{Binding RouteThumbnail}" />
</StackLayout>

Any advice? Can't see what has changed and why it only affects Android; iOS displays image as expected.
Appreciate it.

how to Upload file To Web service ?

$
0
0

Hi
I trying to upload files from the mobile app using Web Service.
But after Pick File I could not send the file to the web service
Suppose the web service is located at the following address:
www.haythamweb.com/myServices.asmx/uploadfiles
And I have two parameters:
byte[] fileContent, string fileName

This is the code for the web service:
[WebMethod]
public string UploadFile(byte[] fileContent, string fileName)
{
try
{
MemoryStream ms = new MemoryStream(fileContent);
FileStream fs = new FileStream
(System.Web.Hosting.HostingEnvironment.MapPath
("~/TransientStorage/") +
fileName, FileMode.Create);
ms.WriteTo(fs);
ms.Close();
fs.Close();
fs.Dispose();
return "OK";
}
catch (Exception ex)
{
// return the error message if the operation fails
return ex.Message.ToString();
}
}

This is the code for the upload button I could not complete:

private async void Button_Clicked(object sender, EventArgs e)
{
var file = await CrossFilePicker.Current.PickFile();

        if (file != null)
        {
            lbl.Text = file.FileName ;
        }

        String URI = "http://haythamweb.com/myServices.asmx/uploadfiles";
       ...........................
       ...........................
       ...........................
       ...........................
    }

can you help me

Cloud not launch Xamarin.Launcher

$
0
0

Dear all,

I am facing an issue with the launch iOS simulator.

The following image appeared when I tried to debug.

How can I fixed it?

Environment

  • macOS Catalina 10.15.4
  • Visual Studio for Mac
=== Visual Studio Community 2019 for Mac ===

Version 8.6 (build 4520)
Installation UUID: 436d9f64-9f6a-4a97-8b0c-f1f4848e6080
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 610000104

=== Mono Framework MDK ===

Runtime:
    Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
    Package version: 610000104

=== Roslyn (Language Service) ===

3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

=== NuGet ===

バージョン: 5.6.0.6591

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.300/Sdks
SDK バージョン: 3.1.300
MSBuild SDK: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

ランタイム: /usr/local/share/dotnet/dotnet
ランタイム バージョン:
    3.1.4
    2.1.18

=== Xamarin.Profiler ===

バージョン:1.6.15.68
場所: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

バージョン: 11

=== Apple Developer Tools ===

Xcode 11.5 (16139)
Build 11E608c

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 13.18.1.31 (Visual Studio Community)
Hash: b3eedfed9
Branch: d16-6
Build date: 2020-04-09 10:22:36-0400

=== Xamarin Designer ===

Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

=== Xamarin.Android ===

バージョン:10.3.1.0 (Visual Studio Community)
コミット:xamarin-android/d16-6/3fe860a
Android SDK: /Users/toyoshima takumi/Library/Developer/Xamarin/android-sdk-macosx
    サポートされている Android バージョン:
        インストールなし

SDK Tools のバージョン: 26.1.1
SDK プラットフォーム ツールのバージョン: 29.0.5
SDK ビルド ツールのバージョン: 29.0.2

ビルド情報: 
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/toyoshima takumi/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL のコードは以下から入手できます。
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-04-30 04:01:22 UTC

=== Android Device Manager ===

Version: 16.6.0.95
Hash: 45d17b5
Branch: remotes/origin/d16-6
Build date: 2020-04-30 04:01:42 UTC

=== Build Information ===

Release ID: 806004520
Git revision: 9c92c7baceef7771f8dcf5c86e1e1a66fdc26182
Build date: 2020-05-18 10:05:00-04
Build branch: release-8.6
Xamarin extensions: 9c92c7baceef7771f8dcf5c86e1e1a66fdc26182

=== Operating System ===

Mac OS X 10.15.4
Darwin 19.4.0 Darwin Kernel Version 19.4.0
    Wed Mar  4 22:28:40 PST 2020
    root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64


ITMS-90809:Deprecated API Usage-Apple will stop accepting submissions of apps that use UIWebView API

$
0
0

Yesterday, I uploaded my App to TestFlight and after a while, Apple sent me this warning:

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs. See https://developer.apple.com/documentation/uikit/uiwebview for more information.

I am using WebView for showing HTML data in my app. Also, I have used WebView for playing audio and video. So is this warning reject my app when submitting for review or should I change these features with some other APIs?

In this link provided by AppStore, telling about use WKWebView instead of UIWebView, I tried that and no such property found on XAML. Should I need to install any packages for getting that feature? Also, by using WKWebView, is it possible to play audio, video and showing HTML data in the app?

Launching Running app Soon but wish to give free trail before charge of app store

$
0
0

Hi I wish to give my users of my new running app seven days free trail before charging their debit card in ios store. Is this sort of functionality done at the store level or do I also need to code for it in my xamrain forms app.

Also is their any hosted sites like appcentre for your privacy policies screen shots and all.


Post download latest visual studio 19 getting some errors

$
0
0

05-23 00:20:54.865 W/monodroid-assembly(15792): typemap: unable to find mapping to a managed type from Java type 'java/util/Collections$UnmodifiableCollection$1'
05-23 00:20:54.870 W/monodroid-assembly(15792): typemap: unable to find mapping to a managed type from Java type 'android/app/SharedPreferencesImpl'
05-23 00:20:54.870 W/monodroid-assembly(15792): typemap: unable to find mapping to a managed type from Java type 'android/app/SharedPreferencesImpl$EditorImpl'
05-23 00:20:54.872 W/monodroid-assembly(15792): typemap: unable to find mapping to a managed type from Java type 'android/app/SharedPreferencesImpl'
05-23 00:20:54.872 W/monodroid-assembly(15792): typemap: unable to find mapping to a managed type from Java type 'android/app/SharedPreferencesImpl$EditorImpl'

SimpleAudioPlayer stops working

$
0
0

Hi. I created a class to add sound effects to my program. It works great.... and then just quits. I am not certain as to why, but it seems to be occuring when a sound is called again before the first sound ends, but I am not certain of this.

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;

namespace Potocracy.Classes
{
    public class Sounds
    {
        protected Plugin.SimpleAudioPlayer.ISimpleAudioPlayer sound_KaChing;
        protected Plugin.SimpleAudioPlayer.ISimpleAudioPlayer sound_Train;

        public Sounds()
        {
            var assembly = typeof(App).GetTypeInfo().Assembly;

            sound_KaChing = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            sound_KaChing.Load(assembly.GetManifestResourceStream("Potocracy.Resources.kaching.mp3"));

            sound_Train = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            sound_Train.Load(assembly.GetManifestResourceStream("Potocracy.Resources.train.wav"));
        }

        public void KaChing()
        {
            if (!sound_KaChing.IsPlaying)
                sound_KaChing.Play();
        }

        public void Train() => sound_Train.Play();
    }
}

When I played my game, if KaChing was called twice the sound quit working and you could never hear any sound again (including the train sound). So, I added the code:

            public void KaChing()
            {
                if (!sound_KaChing.IsPlaying)
                    sound_KaChing.Play();
            }

After that, you could hear the KaChing sound once, but no sounds after that would work. Even though, stepping through with the debugger, Play() would execute.

Any ideas?

Thank you.

Push Notification in Xamarin Forms for a specific USER

$
0
0

I have followed this https://docs.microsoft.com/en-za/xamarin/xamarin-forms/data-cloud/azure-services/azure-notification-hub to the core and I am able to send push notifications in Azure to many devices e.g Android devices.

I want to be able to register a user to the hub (I assume by calling this method OnNewToken in FirebaseService) but I don't know how to go about doing that from the PCL project and if it's the right thing to do.

It'd be great if someone with greater knowledge on how to properly implement the OnNewToken method and call it could share that knowledge with me. I appreciate it

How to read a backspace in an Entry from Xamarin.Forms?

$
0
0

I can't for the life of me capture the backspace! I need to capture a backspace, even if the field is empty. Am I doing something wrong?

public class CustomEntryRenderer: EntryRenderer, Android.Views.View.IOnKeyListener
{
    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
    {
        base.OnElementChanged(e);

        if (Control == null) 
        {
            return;
        }

        var entry = (CustomEntry)Element;

        Control.SetOnKeyListener(this);

        Control.KeyPress += (s, arg) => { 
            System.Diagnostics.Debug.WriteLine("OnElementChanged KeyPress");
        };

        Control.TextChanged += (s, ev) => { 
            System.Diagnostics.Debug.WriteLine("OnElementChanged TextChanged"); 
        };

        Control.EditorAction += (s, ev) =>
        {
            System.Diagnostics.Debug.WriteLine("EditorAction EditorAction");
        };

        Control.SetOnEditorActionListener(this);


    }

    public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
    {
        System.Diagnostics.Debug.WriteLine("OnKeyPreIme");
        return base.OnKeyPreIme(keyCode, e);
    }

    public override bool OnKeyUp(Keycode keyCode, KeyEvent e)
    {
        System.Diagnostics.Debug.WriteLine("OnKeyUp");
        return base.OnKeyUp(keyCode, e);

    }



    protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (Control == null)
        {
            return;
        }

        var entry = (CustomEntry)Element;

        Control.SetOnKeyListener(this);

        Control.KeyPress += (s, arg) =>
        {
            System.Diagnostics.Debug.WriteLine("OnElementPropertyChanged KeyPress");
        };

        Control.TextChanged += (s, ev) =>
        {
            System.Diagnostics.Debug.WriteLine("OnElementPropertyChanged KeyPress");
        };

        Control.EditorAction += (s, ev) => { 
            System.Diagnostics.Debug.WriteLine("OnElementPropertyChanged EditorAction");
        };

    }

    bool IOnKeyListener.OnKey(Android.Views.View v, Keycode keyCode, KeyEvent e)
    {
        System.Diagnostics.Debug.WriteLine("OnKey");
        return true;
    }


}

Scrollview works with slight problem

$
0
0

I have a pop-up working just fine but the problem occurs when the keyboard is present on the screen. Attached are my screenshots of what is happening and I am unsure of how to solve it. The popup window goes behind MGMT Notes/Detail Notes/Postmortem. I am unsure of how it to remain on top of the layer.

Would you need to see the code of the Main Detail page or the popup?

Access Field Value of Raw View in a C# ObservableCollection

$
0
0

I am writing to ask how best to access a value Heading in Raw View section of below C# ObservableCollection cBeanList;

Please see attached screen shot of debug mode for additional details of existing ObservableCollection layout;

public static ObservableCollection cBeanList = new ObservableCollection();

Type SingleBeanGroup is specified as follows: public class SingleBeanGroup : List, INotifyPropertyChanged

  • and contains public string Heading { get; set; }

Type SingleBean is simply a class with values of string and bool :

public class SingleBean
{
public string Field1 { get; set; }

    public bool Selected { get; set; }

    public SingleBean()
    {
    }

}

Following code snippet works well to access Field1 - which is selected by user, via a Xaml page Check Box:

foreach (var data in MonkeysViewModel.cBeanList)
{
for (int i = 0; i < data.Count; i++)
{
if (data[i].Selected == true)
{
await DisplayAlert("Alert", "Model Tapped: " + data[i].Field1, "OK");
}
}
}

Thanks in advance for any insight, guidance;

SkiaSharp PNG Header

$
0
0

Hi,

Apologies if this seems a bit vague!

I can create an image in SkiaSharp and save it as a PNG file. This is only saved at 96 dpi, but having looked into PNG header files, I know I can change values in the header to make it 200dpi - this is important as the image is printed on a thermal printer, and 96dpi means the print is pixelated.

The problem I have (this is the vague bit, need more research) is the PNG header has sBit in it, whereas practising editing the header contains sRPG in the header. If I open the image in say Paint.NET and save it, the header changes from sBit to sRPG.

So my question is how can I change the dpi of the PNG when the header file contains sBit in it? This is my last stumbling block in my project, and am rather lost with it!!

Many thanks


How do I reference one XAML MergedDictionary from another?

$
0
0

I am struggling with XAML Merged Dictionaries. Is it possible to get something like the following working?

File Colours.xaml contains this:

<?xml version="1.0" encoding="utf-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

    <Color x:Key="WarningTextColour">#FF0000</Color>

</ResourceDictionary>

Another file Text.xaml contains something like this:

<?xml version="1.0" encoding="utf-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <Style x:Key="WarningTextStyle" TargetType="Label">
        <Setter Property="TextColor" Value="{StaticResource WarningTextColour}"/>
        <Setter Property="FontSize" Value="Large"/>
    </Style>
</ResourceDictionary>

Then somewhere like my main App.xaml file, I bring them together like this:

<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="myProject.Forms.App">

    <Application.Resources>
        <ResourceDictionary Source="Styles/Colours.xaml"/>
        <ResourceDictionary Source="Styles/Text.xaml"/>
    </Application.Resources>

</Application>

I've read the guides and tried various combinations of syntax, trying both the old and the new ways, but I can't find a way to do this. I am beginning to wonder if I am maybe approaching this completely the wrong way.

Even with all my XAML set to compile, the project builds okay (which is disappointing if I have something wrong), but the MainPage.xaml that tries to use the WarningTextStyle gives an exception.

Any help or advice would be very much appreciated.

Kind wishes ~ Patrick

Extremely long build with xamarin forms android

$
0
0

Hi,

I have a xamarin forms project with Xamarin.Forms v4.5 with Vs 2019.

And I compile with using Android 10.0 Q.

When I build in debug mode it's extremely long.

In my output it hangs 10 minutes on the line:

1>------ Build started: Project: Dev.Mobile.Android, Configuration: Debug Any CPU ------

Once it passes this step it's quite fast.

My setup for the build is:

What could bhe the issue? How can I investigate?

Thanks,

Xamarin Forms... MVVM and Observable Collection Issue (perhaps)

$
0
0

I have built a prototype Forms App for Android. It's a potential replacement for a WebForms app. The concept is, I begin with a JSON file (as a datasource) for local non-internet functionality. This is a READ-ONLY file, from the users perspective... The data is retrieved and updated as needed from a web service... (the url is contained within each JSON Entity... When the app opens, there is default JSON information the app can start with... Then, there is a date field and some ModelView logic that retrieves new data as needed, and is updated in the "live" entity (that which was loaded initially). When the app Sleeps or Stops the current ObservableCollection is serialized to JSON, with any subsequent data changes and the file itself is saved...

Everything works as expected... Except... In the json file there are approximately 7 primary entities. Only 4 of them require regular updates because they have hot changing information... This I wish to display in a subset on the startup Navigation page in a marquee... I have all the bits in place and it all works, BUT only when the full list is queried...

ModelView (psuedo code)

PrimaryList = new ObservableCollection(FileOperastions.GetFullPrimaryLIst());

// GetFullPrimaryList returns a "list of primary model" items. I then bind this list to the binding context of the view, add it to the CarouselView in Xamarin and Walla! It works... As the background code on the primary thread executes, the Observable entities are updated from the URLs in the entity, and the displays are changed, viewable and subsequently saved... Perfect!

The problem appears to happen when I use a select query for only the 4 primary items that require notification... So;

PrimaryList = new ObservableCollection(FileOperastions.GetFullPrimaryLIst().Where(l => l.infourl.Contains("http")).ToList());

  • My list now contains just the 4 entities in question as desired.
  • The CarouselView displays these 4 entities as desired, and SOME of the entities show updates while others do not.
  • Breakpoints in the WebClient DownloadStringAsync callback verify that the data is properly retrieved and the entity is updated properly...
  • But, the data is not shown, as it is when the full list is in place...

has anyone else run into this issue? Do I need to raise a CollectionChanged event here... It's odd it does not work for a subset, but works for the full list... In terms of code... I change NOTHING else other than the line of code displayed above... I have tried creating a separate function of course, but whether it is a linq query as above or a function that returns a NEW list makes no difference... the result is the same... however, this also breaks the MVVM construct I am trying to stay within...

Best way to store string based on OS and version

$
0
0

Hi all,
whats the best way to store a string (in my case Google AdMob Id) based on version (Debug or Release) and OS (iOS or Android)? So I have 4 different values. I tried with "if DEBUG" or "On Platform" but did not find the best result yet. I think I'd prefer to store all the values in App.xaml but did not get it to work with all these combinations (Debug/Release and iOS/Android).
Many Thanks!

MessagingCenter.Unsubscribe occasionally fails to unsubscribe

$
0
0

Is there a situation where calling Unsubscribe can fail?

I have an application which listens for connection then allows the remote to register as a remote monitor. Any status updates will then be sent to this monitor using the MessagingCenter.

The monitor "RemoteMonitor" creates a subscription to a message within it's constructor and removes this subscription when the underlying connection is disconnected. For test purposes the remote is creating many connections (50 ish) then being disconnected and a status update is being sent to detect the disconnections.

`internal RemoteMonitor(string id, HttpConnection sourceConnection) : base("remotemonitor", MappedObjectType.NotSerialisable)
    {
        Log.GetInstance().WriteInfo(GetType(), "{" + UId.ToString() +"} Adding remote monitor to parent conId{" + m_sourceConnection.UId + "}"); 
        m_sourceConnection.ConnectionClosed += M_sourceConnection_ConnectionClosed;
        MessagingCenter.Subscribe<StatusMap>(this, MessageStrings.MedaiPlayerStatusChanged, (sender) => SendStatus(sender));
    }

private void M_sourceConnection_ConnectionClosed()
    {
        Log.GetInstance().WriteInfo(GetType(), "{" + UId.ToString() + "} Removing remote monitor from parent conId{" + m_sourceConnection.UId + "}");
        MessagingCenter.Unsubscribe<StatusMap>(this, MessageStrings.MedaiPlayerStatusChanged);
    }`

Looking at the log we can see that connection closed has been called for this instance
RemoteMediaPlayer.Models.Map.RemoteMonitor(13500): {37} Removing remote monitor from parent conId{36}

And only one instance of the Subscription was ever created
RemoteMediaPlayer.Models.Map.RemoteMonitor(13500): {37} Adding remote monitor to parent conId{36}

Yet SendStatus continues to be called

Android version 4.4.2
Xamarin Forms 4.6.0.726

Viewing all 89864 articles
Browse latest View live


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