Editor Control not Working in NET MAUI

Yusuf 791 Reputation points
2022-09-26T01:24:35.447+00:00

Hi,

Editor control appears as a column of one or several characters on when the application is first launched... Sometimes when I navigate between pages or continue editing, the text is displayed normally.

244622-screenshot-1.png

<?xml version="1.0" encoding="utf-8" ?>  
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"  
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
             x:Class="MauiApp2.MainPage">  
  
    <ScrollView>  
        <StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="Gray">  
  
            <Editor  Margin="50" FontSize="36" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="White"  />  
        </StackLayout>  
    </ScrollView>  
  
</ContentPage>  
  

 

Thanks in advance

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. dg2k 1,416 Reputation points
    2022-09-27T00:07:24.45+00:00

    Hi @Yusuf ,

    I think the issue you're having has something to do with a bug with ScrollView. You can see this go away by setting the WidthRequest for the Editor element, for example set WidthRequest to 300.

    The ScrollView bug has to do with its Content property which doesn't set the ScrollView dimensions as expected. If you set ScrollView.Content to null on start-up, then ScrollView behaves as expected. This however requires some hack of copying the Content, null it, and then copy back.

    An alternative is to bind the WidthRequest to some container, typically the screen width. I always used the binding approach, so much so that I even forgot about the bug.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.