Why the text at the arrow after adding the code in the red box cannot be bound?

wei dai 0 Reputation points
2023-07-09T03:23:01.2133333+00:00

Why the text at the arrow after adding the code in the red box cannot be bound?

8c543fd2114d4589af13a12defb9f98

Developer technologies .NET .NET MAUI
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-07-10T01:01:44.4133333+00:00

    Hello,

    Cannot find Text in MainViewModel?

    Yes, please add the following BindingContext code in your XAML. Here is a document about: Use compiled bindings

     <ContentPage.BindingContext>
            <local:MainViewModel  />
        </ContentPage.BindingContext>
    

    I followed the video but did not automatically generate a Text: string. How can I automatically generate it?

    You can do this by adding it manually as the following code in MainViewModel.cs`.

    public class MainViewModel
    {
        public string Text { get; set; } = "123";
    }
    
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.