Op Englesch liesen

Deelen iwwer

Xamarin.Forms Editor Tutorial

Customize behavior

  1. In MainPage.xaml, modify the Editor declaration to customize its behavior:

    XAML
    <Editor Placeholder="Enter multi-line text here"
            AutoSize="TextChanges"
            MaxLength="200"
            IsSpellCheckEnabled="false"
            IsTextPredictionEnabled="false" />
    

    This code sets properties that customize the behavior of the Editor. The AutoSize property is set to TextChanges, which indicates that the height of the Editor will increase when its filled with text, and decrease as text is removed. The MaxLength property limits the input length that's permitted for the Editor. In addition, the IsSpellCheckEnabled property is set to false to disable spell checking, while the IsTextPredictionEnabled property is set to false to disable text prediction and automatic text prediction.

  2. If the application is still running, save the changes to the file and the application user interface will automatically be updated in your simulator or emulator. Otherwise, in the Visual Studio toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen remote iOS simulator or Android emulator. Enter text into the Editor and observe that the height of the Editor increases as it fills with text, and decreases as text is removed, and that the maximum number of characters that can be entered is 200:

    Screenshot of an auto-sizing Editor, on iOS and Android

    In Visual Studio, stop the application.

    For more information about customizing Editor behavior, see the Xamarin.Forms Editor guide.