Xamarin.Forms 2.3.4.221-pre6

124

Posts

  • PhilippSumiPhilippSumi ✭✭✭ USMember ✭✭✭

    @EZHart said:
    PhilippSumi Did you create a Bugzilla case for the CarouselView issue?

    Yup: https://bugzilla.xamarin.com/show_bug.cgi?id=53382

  • JoeMankeJoeManke ✭✭✭✭✭ USMember ✭✭✭✭✭

    With the deprecation of Device.OnPlatform() and introduction of Device.RuntimePlatform in 2.3.4, what is the recommended way to handle platform-specific things in XAML?

  • NMackayNMackay mod GBInsider, University mod
    edited March 2017

    Any else noticed really bad performance of GestureRecognizers in 2.3.4 in iOS? when I test on an actual iPhone6?

    Something like this works perfectly in Android or UWP hardware but not in iOS, tried with label, stacklayout etc but the same result. Using the approach as the button was causing all sorts of problems and I didn't want to resort to yet another renderer although I'm probably going to have to.

    <Grid Grid.Row="0" Margin="20,0,20,0" RowSpacing="0" ColumnSpacing="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="90" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="34" />
                </Grid.ColumnDefinitions>
                <ContentView Grid.Column="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                  <Label HorizontalOptions="Center" VerticalOptions="Center"
                       HorizontalTextAlignment="Start" BackgroundColor="Transparent"
                       VerticalTextAlignment="Center"
                       Style="{StaticResource HomeScreenLabel}"
                       Text="Cancel">
                  </Label>
                  <ContentView.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding CloseCommand}" />
                  </ContentView.GestureRecognizers>
                </ContentView>
    

    @DavidOrtinau

    I'm not sure if there are any known issues with GestureRecognizers in iOS in 2.3.4-pre5.

  • NMackayNMackay mod GBInsider, University mod

    @JoeManke

    You can this format instead but you might have to write your own Xaml extension methods as this approach can be a bit clunky and you end up using case statements in code without the extension methods.

    <Grid.Padding>
                        <OnPlatform x:TypeArguments="Thickness">
                          <On Platform="iOS">10,5,10,5</On>
                          <On Platform="Android,WinPhone">5,5,5,5</On>
                        </OnPlatform>
                      </Grid.Padding>
    
  • NMackayNMackay mod GBInsider, University mod

    Actually got round the iOS tap gesture issues but reworking the UI

  • rmarinhormarinho Xamurai PTMember, Insider, Beta Xamurai

    What were the changes @NMackay ?

  • NMackayNMackay mod GBInsider, University mod
    edited March 2017

    @rmarinho

    I had a transparent label that spanned there columns and a label in column 0 with a tap gesture. I changed the column layout slightly so I didn't have to span the center title label and then in iOS the label with the gesture fired okay. I also used a Contentview and added the gesture to that as it works better on smaller screens and stuck the label inside inside that says Cancel and it seems to work better.

    <Grid Grid.Row="0" Margin="20,0,20,0" RowSpacing="0" ColumnSpacing="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="90" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="90" />
                </Grid.ColumnDefinitions>
                <customControls:ContentButton Grid.Column="0" Command="{Binding CloseCommand}" BackgroundColor="Transparent">
                  <Label HorizontalOptions="Start" VerticalOptions="Center"
                       HorizontalTextAlignment="Start" BackgroundColor="Transparent"
                       VerticalTextAlignment="Center"
                       Style="{StaticResource HomeScreenLabel}"
                       Text="Cancel">
                  </Label>
                </customControls:ContentButton>
                <Label Grid.Column="1" HorizontalOptions="FillAndExpand"
                       HorizontalTextAlignment="Center"
                       VerticalTextAlignment="Center"
                       Style="{StaticResource TopBarTextDataLabelStyle}"
                       Text="Vessels" />
                <customControls:ImageButton
                    Grid.Column="2"
                    WidthRequest="24"
                    HeightRequest="24"
                    VerticalOptions="Center"
                    HorizontalOptions="End"
                    Command="{Binding CloseCommand}"
                    Source="{markupExtensions:PlatformImage SourceImage={x:Static resources:ImageResources.PopupClose}}" />
            </Grid>
    

    In Android and UWP the previous approach was okay but not iOS.

    ContentButton is just a contentview, I just called it that as it acts like a button.

  • BradChase.2654BradChase.2654 ✭✭✭ USMember ✭✭✭

    @NMackay I noticed now on iOS if you have two buttons on top of each other and their IsVisible is opposite each other, they cant be tapped. So if there is an invisible button overlapping another button, the button that is visible doesnt get hit reg.

  • EmmanuelVazquezEmmanuelVazquez ✭✭ USMember ✭✭
    edited March 2017

    Hello, is it just me or has the ListView in RecycleElement mode started leaking again. This PR fixed it a while back, however I just noticed this behavior and tested it with -pre2 and -pre6. Both of those display this leak. I made a bugzilla report https://bugzilla.xamarin.com/show_bug.cgi?id=54146

  • MarkVaughnMarkVaughn USMember
    edited March 2017

    I have a custom textbox renderer in my application that hides the popup keyboard and allows the user to use a touch keypad and after updating to Xamarin Forms 2.3.4.221-pre6, it has stopped working. Basically whenever the user touches one of the buttons the HandleCharEvent event is not getting fired, and text boxes are not getting updated. However the OnElementChanged event does. I am currently deploying to a Zebra WT-6000 that runs Android 5.1. Here is the code for the renderer:

    `using System;
    using System.Linq;
    using Android.Content;
    using Android.OS;
    using Android.Views.InputMethods;
    using MobileLogisticsCenter.AndroidModule.Renderers;
    using MobileLogisticsCenter.Common.Controls;
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.Android;

    [assembly: ExportRenderer(typeof(TextBox), typeof(TextBoxRenderer))]
    namespace MobileLogisticsCenter.AndroidModule.Renderers
    {
    class TextBoxRenderer : EntryRenderer
    {
    private int lastSelectionStart;
    private int lastSelectionEnd;

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            var textBox = Element as TextBox;
            if (textBox == null)
                return;
    
            textBox.CharChangeRequested += (s, c) => HandleCharEvent(c);
            textBox.ClearRequested += (s, c) => HandleClearEvent();
            textBox.BackspaceRequested += (s, c) => HandleBackspaceEvent();
            textBox.RefocusRequested += (s, ev) => ReFocus();
            if (!TextBox.TextBoxFocusOrder.Contains(textBox))
                TextBox.TextBoxFocusOrder.Add(textBox);
    
            if (TextBox.TextBoxFocusOrder.FirstOrDefault() == textBox)
                textBox.Focus();
    
            Control.Click += (s, ev) =>
            {
                new Handler().Post(HideKeyboard);
            };
    
            Control.FocusChange += (s, ev) =>
            {
                new Handler().Post(HideKeyboard);
                if (ev.HasFocus)
                {
                    if (Control == null)
                        return;
                    TextBox.CurrentlyFocusedTextBox = textBox;
                    if (textBox.SelectsAllOnFocus)
                        Control.SelectAll();
                }
            };
        }
    
        protected override void OnAttachedToWindow()
        {
            base.OnAttachedToWindow();
    
            var textBox = Element as TextBox;
            if (textBox == null)
                return;
            if (!TextBox.TextBoxFocusOrder.Contains(textBox))
                TextBox.TextBoxFocusOrder.Add(textBox);
        }
    
        protected override void OnDetachedFromWindow()
        {
            base.OnDetachedFromWindow();
    
            var textBox = Element as TextBox;
            if (textBox == null)
                return;
            TextBox.TextBoxFocusOrder.Remove(textBox);
        }
    
        private void HideKeyboard()
        {
            if (Control == null)
                return;
            var imm = (InputMethodManager) Control.Context.GetSystemService(Context.InputMethodService);
            imm.HideSoftInputFromWindow(Control.WindowToken, 0);
        }
    
        private void ReFocus()
        {
            if (Element == null)
                return;
    
            Element.Focus();
            new Handler().Post(() =>
            {
                if (Control == null)
                    return;
                Control.SetSelection(lastSelectionStart, lastSelectionEnd);
                HideKeyboard();
                new Handler().Post(HideKeyboard);
            });
        }
    
        private void HandleClearEvent()
        {
            if (Control == null)
                return;
            Control.Text = "";
            lastSelectionStart = 0;
            lastSelectionEnd = 0;
        }
    
        private void HandleCharEvent(char c)
        {
            if (Control == null)
                return;
            string currentText = Control.Text;
            lastSelectionStart = Control.SelectionStart;
            lastSelectionEnd = Control.SelectionEnd;
            Control.Text = currentText.Substring(0, Control.SelectionStart) + c + currentText.Substring(Control.SelectionEnd, currentText.Length - Control.SelectionEnd);
            lastSelectionStart++;
            lastSelectionEnd = lastSelectionStart;
        }
    
        private void HandleBackspaceEvent()
        {
            if (Control == null)
                return;
            string currentText = Control.Text;
            lastSelectionStart = Control.SelectionStart;
            lastSelectionEnd = Control.SelectionEnd;
            if (lastSelectionStart != lastSelectionEnd)
            {
                Control.Text = currentText.Remove(lastSelectionStart, lastSelectionEnd - lastSelectionStart);
                lastSelectionEnd = lastSelectionStart;
            }
            else if (lastSelectionStart > 0)
                Control.Text = currentText.Remove(lastSelectionStart - 1, 1);
    
            if (lastSelectionStart > 0)
            {
                lastSelectionStart--;
                lastSelectionEnd = lastSelectionStart;
            }
        }
    }
    

    }`

    `public class TextBox : Entry
    {
    public static TextBox CurrentlyFocusedTextBox { get; set; }
    public static List TextBoxFocusOrder { get; private set; }

        public int FocusOrder { get; set; }
    
        public event EventHandler ClearRequested;
        public event EventHandler BackspaceRequested;
        public event EventHandler<char> CharChangeRequested;
        public event EventHandler RefocusRequested;
    
        public static readonly BindableProperty SelectsAllOnFocusProperty = BindableProperty.Create("SelectsAllOnFocus", typeof(bool), typeof(TextBox), true);
        public static readonly BindableProperty EnterPressedCommandProperty = BindableProperty.Create("EnterPressedCommand", typeof(ResponsiveCommand), typeof(TextBox));
    
        static TextBox()
        {
            TextBoxFocusOrder = new List<TextBox>();
        }
    
        public static void FocusNext()
        {
            bool found = false;
            bool setNew = false;
            foreach (var textBox in TextBoxFocusOrder)
            {
                if (found)
                {
                    setNew = true;
                    CurrentlyFocusedTextBox = textBox;
                    textBox.Focus();
                    return;
                }
    
                if (textBox == CurrentlyFocusedTextBox)
                    found = true;
            }
    
            if (!setNew && TextBoxFocusOrder.Count > 0)
            {
                var textBox = TextBoxFocusOrder.First();
                CurrentlyFocusedTextBox = textBox;
                textBox.Focus();
            }
        }
    
        public void HandleCharChange(char c)
        {
            if (CharChangeRequested != null)
                CharChangeRequested(this, c);
        }
    
        public void HandleBackspace()
        {
            if (BackspaceRequested != null)
                BackspaceRequested(this, null);
        }
    
        public void Clear()
        {
            if (ClearRequested != null)
                ClearRequested(this, null);
        }
    
        public void Refocus()
        {
            if (RefocusRequested != null)
                RefocusRequested(this, null);
        }
    
        public bool SelectsAllOnFocus
        {
            get { return (bool) GetValue(SelectsAllOnFocusProperty); }
            set { SetValue(SelectsAllOnFocusProperty, value); }
        }
    
        public ResponsiveCommand EnterPressedCommand
        {
            get { return (ResponsiveCommand) GetValue(EnterPressedCommandProperty); }
            set { SetValue(EnterPressedCommandProperty, value); }
        }
    }`
    
  • MarkVaughnMarkVaughn USMember
    edited March 2017

    I am updating to try and fix this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=42678 and it appears to have messed up my custom control. The NumberPressedCommand is no longer getting fired.

    <controls:NumberInput Grid.Column="0" Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="Center" EnableDecimal="False" IsEnabled="{Binding LoadingHelper.IsLoading, Converter={StaticResource BoolInverseConverter}}"/>

    <Style TargetType="{x:Type controls:NumberInput}"> <Setter Property="ControlTemplate"> <Setter.Value> <ControlTemplate> <Grid> <Button Text="1" Grid.Row="0" Grid.Column="0" Command="{TemplateBinding NumberPressedCommand}" CommandParameter="1"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>

    ` public class NumberInput : ContentView
    {
    public ResponsiveCommand NumberPressedCommand { get; private set; }

        public NumberInput()
        {
            NumberPressedCommand = new ResponsiveCommand<string>(EnterNumber, CanEnterNumber);
        }
    }`
    
  • MarkVaughnMarkVaughn USMember
    edited March 2017

    Seems to be a problem with template bindings specifically. The NumberPressedCommand is no longer getting triggered.

    public class NumberInput : ContentView
    {
    public ResponsiveCommand NumberPressedCommand { get; private set; }

    public NumberInput()
    {
        NumberPressedCommand = new ResponsiveCommand<string>(EnterNumber, CanEnterNumber);
    }
    

    }

  • DavidOrtinauDavidOrtinau Xamurai USForum Administrator, Xamarin Team, Insider, University Xamurai

    @EmmanuelVazquez said:
    Hello, is it just me or has the ListView in RecycleElement mode started leaking again. This PR fixed it a while back, however I just noticed this behavior and tested it with -pre2 and -pre6. Both of those display this leak. I made a bugzilla report https://bugzilla.xamarin.com/show_bug.cgi?id=54146

    Thx, we'll look into it.

  • JimmyGarridoJimmyGarrido Xamurai USXamarin Team Xamurai
    edited March 2017

    @EmmanuelVazquez I checked out your report and Forms 2.3.4 does not include the fix from that PR so the leak is still present. However testing with the nightly build, which is built from master so it includes that commit, results in the ListView page now being destroyed and memory being stable.

  • EmmanuelVazquezEmmanuelVazquez ✭✭ USMember ✭✭

    @JimmyGarrido ah that explains it. Thanks.

  • DirkWilhelmDirkWilhelm ✭✭✭✭ USMember ✭✭✭✭

    @JimmyGarrido @DavidOrtinau

    Just out of curiosity, what branches are the nightly and the -pre releases based on?

    Is it always the master branch, do you cherry pick what to include? For example the PR that EmmanuelVazquez mentioned, how come that it is in the nightlys but not in the pre releases? The PR was merged to master some days before pre2 was released.

  • rmarinhormarinho Xamurai PTMember, Insider, Beta Xamurai

    @DirkWilhelm pre's are branched from master for example 2.3.4 (first pre1) then we cherry pick fixes only that address regressions on that version, we commit to master and cherry pick to 2.3.4 and theres where you get another pre's.

    Nightly is always master so it will have the fixes for 2.3.4 branch plus everything else.

  • FredyWengerFredyWenger ✭✭✭✭✭ CHInsider ✭✭✭✭✭

    Hi all
    As it seems as 2.3.4 will be released soon...
    Goal 2.3.4:

    Startup Time Improvements - Performance
    Improve the startup and initialization time for Xamarin.Forms apps.

    Have anybody noted a faster "startup and initialization time" in real life with his App?
    I think, this is interesting for many users....
    Thanks for any comment

  • NMackayNMackay mod GBInsider, University mod
    edited March 2017

    @DavidOrtinau

    Hi David, I noticed this PR in Pre6, it breaks my CustomRenderer that was fine in Pre5.

    https://github.com/xamarin/Xamarin.Forms/pull/824

    Using GoogleMaps 29.0.0.1.

    I think the issue is this property change never occurs anymore

     protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
            {
                base.OnElementPropertyChanged(sender, e);
    
                if (e.PropertyName.Equals("VisibleRegion") && !_isDrawn)
    

    I can fix the polyline and custom marker code by moving it into OnMapReady but the zoom level and maptype isn't been passed on to the renderer.

    I'll roll back to 2.3.4 pre5 as I have to publish a beta but I'd say this is a breaking change.

  • DavidOrtinauDavidOrtinau Xamurai USForum Administrator, Xamarin Team, Insider, University Xamurai

    @NMackay we're looking into it, thx.

  • NMackayNMackay mod GBInsider, University mod

    @DavidOrtinau

    Thanks David. Rolling back to pre5 for now fixes the issue.

  • MichaelRumplerMichaelRumpler ✭✭✭✭✭ ATMember ✭✭✭✭✭

    @BrightLee said:
    NOTE : If you're using Media plugin from ActionSheet button event(on iOS), you better put 'await Task.Delay(100);' before PickPhotoAsync(). Otherwise the gallery will not shown and crash if you press button next time.

    It occurs because XF2.3.4 started using UIAlertController instead of UIActionSheet and Media plugin is not prepared for it.

    more information : https://github.com/jamesmontemagno/MediaPlugin/issues/186

    I have a similar problem. I await DisplayActionSheet and upon a certain result on iOS I want to present an UIDocumentPickerViewController. This worked fine before (last version was 2.3.2 because those inbetween didn't work either for various reasons) but with pre5 and pre6 I need to delay for a couple of milliseconds. Without the Task.Delay the document picker is not shown and there is no error and nothing in the output window. My app does not crash if I try again. It is simply ignored.

  • JimmyGarridoJimmyGarrido Xamurai USXamarin Team Xamurai

    @MichaelRumpler @BrightLee This looks like it's being caused by the UIAlertController being presented in a new window in order to fix other issues that were occurring. Adding a delay is a good workaround, but I've also opened a pull request for a fix that should prevent this from occurring in this scenario.

  • BrightLeeBrightLee ✭✭✭ KRMember ✭✭✭

    Thanks @JimmyGarrido

  • BrightLeeBrightLee ✭✭✭ KRMember ✭✭✭

    on Android, IsClippedToBounds="true" is not working for me.
    It worked on XF 2.3.3.

  • OOIIpsOOIIps ✭✭ UAMember ✭✭

    If I change content with other height intro viewcell and call ForceUpdateSize nothing to happens. Only iOS.

  • BjornBBjornB ✭✭✭ USMember ✭✭✭
    edited March 2017

    https://bugzilla.xamarin.com/show_bug.cgi?id=54334

    Found a new regression bug that was introduced in pre3, styles now override properties set in code for UI-elements when changing App.Current.Resources. This is a pain (duh), and it forces me to stay on pre 2. Please check it out @DavidOrtinau

    https://github.com/xamarin/Xamarin.Forms/pull/737 i think this is what made it stop working @StephaneDelcroix

    Thank you!

  • JKayJKay ✭✭✭ USMember ✭✭✭

    -Pre 6 has broken my attached property:

      public class KeyboardStyle
        {
            public static BindableProperty KeyboardFlagsProperty = BindableProperty.CreateAttached(
               propertyName: "KeyboardFlags",
               returnType: typeof(string),
               declaringType: typeof(InputView),
               defaultValue: null,
               defaultBindingMode: BindingMode.OneWay,
               propertyChanged: HandleKeyboardFlagsChanged);
    
            public static void HandleKeyboardFlagsChanged(BindableObject obj, object oldValue, object newValue)
            {
                var entry = obj as InputView;
    
                if (entry == null)
                {
                    return;
                }
    
                if (newValue == null)
                {
                    return;
                }
    
                string[] flagNames = ((string)newValue).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                KeyboardFlags allFlags = 0;
    
                foreach (var flagName in flagNames)
                {
                    KeyboardFlags flags = 0;
                    Enum.TryParse<KeyboardFlags>(flagName.Trim(), out flags);
                    if (flags != 0)
                    {
                        allFlags |= flags;
                    }
                }
    
                var keyboard = Keyboard.Create(allFlags);
    
                entry.Keyboard = keyboard;
            }
        }
    

    Defined in a style like so:

        <Style TargetType="Entry">
            <Setter Property="custom:KeyboardStyle.KeyboardFlags" Value="Spellcheck,CapitalizeSentence"/>
        </Style>
    

    No longer compiles. Dont know if this is me or Xamarin?

  • JKayJKay ✭✭✭ USMember ✭✭✭
    edited March 2017

    Also -Pre 6:

    Merged Dictionaries no longer work:

    Initial Dictionary

    <ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="FieldStrikeMove.Forms.Styling.DarkThemeColours">
    

    Merged Dictionary

       <ResourceDictionary
    xmlns:styling="clr-namespace:MyApp.Forms.Styling;assembly=MyApp.Forms"
    MergedWith="styling:DarkThemeColours"/>
    

    The above SUDO code does not work anymore

  • DavidOrtinauDavidOrtinau Xamurai USForum Administrator, Xamarin Team, Insider, University Xamurai

    @JKay we are looking into those issues.

  • JKayJKay ✭✭✭ USMember ✭✭✭
    edited March 2017

    @DavidOrtinau Thanks. Hopefully you can re-create them from my comments. If not I will try to replicate them in a sample. Both of the above work in Xamarin.Forms 2.3.3.193 (latest stable)

  • MarkVaughnMarkVaughn USMember

    After updating to Xamarin.Forms 2.3.4.221-pre6 my custom TextBox Render has stopped working. It will no longer call the HandleCharEvent.

    `class TextBoxRenderer : EntryRenderer
    {
    private int lastSelectionStart;
    private int lastSelectionEnd;

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            var textBox = Element as TextBox;
            if (textBox == null)
                return;
    
            textBox.CharChangeRequested += (s, c) => HandleCharEvent(c);
            textBox.ClearRequested += (s, c) => HandleClearEvent();
            textBox.BackspaceRequested += (s, c) => HandleBackspaceEvent();
            textBox.RefocusRequested += (s, ev) => ReFocus();
            if (!TextBox.TextBoxFocusOrder.Contains(textBox))
                TextBox.TextBoxFocusOrder.Add(textBox);
    
            if (TextBox.TextBoxFocusOrder.FirstOrDefault() == textBox)
                textBox.Focus();
    
            Control.Click += (s, ev) =>
            {
                new Handler().Post(HideKeyboard);
            };
    
            Control.FocusChange += (s, ev) =>
            {
                new Handler().Post(HideKeyboard);
                if (ev.HasFocus)
                {
                    if (Control == null)
                        return;
                    TextBox.CurrentlyFocusedTextBox = textBox;
                    if (textBox.SelectsAllOnFocus)
                        Control.SelectAll();
                }
            };
        }
    
        protected override void OnAttachedToWindow()
        {
            base.OnAttachedToWindow();
    
            var textBox = Element as TextBox;
            if (textBox == null)
                return;
            if (!TextBox.TextBoxFocusOrder.Contains(textBox))
                TextBox.TextBoxFocusOrder.Add(textBox);
        }
    
        protected override void OnDetachedFromWindow()
        {
            base.OnDetachedFromWindow();
    
            var textBox = Element as TextBox;
            if (textBox == null)
                return;
            TextBox.TextBoxFocusOrder.Remove(textBox);
        }
    
        private void HideKeyboard()
        {
            if (Control == null)
                return;
            var imm = (InputMethodManager) Control.Context.GetSystemService(Context.InputMethodService);
            imm.HideSoftInputFromWindow(Control.WindowToken, 0);
        }
    
        private void ReFocus()
        {
            if (Element == null)
                return;
    
            Element.Focus();
            new Handler().Post(() =>
            {
                if (Control == null)
                    return;
                Control.SetSelection(lastSelectionStart, lastSelectionEnd);
                HideKeyboard();
                new Handler().Post(HideKeyboard);
            });
        }
    
        private void HandleClearEvent()
        {
            if (Control == null)
                return;
            Control.Text = "";
            lastSelectionStart = 0;
            lastSelectionEnd = 0;
        }
    
        private void HandleCharEvent(char c)
        {
            if (Control == null)
                return;
            string currentText = Control.Text;
            lastSelectionStart = Control.SelectionStart;
            lastSelectionEnd = Control.SelectionEnd;
            Control.Text = currentText.Substring(0, Control.SelectionStart) + c + currentText.Substring(Control.SelectionEnd, currentText.Length - Control.SelectionEnd);
            lastSelectionStart++;
            lastSelectionEnd = lastSelectionStart;
        }
    
        private void HandleBackspaceEvent()
        {
            if (Control == null)
                return;
            string currentText = Control.Text;
            lastSelectionStart = Control.SelectionStart;
            lastSelectionEnd = Control.SelectionEnd;
            if (lastSelectionStart != lastSelectionEnd)
            {
                Control.Text = currentText.Remove(lastSelectionStart, lastSelectionEnd - lastSelectionStart);
                lastSelectionEnd = lastSelectionStart;
            }
            else if (lastSelectionStart > 0)
                Control.Text = currentText.Remove(lastSelectionStart - 1, 1);
    
            if (lastSelectionStart > 0)
            {
                lastSelectionStart--;
                lastSelectionEnd = lastSelectionStart;
            }
        }
    }`
    

    `public class TextBox : Entry
    {
    public static TextBox CurrentlyFocusedTextBox { get; set; }
    public static List TextBoxFocusOrder { get; private set; }

        public int FocusOrder { get; set; }
    
        public event EventHandler ClearRequested;
        public event EventHandler BackspaceRequested;
        public event EventHandler<char> CharChangeRequested;
        public event EventHandler RefocusRequested;
    
        public static readonly BindableProperty SelectsAllOnFocusProperty = BindableProperty.Create("SelectsAllOnFocus", typeof(bool), typeof(TextBox), true);
        public static readonly BindableProperty EnterPressedCommandProperty = BindableProperty.Create("EnterPressedCommand", typeof(ResponsiveCommand), typeof(TextBox));
    
        static TextBox()
        {
            TextBoxFocusOrder = new List<TextBox>();
        }
    
        public static void FocusNext()
        {
            bool found = false;
            bool setNew = false;
            foreach (var textBox in TextBoxFocusOrder)
            {
                if (found)
                {
                    setNew = true;
                    CurrentlyFocusedTextBox = textBox;
                    textBox.Focus();
                    return;
                }
    
                if (textBox == CurrentlyFocusedTextBox)
                    found = true;
            }
    
            if (!setNew && TextBoxFocusOrder.Count > 0)
            {
                var textBox = TextBoxFocusOrder.First();
                CurrentlyFocusedTextBox = textBox;
                textBox.Focus();
            }
        }
    
        public void HandleCharChange(char c)
        {
            if (CharChangeRequested != null)
                CharChangeRequested(this, c);
        }
    
        public void HandleBackspace()
        {
            if (BackspaceRequested != null)
                BackspaceRequested(this, null);
        }
    
        public void Clear()
        {
            if (ClearRequested != null)
                ClearRequested(this, null);
        }
    
        public void Refocus()
        {
            if (RefocusRequested != null)
                RefocusRequested(this, null);
        }
    
        public bool SelectsAllOnFocus
        {
            get { return (bool) GetValue(SelectsAllOnFocusProperty); }
            set { SetValue(SelectsAllOnFocusProperty, value); }
        }
    
        public ResponsiveCommand EnterPressedCommand
        {
            get { return (ResponsiveCommand) GetValue(EnterPressedCommandProperty); }
            set { SetValue(EnterPressedCommandProperty, value); }
        }
    }`
    
  • JimmyGarridoJimmyGarrido Xamurai USXamarin Team Xamurai

    @JKay I wasn't able to reproduce the issue with merged dictionaries with a new sample project. It worked as expected on both Forms 2.3.3.193 and 2.3.4-pre6. Can you share a repro project so we can keep looking into this?

    Regarding the AttachedProperty, with XamlC enabled and 2.3.4-pre6 I was seeing this error during compilation:

    error : Position 10:70. Missing a public static GetKeyboardFlags or a public instance property getter for the attached property "MergedIssue.KeyboardStyle.KeyboardFlagsProperty"

    This is because XamlC now compiles the AttachedProperty (previously it didn't) and that requires that a public getter and setter actaully be defined that conforms to these guidelines. Let us know if this resolves the build error in your case, or if this is a different error than you are seeing. Thanks!

  • DavidOrtinauDavidOrtinau Xamurai USForum Administrator, Xamarin Team, Insider, University Xamurai

    @BrightLee said:
    on Android, IsClippedToBounds="true" is not working for me.
    It worked on XF 2.3.3.

    Hey @BrightLee, I'm not able to reproduce this problem with 2.3.4.221-pre6. Could you please open a Bugzilla and include a simple reproduction project? Thx.

  • JimmyGarridoJimmyGarrido Xamurai USXamarin Team Xamurai

    @MarkVaughn For the custom renderer issue, I wasn't able to create a sample project based on the code you provided. I'm not seeing anything in the TextBox class that calls HandleCharChange(char c) and fires off the event. How are you firing off the event?

    I also couldn't repro the template binding issue you mentioned. The command is being executed when I test with Forms 2.3.3.193 and 2.3.4-pre6 on an Android 6.0 device.

    I wonder if these are device specific; are you are seeing these issues on another device or emulator? Can you share a complete reproduction project for each issue so we can look into them? Thanks!

  • JKayJKay ✭✭✭ USMember ✭✭✭
    edited April 2017

    @JimmyGarrido Thanks for the AttachedProperty feedback, that has now fixed my build error.

    As for Merged Dictionaries. it may be a change in how it works.

    I have a Dictionary defined in App.xaml and have merged it with another dictionary - each with 1 resource.

    In App.Xaml.cs I then call var count = Application.Current.Resources.Count; I'm sure with current stable this would return 2 but in pre6 it now returns 1.

    I have uploaded the sample for you to have a look

  • MarkVaughnMarkVaughn USMember

    @JimmyGarrido Looks like my most recent edit to that post didn't take. Here is some more detail:

    I upgraded to fix an error I was getting:

    Java.Lang.ReflectiveOperationException: Exception of type 'Java.Lang.ReflectiveOperationException' was thrown.;System.ObjectDisposedException: Cannot access a disposed object.
    Object name: 'Xamarin.Forms.Platform.Android.FormsTextView'.;

    When I upgraded I ran into the problem where whenever I click one of my custom buttons they no longer trigger the NumberPressedCommand.

    My login view contains a custom view called number input that basically has buttons for 0-9, backspace, and enter. They are used to update custom textboxes for username and password. NumberInput inherits from Content View and has a ResponsiveCommand that updates the custom TextBox (shown above). The username and password text boxes are no longer getting updated.

    <controls:NumberInput Grid.Column="0" Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="Center" EnableDecimal="False" IsEnabled="{Binding LoadingHelper.IsLoading, Converter={StaticResource BoolInverseConverter}}"/>
    `public class NumberInput : ContentView
    {
    public ResponsiveCommand NumberPressedCommand { get; private set; }

    public NumberInput()
    {
        NumberPressedCommand = new ResponsiveCommand<string>(EnterNumber, CanEnterNumber);
    }
    
    private bool CanEnterNumber(string n)
    {
        if (!IsEnabled)
            return false;
        if (n == ".")
            return EnableDecimal;
        return true;
    }
    
    private void EnterNumber(string n)
    {
        if (TextBox.CurrentlyFocusedTextBox != null)
        {
            TextBox.CurrentlyFocusedTextBox.HandleCharChange(n[0]);
            TextBox.CurrentlyFocusedTextBox.Refocus();
        }
    }
    

    }`

    I've got a lot of custom code being used here. It maybe best for me to just create a small project.

  • MarkVaughnMarkVaughn USMember

    @JimmyGarrido I am also using a WT-6000 Zebra device running Android 5.1 so that could be an issue.

Sign In or Register to comment.