0
votes

I am trying to have make the Entry select all text when it is focused. I have a custom renderer for doing so on Android, but would like it to work on Windows 8 as well. How can I create a custom render for Windows in Xamarin Forms? Here is what I have:

[assembly: ExportRenderer(typeof(Xamarin.Forms.Entry), typeof(DrivingLog.Windows.MyEntryRenderer))]
namespace DrivingLog.Windows{

    public class MyEntryRenderer : EntryRenderer {

        protected override void OnElementChanged(ElementChangedEventArgs e) {

            base.OnElementChanged(e);

            if (e.OldElement == null) {

                var nativeEditText = (global::Windows.UI.Xaml.Controls.TextBox)Control;

                nativeEditText.ManipulationStarted += (object sender, ManipulationStartedRoutedEventArgs args) => {

                    nativeEditText.SelectAll();

                };

            }

        }

    }

}
1
Is there something wrong with what you have so far? What specific piece are you having issues with?Jason
@Jason The code does not select the text in the TextBox. I have tried changing the text color of the TextBox as well, but it still did not work. The renderer is not used by xamarin.Androprise

1 Answers

0
votes

I found the issue, the renderer class was in the Main Page.xaml.cs file. It needed to be in a file that did not have xaml associated with it for the assembly tag to be recognized be Xamarin Forms 2.0