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

text not bold in xamarin forms markdown label

$
0
0

This is my code to bold label text. But text not bold

parameterText= "This is supposed to be bold too"

public FormattedString GetBoldTextValue(string parameterText)
{
var boldFormat = "**";
var formatString = new FormattedString();
while (!string.IsNullOrWhiteSpace(parameterText))
{
try
{
var boldIndex = parameterText.IndexOf(boldFormat);

                if (boldIndex >= 0)
                {
                    if (boldIndex > 0)
                    {
                        var t = parameterText.Substring(0, boldIndex);
                        formatString.Spans.Add(new Span() { Text = t });
                    }
                    parameterText = parameterText.Substring(boldIndex + 2);
                    var next = parameterText.IndexOf(boldFormat);
                    var t1 = parameterText.Substring(0, next);
                    formatString.Spans.Add(new Span() { Text = t1, FontAttributes = FontAttributes.Bold });
                    parameterText = parameterText.Substring(next + 2);
                }
                else
                {
                    formatString.Spans.Add(new Span() { Text = parameterText });
                    break;
                }
            }
            catch (Exception)
            {
                formatString = new FormattedString();
                break;
            }
        }

        return formatString;
    }`

This code worked well. But After I added Label Render this not working. This is my render.


How can I make such a slider

Blinking animation for an image in DataTemplate

$
0
0

https: //stackoverflow.com/questions/62580924/xamarin-forms-blinking-animation-for-an-image-in-datatemplatehow to make it blink

Xamarin Forms, cannot generate IPA file for IOS project

$
0
0

Hello,

I have a Xamarin.Forms app that we run on Android, IOS and Windows. Android and Windows work fine and we have them deployed. IOS works fine in the Simulator, and I can install to an iPad via a USB cable. But, I have been unable to generate an IPA file for wider distribution.

When running the Release build (Build IPA is checked), all seems to go well but no IPA file is generated.

The only thing that looks awry is this warning message: "There is no available connection to the Mac, hence the task Xamarin.Messaging.Tasks.CopyFileFromMac will not be executed".

Our MacInCloud server is paired for the build session, so should be "available". But I assume this is why we are not getting the IPA file? Does that message imply that I could/should be able to find the file out on the MacInCloud server somewhere? I looked around, but could not see one.

VS.2019 is latest build, and NuGet Xamarin packages are also latest.

Can anyone give me some guidance on how to get our IPA generated?

Thanks for any help.

Bryan Hunt

Anybody knows how to fire an event when signing on a Signature Pad in Xamarin.Forms?

$
0
0

I tried this but it doesn't fire when signing.
signatureView.PropertyChanged += (sender, args) => {
var x = string.Empty;
};

And I'm using Xamarin.Controls.SignaturePad.Forms.

profile image crop and drag

$
0
0

i have user profile page where i allow user to upload profile image. I want user can drag and zoom to crop the picture as they like

can anyone help?

How to hide Flyout items In shell xamarin forms.

$
0
0

I have two different users. So I want to show different FLYOUTS in shell flyout respectively.

how to create rating bar in xaml

$
0
0

hello,
how to create a rating bar in xaml and get its value. please help.


How to draw synchronous ChipView in Xamarin Forms?

$
0
0

Hi Team,

I would like to implement the synchronous ChipView control as like below image through native renderers.

I'm not sure how to draw the particular shapes in renderers.

Can anyone please help on this?

Thanks in advance,
Dinesh B

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

Scroll ScrollView programatically based on TouchEffect

$
0
0

I tries to programmatically scroll ScrollView based on TouchEffect, but when I do that it scrolls not properly, it scrolls instead of up it scrolls down and instead of down - up ...

Also from some point it stop scrolling ...

Here is code that I use to scroll programmatically:

            TouchEffect touchEffect = new TouchEffect();
            touchEffect.TouchAction += async (sender, args) =>
            {
                await Scroller.ScrollToAsync(args.Location.X, args.Location.Y, true);
            };
            Scroller.Effects.Add(touchEffect);

Display Datagrid in Xamarin forms by count

$
0
0

Hi, I am currently using Xamarin.forms.Datagrid to display data. I would like to ask if anyone know how to display multiple datagrid based on count? For example category A have 2 items and category B have 1 item, when user choose category A, I want to display 2 separate Datagrid for this 2 items. If user chooses B, it will only show 1 datagrid. How can I achieve this? Because the datagrid I am using is manually added in xaml, and also for rows and columns.

I did not add in the drop down list but example if User choose A in the drop down, it will display 2 data grid. If user choose B, it will display 1 data grid. What I want to achieve is to have the datagrid displayed on the same page where User chooses the category..... Is it possible? Please help thank you I am new to Xamarin and programming... I am not very good

This is my current codes

Mainpage.xaml
`

    <dg:DataGrid  ItemsSource="{Binding categoryA2}" HeaderHeight="0"
     BorderColor="#CCCCCC" SelectionEnabled="False" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HeaderBackground="#E0E6F8" 
      IsSortable="False" FontSize="16" HeaderFontSize="16">
        <dg:DataGrid.Columns>
            <dg:DataGridColumn Title="Fruit" PropertyName="Name"/>
            <dg:DataGridColumn Title="Price" PropertyName="Price"/>
        </dg:DataGrid.Columns>
        <dg:DataGrid.RowsBackgroundColorPalette>
            <dg:PaletteCollection>
                <Color>#F2F2F2</Color>
            </dg:PaletteCollection>
        </dg:DataGrid.RowsBackgroundColorPalette>
    </dg:DataGrid>

<dg:DataGrid  ItemsSource="{Binding categoryA1}" HeaderHeight="0"
     BorderColor="#CCCCCC" SelectionEnabled="False" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HeaderBackground="#E0E6F8" 
      IsSortable="False" FontSize="16" HeaderFontSize="16">
        <dg:DataGrid.Columns>
            <dg:DataGridColumn Title="Fruit" PropertyName="Name"/>
            <dg:DataGridColumn Title="Price" PropertyName="Price"/>
        </dg:DataGrid.Columns>
        <dg:DataGrid.RowsBackgroundColorPalette>
            <dg:PaletteCollection>
                <Color>#F2F2F2</Color>
            </dg:PaletteCollection>
        </dg:DataGrid.RowsBackgroundColorPalette>
    </dg:DataGrid>

`

Mainpage.cs
public MainPage()
{
InitializeComponent();
this.BindingContext = new ViewModel();
}`

Viewmodel
public class ViewModel
{
public ObservableCollection categoryA1 { get; set; }
public ObservableCollection categoryA2 { get; set; }
public ObservableCollection categoryB1 { get; set; }

    public ViewModel()
    {
        categoryA1 = new ObservableCollection<Test>();
        categoryA1.Add(new Test() { Name = "Orange", });
        categoryA1.Add(new Test() { Price = "1.4" });

        categoryA2 = new ObservableCollection<Test>();
        categoryA2.Add(new Test() { Name = "Apple", });
        categoryA2.Add(new Test() { Price = "1.2" });

        categoryB1 = new ObservableCollection<Test>();
        categoryB1.Add(new Test() { Name = "Spinach", });
        categoryB1.Add(new Test() { Price = "1.0" });
    }
}

Test.cs
public class Test
{
public string Name { get; set; }
public string Price { get; set; }
}

How to fix 'Task could not find "al.exe" using the SdkToolsPath' Error?

$
0
0

I am getting the below compile time error. Visual studio (2019) version is 16.3.3. and .net framework is 4.8.03752.How to fix it? Any suggestion please.

Task could not find "al.exe" using the SdkToolsPath "" or
the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.7.2\WinSDK-NetFx40Tools-x86".
Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under
the SdkToolsPath and that the Microsoft Windows SDK is installed.

Xam.Plugin.Media after camera capture app crashes without any error

$
0
0

Hello,

I am using Xam.Plugin.Media in my xamarin forms (Xamarin.Forms 4.5.0.530) mobile app. App gets crashed after camera capture strangely without any error. Camera captured image also gets stored in the desired folder I set. I don't know how to proceed further, would appreciate if someone could help me move forward.

Code snippet and other App details are attached below:

Shared Project

XAML

<ContentPage.Resources>
            < ResourceDictionary>
                < services:Null2StringConverter x:Key="Null2String"/>
                < services:ByteToImageFieldConverter x:Key="ByteArrayToImage"/>
            < /ResourceDictionary>
    </ContentPage.Resources>

    <Grid ColumnSpacing="16">
        <StackLayout Grid.Column="0">
            <Image
                x:Name="PhotoImage"
                Aspect="AspectFit"
                Source="{Binding PhotoByte, Converter={StaticResource ByteArrayToImage}, Mode=TwoWay}" />
        </StackLayout>
        <StackLayout  Grid.Column="1">
            <Button Grid.Column="1" WidthRequest="200"
                x:Name= "btnTake"
                Text = "Take Picture"
                Style="{StaticResource ButtonBlueWhite}"
                HorizontalOptions = "End"/>
        </StackLayout>
    </Grid>

View

    public partial class PODUpdate : ContentPage
    {
            PODViewModel viewModel;

                public PODUpdate()
                {   
                     InitializeComponent();

                        BindingContext = viewModel = new PODViewModel(2);
                }



                private void BtnTake_Clicked(object sender, EventArgs e)
                {
                    PictureClick();
                }


                private async void PictureClick()
                {
                    try
                    {
                        if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                        {
                            await DisplayAlert("No Camera", ":( No camera available.", "OK");
                            return;
                        }

                        string mFileName = DateTime.Now.Year.ToString() +
                                            DateTime.Now.Month.ToString() +
                                            DateTime.Now.Day.ToString() +
                                            DateTime.Now.Hour.ToString() +
                                            DateTime.Now.Minute.ToString() +
                                            DateTime.Now.Second.ToString();


                        await CrossMedia.Current.Initialize();

                        var photo = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                        {
                            MaxWidthHeight = 2500,
                            CompressionQuality = 80,
                            DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Front,
                            Name = mFileName,
                            PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small
                        });

                        if (photo == null)
                            return;


                        if (photo != null)
                        {
                            viewModel.IsPhotoTaken = true;
                            viewModel.PhotoByte = System.IO.File.ReadAllBytes(photo.Path);

                            photo.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert(this.Title, ex.Message+ ex.InnerException, "Ok");
                        return;
                    }
                }
    }

Android Project
AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.Flyking.ibots.netmobile" android:installLocation="auto">
        <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
        <application android:label="Ibots.NetMobile.Android" android:icon="@drawable/FlykingIcon">
            <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.Flyking.ibots.netmobile.fileprovider" android:exported="false" 
                  android:largeHeap="true" android:grantUriPermissions="true">
                <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
            </provider>
        </application>
      <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.FLASHLIGHT" />
    </manifest>

AssemblyInfo.cs

    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using Android.App;

    // General Information about an assembly is controlled through the following 
    // set of attributes. Change these attribute values to modify the information
    // associated with an assembly.
    [assembly: AssemblyTitle("Ibots.NetMobile.Android")]
    [assembly: AssemblyDescription("")]
    [assembly: AssemblyConfiguration("")]
    [assembly: AssemblyCompany("")]
    [assembly: AssemblyProduct("Ibots.NetMobile.Android")]
    [assembly: AssemblyCopyright("Copyright ©  2014")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: ComVisible(false)]

    // Version information for an assembly consists of the following four values:
    //
    //      Major Version
    //      Minor Version 
    //      Build Number
    //      Revision
    //
    // You can specify all the values or you can default the Build and Revision Numbers 
    // by using the '*' as shown below:
    // [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyVersion("1.0.0.0")]
    [assembly: AssemblyFileVersion("1.0.0.0")]

    // Add some common permissions, these can be removed if not needed
    [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
    [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
    #if DEBUG
        [assembly: Application(Debuggable = true, UsesCleartextTraffic = true)]
    #else
        [assembly: Application(Debuggable = false, UsesCleartextTraffic = true)]
    #endif

    [assembly: UsesPermission(Android.Manifest.Permission.Camera)]
    [assembly: UsesFeature("android.hardware.camera", Required = true)]
    [assembly: UsesFeature("android.hardware.camera.autofocus", Required = true)]

MainActivity.cs

    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {

            protected override void OnCreate(Bundle savedInstanceState)
            {
                TabLayoutResource = Resource.Layout.Tabbar;
                ToolbarResource = Resource.Layout.Toolbar;

                base.OnCreate(savedInstanceState);
                Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);

                Xamarin.Essentials.Platform.Init(this, savedInstanceState);
                global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

                ZXing.Net.Mobile.Forms.Android.Platform.Init();

                LoadApplication(new App());
            }



            public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
            {
                global::ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);

                Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

                base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }

    }

Thanks - G Rajesh

Cut off 1 corner in Collectionview

$
0
0

How do i make this in a Collectionview , 1 corner is cut off and not round with cornerradius


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

ListView Performance

$
0
0

Ok, so I was testing my application and I've noticed that in my listview when I have itens, like images or labels and this item has a GestureRecognizer ataching a command through a binding the scroll suffers a big decrease in performance. If I just remove the GestureRecognizer from my xaml the performance is acceptable, but with the command bindings the performance becomes laggy. I'm using MVVM. Has anyone experience the same? Maybe someone will ask for a piece of code, but I'm using only a class with some strings and a command and doing the binding to the xaml, nothing fancy. I've tested the Command binding to something null and the issue persists. Also, this doesn't seem to happen in the Tapped property, but how would I use it with MVVM (if possible of course)?

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?

WHY MY METHOD CalculateDiff is not executing???

$
0
0

Hellooooooooo
I need help please
I am defining a method to avoid repeating the same code which is present in "CalculateDiff" many times whithin the same class (CompuChemXamlPage9)
BUT my "CalculateDiff" is not executed.

    public partial class CompuChemXamlPage9 : ContentPage
{
       private double diff;
       private int Numerator;
       private int Denominator;

       public void CalculateDiff(double diff)
        {
            if (diff >= 0.09 && diff < 0.1055)        // diff == 0.100
            {
                // 1 / 10
                Numerator = 1;
                Denominator = 10;
            }
            else if (diff >= 0.1055 && diff < 0.118)          // diff == 0.111
            {
            }
    ...

}

private void Calculate(object sender, EventArgs e)
{
   RCH = moleH / moleC;
   diff = Math.Abs(RCH - Math.Floor(RCH + 0.5));

   CompuChemXamlPage9 myCompuChem = new CompuChemXamlPage9();
   myCompuChem.CalculateDiff(diff);
   mX.Text = Numerator.ToString();
   RCH = ((Math.Floor(RCH)) * Denominator) + Numerator;
}

/WHY MY METHOD CalculateDiff is not executing???

Button on Android all caps

$
0
0

I have just noticed that on Xamarin Forms Android, the text label on elements appears in ALL CAPS. Is this by design?

Regards,
Ian

Viewing all 91519 articles
Browse latest View live


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