Skip to content

How to bind? #74

Closed Answered by bijington
PlayCreatively asked this question in Q&A
Jun 19, 2022 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Hey @PlayCreatively,

We do link over to the .NET MAUI docs but I don't actually see anything clearly helpful there either. Essentially when creating a binding we need to do so against a property that is accessible (public or internal), to tell the control the context of the binding (BindingContext) and we also need a way of notifying the control when things change (INotifyPropertyChanged).

What you had was close but there are some extra bits you needed. See this modified version of your code:

class MyPage : ContentPage
{
    public string MyVal { get; } = "initial value";

    public DataPage()
    {
        BindingContext = this;

        Content =
            new VerticalStackLayout()

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@PlayCreatively
Comment options

@bijington
Comment options

Answer selected by brminnick
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants