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

How do I use XAML to bind to a property inside a class instance in the view-model?

$
0
0

I am struggling to get a binding working. In my code, I have something like this:

public class SomeClass
{
    public string AProperty { get; set; } = "ABC";
}
public class MyViewModel
{
    public SomeClass { get; set; } = new SomeClass();
}

I am trying to bind a Label to AProperty. MyViewModel is set as the DataContext for the window. My XAML is as follows:

<Label Text="{Binding Source={x:Reference Name=SomeClass},Path=AProperty}"/>

This gives a System.Exception: Can't resolve name on Element.

Can anyone spot what I am doing wrong?


Ad Networks for Xamarin Forms?

$
0
0

Hi there

What are the available ad networks for Xamarin Forms?

Regards

DisplayAlert showing title twice.

$
0
0

var remove = await DisplayAlert("Remove Attendee?", message, "Yes", "No");

This is causing a display alert pop-up to appear with the title showing up twice. Anyone know what is going on?

Thanks!

View PDF in WebView for Android below API level 19

$
0
0

I am following recipe to view PDF in Android app.
My Xamarin.Forms app supports Android API level 16 and onwards. As per docs:

API levels below 19 are not capable of loading the local PDF file by specifying a ?file= query string to the viewer URL.
Instead, modify the DEFAULT_URL variable in the Assets/pdfjs/web/viewer.js file to reference the local PDF file.

If I change PDF path in viewer.js file it will point to same PDF and wont be dynamic. I want to view PDF from my external storage.
And path to that file will be dynamic. Can anyone tell how to achieve goal?

Not able to see ListView inside ScrollView

$
0
0

Hi,

I have a ListView inside a ScrollView, but I cant see the ListView or the ScrollView.
This is my Code:

`<?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:pages="clr-namespace:AdWordsApp.Pages;assembly=App"
">

<StackLayout>

    <StackLayout Orientation="Horizontal">
        <Button Text="Start" HorizontalOptions="StartAndExpand" Clicked="Button_OnClicked_Start" />
        <Button Text="End" HorizontalOptions="CenterAndExpand" Clicked="Button_OnClicked_End" />
    </StackLayout>

    <Label Text="Title" FontSize="Large" HorizontalOptions="Center" VerticalOptions="Center"
           HeightRequest="50" />

    <ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

        <StackLayout Orientation="Horizontal">
            <Picker Scale="0.8" HorizontalOptions="StartAndExpand" WidthRequest="150"
                    SelectedIndex="{Binding Compare}"
                    SelectedIndexChanged="Picker_OnSelectedIndexChanged_Compare">
                <Picker.Items>
                    <x:String>1</x:String>
                    <x:String>2</x:String>
                    <x:String>3</x:String>
                    <x:String>4</x:String>
                    <x:String>5</x:String>
                </Picker.Items>
            </Picker>
            <Label Text="compare" HorizontalOptions="Center" VerticalOptions="Center" FontSize="Small" />
        </StackLayout>

        <pages:OxyView />

        <StackLayout Orientation="Horizontal">
            <Grid Padding="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="60" />
                    <ColumnDefinition Width="80" />
                </Grid.ColumnDefinitions>

                <Label Grid.Row="0" Grid.Column="0" Text="Status" VerticalOptions="Start"
                       HorizontalOptions="Center" FontSize="Small" TextColor="White" LineBreakMode="NoWrap" />

                <Label Grid.Row="0" Grid.Column="1" Text="One" VerticalOptions="End" HorizontalOptions="Start"
                       FontSize="Small" TextColor="White" LineBreakMode="NoWrap" />

                <Label Grid.Row="0" Grid.Column="2" Text="two" VerticalOptions="Center"
                       HorizontalOptions="Start" FontSize="Small" TextColor="White" LineBreakMode="NoWrap" />

                <Label Grid.Row="0" Grid.Column="3" Text="three" VerticalOptions="End"
                       HorizontalOptions="Start" FontSize="Small" TextColor="White" />

            </Grid>

        </StackLayout>

        <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <ListView x:Name="list"
                      ItemsSource="{Binding Titles}"
                      ItemTapped="OnItemSelected"
                      IsGroupingEnabled="True"
                      GroupDisplayBinding="{Binding Key}"
                      GroupShortNameBinding="{Binding Key}"
                      HasUnevenRows="True"
                      HeightRequest="600"

                      Footer="Gesamt: ">
                <ListView.GroupHeaderTemplate>
                    <DataTemplate>

                    </DataTemplate>
                </ListView.GroupHeaderTemplate>

                <ListView.ItemTemplate>
                    <DataTemplate>

                    </DataTemplate>
                </ListView.ItemTemplate>

            </ListView>
        </StackLayout>

        <StackLayout Orientation="Horizontal">
            <Grid Padding="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="60" />
                    <ColumnDefinition Width="80" />
                </Grid.ColumnDefinitions>
                <Label Grid.Row="0" Grid.Column="0" Text="Total: " VerticalOptions="Center"
                       HorizontalOptions="Center" FontSize="Small" TextColor="White" LineBreakMode="NoWrap" />
            </Grid>
        </StackLayout>

    </ScrollView>
</StackLayout>

`

Im can see everything above the ScrollView.
But inside the ScrollView I can only see Label inside the Grid.

Why I cant see the ListView?

Thanks in advance,

Michael

[Material] TextInputLayout Renderer (Floating Labels)

$
0
0

Just thought I'd throw this out there. If you want floating labels on your Entry (as found here (by JamesMontemagno)), I've thrown together a custom renderer that extends Entry.

note: this requires the AppCompat stuff to be enabled in your Android App.

First you want to create an axml view and drop it in your /Resources/layout directory.

TextInputLayout.axml

<!-- NOTE: MyAppCompatTheme is important - it MUST apply an AppCompat theme of some sort -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TextInputLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/textInputLayout"
  android:theme="@style/MyAppCompatTheme">
  <EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="true" />
</android.support.design.widget.TextInputLayout>

From there, just drop this renderer into your Droid Renderers directory (wherever that lives).

MaterialEntryRenderer_Droid.cs

using System;
using System.ComponentModel;
using Android.Content;
using Android.Support.Design.Widget;
using Android.Text;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using MyApp.Droid.Extensions;
using MyApp.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Application = Android.App.Application;
using TextChangedEventArgs = Android.Text.TextChangedEventArgs;
[assembly: ExportRenderer(typeof(MaterialEntry), typeof(MaterialEntryRenderer_Droid))]

namespace MyApp.Droid.Renderers
{
    public class MaterialEntryRenderer_Droid : Xamarin.Forms.Platform.Android.AppCompat.ViewRenderer<MaterialEntry, TextInputLayout>
    {
        private EditText _defaultEditTextForValues;
        private bool _preventTextLoop;

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

            if (e.OldElement != null)
            {
                // unsubscribe
                if (Element != null)
                {
                    Element.HideKeyboard -= ElementOnHideKeyboard;
                }
                Control.EditText.KeyPress -= EditTextOnKeyPress;
                Control.EditText.TextChanged -= EditTextOnTextChanged;
            }

            if (e.NewElement != null)
            {
                var ctrl = CreateNativeControl();
                SetNativeControl(ctrl);
                _defaultEditTextForValues = new EditText(Context);

                SetText();
                SetHintText();
                SetTextColor();
                SetBackgroundColor();
                SetHintColor();
                SetIsPassword();
                SetKeyboard();

                // Subscribe
                Control.EditText.TextChanged += EditTextOnTextChanged;
                Control.EditText.KeyPress += EditTextOnKeyPress;
                if (Element != null)
                {
                    Element.HideKeyboard += ElementOnHideKeyboard;
                }
            }
        }

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

            if (e.PropertyName == Entry.PlaceholderProperty.PropertyName)
            {
                SetHintText();
            }

            if (e.PropertyName == Entry.TextColorProperty.PropertyName)
            {
                SetTextColor();
            }

            if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
            {
                SetBackgroundColor();
            }

            if (e.PropertyName == Entry.IsPasswordProperty.PropertyName)
            {
                SetIsPassword();
            }

            if (e.PropertyName == Entry.TextProperty.PropertyName)
            {
                SetText();
            }

            if (e.PropertyName == Entry.PlaceholderColorProperty.PropertyName)
            {
                SetHintColor();
            }

            if (e.PropertyName == InputView.KeyboardProperty.PropertyName)
            {
                SetKeyboard();
            }
        }

        private void ElementOnHideKeyboard(object sender, EventArgs eventArgs)
        {
            var manager = (InputMethodManager)Application.Context.GetSystemService(Context.InputMethodService);
            manager.HideSoftInputFromWindow(Control.EditText.WindowToken, 0);
        }

        private void SetIsPassword()
        {
            Control.EditText.InputType = Element.IsPassword
                ? InputTypes.TextVariationPassword | InputTypes.ClassText
                : Control.EditText.InputType;
        }

        private void SetBackgroundColor()
        {
            Control.SetBackgroundColor(Element.BackgroundColor.ToAndroid());
        }

        private void SetHintText()
        {
            Control.Hint = Element.Placeholder;
        }

        private void SetHintColor()
        {
            if (Element.PlaceholderColor == Color.Default)
            {
                Control.EditText.SetHintTextColor(_defaultEditTextForValues.HintTextColors);
            }
            else
            {
                Control.EditText.SetHintTextColor(Element.PlaceholderColor.ToAndroid());
            }
        }

        private void SetTextColor()
        {
            if (Element.TextColor == Color.Default)
            {
                Control.EditText.SetTextColor(_defaultEditTextForValues.TextColors);
            }
            else
            {
                Control.EditText.SetTextColor(Element.TextColor.ToAndroid());
            }
        }

        private void SetKeyboard()
        {
            Control.EditText.InputType = Element.Keyboard.ToNative();
        }

        protected override TextInputLayout CreateNativeControl()
        {
            var layout = (TextInputLayout)LayoutInflater.From(Context).Inflate(Resource.Layout.TextInputLayout, null);
            var inner = layout.FindViewById(Resource.Id.textInputEdit);
            if (!string.IsNullOrWhiteSpace(Element.AutomationId))
            {
                inner.ContentDescription = Element.AutomationId;
            }
            return layout;
        }

        private void EditTextOnKeyPress(object sender, KeyEventArgs args)
        {
            args.Handled = args.KeyCode == Keycode.Enter;
            if (args.KeyCode == Keycode.Enter && args.Event.Action == KeyEventActions.Up)
            {
                Element.OnCompleted(this, EventArgs.Empty);
            }
        }

        private void EditTextOnTextChanged(object sender, TextChangedEventArgs args)
        {
            // As I type: send the EditText to the Forms Entry
            var selection = Control.EditText.SelectionStart;
            if (!_preventTextLoop)
            {
                Element.Text = args.Text.ToString();
            }
            if (Element == null || Element.Text == null) return;

            var index = selection > Element.Text.Length ? Element.Text.Length : selection;
            Control.EditText.SetSelection(index);
        }

        private void SetText()
        {
            _preventTextLoop = true;
            if (Control.EditText.Text != Element.Text)
            {
                // If I programmatically change text on the Forms Entry,
                // send the forms entry to the native EditText
                Control.EditText.Text = Element.Text;
            }
            _preventTextLoop = false;
        }

        protected override void Dispose(bool disposing)
        {
            // this is here because the PopupPage disposes of the object in a weird way.
            // unsubscribe
            if (Element != null)
            {
                Element.HideKeyboard -= ElementOnHideKeyboard;
            }
            Control.EditText.KeyPress -= EditTextOnKeyPress;
            Control.EditText.TextChanged -= EditTextOnTextChanged;
            base.Dispose(disposing);
        }
    }
}

KeyboardExtensions.cs

using Android.Text;
using Xamarin.Forms;

namespace MyAppDroid.Extensions
{
    public static class KeyboardExtensions
    {
        public static InputTypes ToNative(this Keyboard input)
        {
            if (input == Keyboard.Url)
            {
                return InputTypes.ClassText | InputTypes.TextVariationUri;
            }
            if (input == Keyboard.Email)
            {
                return InputTypes.ClassText | InputTypes.TextVariationEmailAddress;
            }
            if (input == Keyboard.Numeric)
            {
                return InputTypes.ClassNumber;
            }
            if (input == Keyboard.Chat)
            {
                return InputTypes.ClassText | InputTypes.TextVariationShortMessage;
            }
            if (input == Keyboard.Telephone)
            {
                return InputTypes.ClassPhone;
            }
            if (input == Keyboard.Text)
            {
                return InputTypes.ClassText | InputTypes.TextFlagNoSuggestions;
            }
            return InputTypes.ClassText;
        }
    }
}

image

Disclaimer: I am not responsible for your issues ;) - if you have questions or enhancements, post them below.

This renderer currently only supports the following properties.

  • TextColor
  • Placeholder
  • IsPassword
  • BackgroundColor

feel free to add more :)

also, I didn't actually test binding... I did read somewhere that OnElementPropertyChanged doesn't fire on a ViewRenderer if you don't explicitly add the event hooks... that could have been a bug, I don't know. I just statically set these properties (for now).

Set font size in Xamarin.Forms

$
0
0

How can I set font size (e.g. in case of label) in Xamarin.Forms? Te be more generic: how to use fonts, as they are different on different platforms. Thanks!

Blank screen when navigating

$
0
0

We ran into strange bug on IOS. When using a master navigation page when we 'pop to root' we get stuck at a blank page. By blank page I mean there is no content (just white).

The page that causes this includes a customer full screen video render.
Could that be the cause ? If not, what could be the cause.

Our current work around is to replace the master navigation page completely. (App.MainPage = new...). This works, but causes a noticeable reload of our content which is less than satisfactory.


Is there a way to edit a post made by oneself?

$
0
0

Sometimes I notice typos that I'd like to correct. More often it is additional information that I have learned and would like to append to the post. Is there a way to do that?
I did see that deleting a post can be accomplished by a request on this page:
https://forums.xamarin.com/discussion/29318/how-to-delete-post
(at least as late as Oct 2015).
Thanks,
Will

Ah - it works! (test of an edit)

How to save pictures in iOS and then load them in another session?

$
0
0

I am developing a Xamarin Forms app and currently concentrating on the iOS portion. One part of the app presents a choice to either take a picture or to pick a picture (from elsewhere on the device). I use Xam.Plugin.Media for accomplishing those tasks. I store the path to the images in a table so I can retrieve them later for display. That works for me in Android.
In iOS when I take a picture it gets stored with a path like this:
/var/mobile/Containers/Data/Application/40EDDFD2-FEF8-47E6-A9DE-D6829B731AB7/Documents/PicName.jpg

And when I Pick a photo and save it to FileSystem.Current.LocalStorage it looks like this:
/var/mobile/Containers/Data/Application/40EDDFD2-FEF8-47E6-A9DE-D6829B731AB7/Documents/../Library/PicName.jpg

Next, I save those paths along with some other data to a table. When I next run the app from VS in debug on either an iPad or a simulation of an iPhone, the path being used by iOS has changed! When I pick an image and save it, it gets saved with a path like:
/var/mobile/Containers/Data/Application/7D778543-2E59-43AF-BEFE-E6842B5E0E9D/Documents/../Library/PicName2.jpg
Notice that the portion in italics has changed from 40EDDFD2-FEF8-47E6-A9DE-D6829B731AB7.

This raises some questions:
1) What is the background reasoning for this behavior?
2) Does it only happen when I debug or will it also happen when clients are using a published app?
3) When I try to view the images based on the path saved in a table, do I need to replace 40EDDFD2-FEF8-47E6-A9DE-D6829B731AB7 with 7D778543-2E59-43AF-BEFE-E6842B5E0E9D (or what ever is current) for every image or is there an easier way? What do other people do?

Thanks!

Finding out why a release version fails to open?

$
0
0

As I don't have a physical Android device I'm using the Visual Studio emulators.
Deploying the debug version of the app to the emulators works great but once I publish an APK to Beta and install the app on the emulator via the Play Store the app crashes immediately when I try to launch it.
Any advice on how to find out the cause would be gratefully appreciated.

Fix orientation for one page in the app : is it possible with Xamarin.Forms?

$
0
0

Hello,

I make an app with one page who need to have a fix orientation (landscape, exactly). I try to fix the orientation for the specific page in Xamarin.Forms (XAML or C#), but it seems to be specific to each platform. I don't know if Xamarin.Forms have a cross-platform option to do it but my searches aren't conclusive.

Can anyone help me?

Thanks in advance.

Animate toolbar icon

$
0
0

I want to make toolbar icon scale out and scale back in a few times when a navigation page loads to get user's attention to it. I was just wondering if there is a way to make toolbar item animate. Has anyone done anything like that?

I was thinking I would be able to do something like this, but there is nothing in the ToolBarItem class that I can get a VisualElement reference to.

                        var icon = MyToolbarItemFromXaml.Icon as VisualElement; // This (and various other things I've tried) doesn't work
                        if (icon != null)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                await icon.ScaleTo(0.90, 100, Easing.CubicOut);
                                await icon.ScaleTo(1, 100, Easing.CubicIn);
                            }
                        }

Adjusting Picker Selection Text Size

$
0
0

Hi guys,

I have a Picker with rather long values for selection (up to 50 characters). The problem I'm facing is that the text is clipped by default. I decided to create a custom renderer to get around this problem. This is what I've got so far.

iOS Renderer

[assembly: ExportRenderer(typeof(BindablePicker), typeof(BindablePickerRenderer))]
namespace MyProjectName.iOS.CustomRenderers
{
    public class BindablePickerRenderer : PickerRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.AdjustsFontSizeToFitWidth = true;   // This fixes the issue of font size being too big for selected value text box
                //Control.InputView.BackgroundColor = UIColor.Red;
                // I'm not quite sure what to change here to get InputView's font size also reduced so the whole value can be read
            }
        }
    }
}

Android renderer

[assembly: ExportRenderer(typeof(BindablePicker), typeof(BindablePickerRenderer))]
namespace MyProjectName.Droid.CustomRenderers
{
    public class BindablePickerRenderer : PickerRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                //No idea what to do here...
            }
        }
    }
}

Picker with bindable MVVM support

 public class BindablePicker : Picker
    {
        public BindablePicker()
        {
            this.SelectedIndexChanged += OnSelectedIndexChanged;
        }

        public static BindableProperty SelectedItemProperty = BindableProperty.Create("SelectedItem", typeof(object), typeof(BindablePicker), null, BindingMode.TwoWay, null, propertyChanged: OnSelectedItemChanged);
        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(List<string>), typeof(BindablePicker), null, BindingMode.TwoWay, null, propertyChanged: OnItemsSourceChanged);

        public IEnumerable ItemsSource
        {
            get { return (IEnumerable)GetValue(ItemsSourceProperty); }
            set { SetValue(ItemsSourceProperty, value); }
        }

        public object SelectedItem
        {
            get { return (object)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var picker = bindable as BindablePicker;
            if (picker == null)
                return;

            picker.Items.Clear();
            if ((List<string>)newValue != null)
            {
                foreach (var item in (List<string>)newValue)
                {
                    picker.Items.Add(item);
                }
            }
        }

        private static void OnSelectedItemChanged(BindableObject bindable, object oldvalue, object newvalue)
        {
            var picker = bindable as BindablePicker;
            if (picker == null || newvalue == null)
                return;

            picker.SelectedIndex = picker.Items.IndexOf(newvalue.ToString());
        }

        private void OnSelectedIndexChanged(object sender, EventArgs eventArgs)
        {
            if (SelectedIndex < 0 || SelectedIndex > Items.Count - 1)
            {
                SelectedItem = null;
            }
            else
            {
                SelectedItem = Items[SelectedIndex];
            }
        }
    }

Multiple Gesture Recognizers of same type

$
0
0

Hi guys,

I have a use case where I want an Image (inside a ListView) to do 2 things when it is tapped:

  1. Animate as if it was pushed like a button
  2. Take user to another page

I want these behaviors to be isolated because I want 1. to be used globally across the app on almost all images (through a class deriving Behavior<Image> and style inside App.xaml) used as buttons whereas 2. will be a different command and different parameters for each image.

I tried adding 2 TapGestureRecognizer associated with an Image but only one of them seems to fire? Is this an expected behavior of Xamarin.Forms? If yes then what are the workarounds or options to achieve this? The challenge I'm facing with just having one TapGestureRecognizer is that 1. requires the actual Image reference to be passed as parameter whereas 2. requires object bound to the list item. I'm not quite sure how I can pass multiple command parameters to achieve this.

Thanks,
Hiral


CarouselView 2.3.0-pre2

$
0
0

Xamarin.Forms.CarouselView

News

CarouselView is now open source:
https://github.com/xamarin/Xamarin.Forms.CarouselView

2.3.0-pre2

bugs fixed

  • 41463 - "CarouselView Crashes with "Sequence Does not Contain a Matching Element'"

  • 40513 - "Adding views to CarouselView after rendered and swiping crashes Forms"

Other fixes

Reduced assemblies referenced per platform project from three to one so
that now each platform gets its own version of Xamarin.Forms.CarouselView
into which the portable library has been merged.

For example, Android used to referenced:
  Xamarin.Forms.CarouselView
  Xamarin.Forms.CarouselView.Platform
  Xamarin.Forms.CarouselView.Android

But now only references:
  Xamarin.Forms.CarouselView (android specific)

2.3.0-pre1

Nuget package

Notes

Creating this thread to collect all CarouselView feedback until it is merged back into the Xamarin.Forms package.
James Montemagno put together a post on CarouselView here

Design tool for Xamarin.Form UWP

$
0
0

Hi everybody!
Do we have Design tool for Xamarin.Form UWP?
THANK YOU!

styling my mobile app

$
0
0

Hi, i'm new at mobile development and I wanted to know which way is the best option to style my app.
do i have to define styles in my PLC project, or I have to define them in each platform specific project?

what's the status of Xamarin Forms supporting iOS Dynamic Type Font rendering for accessibility

Entry Field does not resize when setting FontSize

$
0
0

Hi,

In my Xamarin Forms app running on iOS, when I set the FontSize of an Entry to say 42, the Entries do not resize so for example the tail of a lower case g is cut off and the top and bottom of an upper case G are also cut off.

I have tried the following code in a custom renderer however this has had little effect :-

public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            if (Control != null)
            {
                ResizeHeightWithText(Control);
            }
        }
        void ResizeHeightWithText(UITextField textField, float maxHeight = 960f)
        {
            var width = textField.Frame.Width;
            var size = ((NSString)textField.Text).StringSize(textField.Font, new CGSize(width, maxHeight),
                    UILineBreakMode.WordWrap);
            var labelFrame = textField.Frame;
            labelFrame.Size = new CGSize(width, size.Height);
            textField.Frame = labelFrame;
        }
    }

Is there a solution to this problem?

Kind Regards,

Paul

Viewing all 91519 articles
Browse latest View live


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