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

Keyboard Input and WebView

$
0
0

Is it possible to send a Keyboard String to the Webview? Like you click a button and it sends a "123" as Keyboard Input to the Website in the Webview?


How perform drag and drop in xamarin forms ?

$
0
0

I have multiple list of Images. now i want to drag an image from one list and drop it to other list. and remove that image from previous list and add it to new list.how i can achieve this ?I'm using collection view.Is there Nuget package ?

ListView Binding Options

$
0
0

I'm creating a ListView with a DataTemplate in code. I'm getting the text values to bind to from a name/paired dictionary that in turn gets them from a JSON file via a service. The problem I can't figure out is how to do the binding. In a perfect world I'd just create a DataTable from the same name/paired dictionary and bind the ListView to that in code, but from what I'm reading you can't bind a DataTable to a ListView so what other options do I have? I could create a class with let's say X properties and just say we are limited to dynamically creating X properties to bind to, but that seems a bit cheesy.

The ultimate idea is that we can change what is displayed by changing the JSON it reads from a service and not have to change the code.

Any other suggestions?

[xfx combox] Dynamically insert an item that doesn't exist in the ItemSource

$
0
0

So the list contains elements: ["Company1", "Company2", "Company3"].

When the user's start typing, the popup shows up with those elements. However, I want user to be able to insert the new item: "Company4", but the user is not able to do it!

Binding text label on a home page to a timer

$
0
0

We have a really simple app, the idea is the timer will update a label on the home screen depending on different configuration within the mobile app. I have created the binding and can update the homepage from it's self but not from the timer. I think what is missing is a OnChange within the home page to detect if the string has changed.

Display layout code, bind the label to the name "LabelText"

<Label                
Text = "{Binding LabelText, Mode=TwoWay}"
x:Name="MainPageStatusText"
HorizontalOptions="CenterAndExpand"
Grid.Row="2"
Grid.Column="0" 
Grid.ColumnSpan="6"
VerticalOptions="CenterAndExpand"
TextColor="White"
FontSize="Medium"/>

=====
This is the class file to link the text string to the label, I can see it been called from the different places but when it's called from the app.cs it does not work

using System;
using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;

namespace Binding_Demo
{
    public class MyClass : INotifyPropertyChanged
    {
        protected void OnPropertyChanged(PropertyChangedEventArgs e)
       { PropertyChanged?.Invoke(this, e); }

       protected void OnPropertyChanged(string propertyName)
       { OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); }

       public event PropertyChangedEventHandler PropertyChanged;

      private string labelText;

      public string LabelText
      {
         get {
            return labelText;
            }


        set
        {
            labelText = value;
            OnPropertyChanged("LabelText");

         }
      }
   } 
}

=====
This is the code inside the homepage, this works and I can see it sending data to the text label

    public static MyClass _myClass = new MyClass();
    public Homepage()
    {

        BindingContext = _myClass;
        _myClass.LabelText = "Inside the home page";

    }

======

This is the App.cs code, we start the timer and then want to set the text on the Homepage label. I can see the class been called, but it does not set the text.

 using System;
 using System.Diagnostics;
 using System.Threading.Tasks;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;

 namespace Binding_Demo
 {
 public partial class App : Application
{
    public static MyClass _myClass = new MyClass();

    public App()
    {
        //InitializeComponent();

        Device.StartTimer(TimeSpan.FromSeconds(10), () =>
        {

            Task.Run(() =>
            {
                Debug.WriteLine("Timer has been triggered");

                // !!!!! This is not setting the text in the label !!!!!
                BindingContext = _myClass;
                _myClass.LabelText = "Inside the timer app";

            });
            return true; //use this to run continuously
        });

        MainPage = new NavigationPage(new MainPage());
    }

    protected override void OnStart()
    {
        //

    }

    protected override void OnSleep()
    {
    }

    protected override void OnResume()
    {
        // force app to mainpage and clear the token  


    }
}

}

RSACryptoServiceProvider SignData very slow on some android devices

$
0
0

I have xamarin forms android application. I am expiriencing slow signing, but only on some devices... out of 4 devices I tested, 2 work slow, other 2 take less than a second.
See the code below, last line is very slow... why?

            var data = Encoding.ASCII.GetBytes(zoiTemp);
            var rsaCSP = (RSACryptoServiceProvider)certificate.PrivateKey;
            var cspParameters = new CspParameters();
            cspParameters.KeyContainerName = rsaCSP.CspKeyContainerInfo.KeyContainerName;
            cspParameters.KeyNumber = rsaCSP.CspKeyContainerInfo.KeyNumber == KeyNumber.Exchange ? 1 : 2;

            var rsaAesCSP = new RSACryptoServiceProvider(cspParameters);

            var signature = rsaAesCSP.SignData(data, CryptoConfig.MapNameToOID("SHA256"));  -- this line of code is taking about 10 seconds!!

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>

Is it possible to detect a long tap on a CollectionView item?

$
0
0

I started using the new CollectionView, but I can't figure out how to detect a long tap (and execute a command) on an item in the CollectionView.
So far I've been using the Syncfusion SfListView which comes with a HoldCommand, but i'd like to start using the CollectionView and I need to have that same feature.

Thanks in advance if someone can provide a simple example.


TimePicker catch ok event

$
0
0

I have already created a class for ios which i can catch ok click, is anyone who knows how to create a same class for android?

 public class MyRenderer2 : TimePickerRenderer
    {
        TimePicker _timePickerElement;

        protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement is TimePicker timePickerElement && Control != null)
            {
                _timePickerElement = timePickerElement;

                var toolbar = Control.InputAccessoryView as UIToolbar;
                foreach (var button in toolbar?.Items)
                {
                    if (button.Style == UIBarButtonItemStyle.Done)
                    {
                        button.Clicked -= OnDoneButtonClicked;
                        button.Clicked += OnDoneButtonClicked;
                    }
                }
            }
        }

        private void OnDoneButtonClicked(object sender, EventArgs e)
        {
            MessagingCenter.Send<object>(this, "Hello");
        }
    }

not show image https

$
0
0

<Image Source="https://cdn.vatanbgs.com/Content/Images/Products/460_466/637089327869489423.jpg" 
       WidthRequest="150" HeightRequest="150"></Image>![](https://us.v-cdn.net/5019960/uploads/editor/1v/n06i7lpljpih.png "")

Why doesn't it open on Android 5?

log eeror

Xamarin.Forms performance really this bad?

$
0
0

Hello,

I am orienting on frameworks to build a cross-platform mobile app for Android and iOS, but possibly also UWP. After some research I am considering Ionic, React Native, Xamarin.Native and Xamarin.Forms, with a slight preference for Xamarin.Forms due the amount of code shared, quick development, not having to learn multiple languages, etc. It is going to be a business to customer app and performance and design are key. The app is not going to be really big; login screen, profile page, at most retrieve 100 records from a web service and display them across different views, make some pictures, do some POST requests and that is about it. Doing the research I am reading a lot about Xamarin.Forms performance being bad and also the videos below:

youtube/watch?v=2oPWmvWHYA4
youtube/watch?v=U8GqGJwuRp4

That makes me worried about choosing to work with Xamarin.Forms. I have also seen an read some Xamarin.Forms optimalization videos like:

docs.microsoft/en-us/xamarin/xamarin-forms/deploy-test/performance

Yet it would be really helpful to know Xamarin.Forms experience of other developers. Do other developers have performance issues working with Xamarin.Forms?

Best regards,

Bas

Prevent page closing on navigating to other page

$
0
0

Hello ,

I haven a page with a name "News" with 5 buttons , the Text of the button i get from a Firebase database OnAppearing .

When i click the button it goes to an otherpage with the name "Showingnews"

Depending on the button it is showing some text from the Firebase database.

So far so good no problem , but every time i go from "Showingnews" back to "News" to select another button it is loading the Text from the buttons again because it is in OnAppearing.

How do i fix this so i don't have to download the text of the buttons again until i close the page it self "News" and go to Mainpage

Keep it open but hide or something ?

How to design slide menu in xamarin

$
0
0
I am trying to implement this kind of design as shown in fig on my page, how can I achieve this in Xamarin.forms mainly in shared project. As I am trying to reduce the complexity by doing in platform specific.

I tried using this even https://github.com/XAM-Consulting/SlideOverKit . But the issue is I can't slide in the menu when its open (i.e after touching on page I want the menu to hide) but it doesn't happen. We need to manually drag that out to close it.

So please let me know how to achieve this.

Thanks

How to enable or disable behaviours?

$
0
0

I got this ListView with an Entry inside and I need to enable or disable the behaviour of the enrty when a detect some property in the item that is binding to the ListView.

Here is the ListView

And here is the Behavior

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?


Xamarin.Forms adding custom fonts using ASSEMBLY

$
0
0

Hi,
I am facing a problem when adding the custom font using assembly, the custom font appear well in android but in UWP, the normal font appears. Why is that?
The custom font is EmpeddedResource

`[assembly: ExportFont("alfarooq2.ttf", Alias = "abc" )]


    <Label Text="Welcom to Xamarin" 
       HorizontalOptions="Center" TextColor="Black"
       VerticalOptions="Center" FontSize="40"
           />
</StackLayout>

`

Remove input underline for entry

$
0
0

Hi,

May i know is it possible and how to remove this underline when i type character from keyboard? I have tried with Custom Entry Render and it actually does remove the pink line but not the line underneath the text where I am looking for.

Thanks in advance.

How to get the user's permission to use more than one feature.

$
0
0

In our App I need to ask the user to use several features of their device. For now, let's focus on requesting two Permissions and getting two replies.

In a ViewModel I request permission for the StorageRead and StorageWrite on successive lines of code like this:

bool bOK = await Util.GetStorageReadPermissionAsync().ConfigureAwait(false);
bool bOL = await Util.GetStorageWritePermissionAsync().ConfigureAwait(false);

Those lines in turn call a couple methods (that surely can be improved, but I need to get them to work first).
Typically what happens is that the first one (GetStorageReadPermissionAsync) works (displays a request for access) and the second one (GetStorageWritePermissionAsync) does not.

Here are the methods that do the requesting:

        public static async Task<bool> GetStorageReadPermissionAsync()
        {
            PermissionStatus status = PermissionStatus.Unknown;
            try
            {
                status = await Xamarin.Essentials.Permissions.CheckStatusAsync<Xamarin.Essentials.Permissions.StorageRead>();
                if (status != PermissionStatus.Granted)
                {
                    MainThread.BeginInvokeOnMainThread(async () =>
                    {
                        status = await Xamarin.Essentials.Permissions.RequestAsync<Xamarin.Essentials.Permissions.StorageRead>();
                    });
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format("GetStorageReadPermissionAsync {0}. ", ex.ToString());
                Debug.WriteLine(msg);
                Util.WriteExceptionToSQL(msg);
            }
            bool res = status == PermissionStatus.Granted ? true : false;
            return res;
        }

        public static async Task<bool> GetStorageWritePermissionAsync()
        {
            PermissionStatus status = PermissionStatus.Unknown;
            try
            {
                status = await Xamarin.Essentials.Permissions.CheckStatusAsync<Xamarin.Essentials.Permissions.StorageWrite>();
                if (status != PermissionStatus.Granted)
                {
                    MainThread.BeginInvokeOnMainThread(async () =>
                    {
                        status = await Xamarin.Essentials.Permissions.RequestAsync<Xamarin.Essentials.Permissions.StorageWrite>();
                    });
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format("GetStorageWritePermissionAsync {0}. ", ex.ToString());
                Debug.WriteLine(msg);
                Util.WriteExceptionToSQL(msg);
            }
            bool res = status == PermissionStatus.Granted ? true : false;
            return res;
        }       

With SkiaSharp , How to move the tiled image

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.

Viewing all 89864 articles
Browse latest View live


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