0

I created two pages in maui app: a ContentView and a ContentPage. Inside the ContentView component, I need to call a popup and show some contents in the page. In my current Implementation on ContentView, I declared a bindable property of type ContentPage for the reason of using the instance to call the ShowPopupAsync method.

Bindable Property in the nxi-lookup.xaml.cs

    public BindableProperty ParentPageProperty =
    BindableProperty.Create(
    nameof(Page),
    typeof(ContentPage),
    typeof(nxi_lookup),
    defaultValue: null,
    defaultBindingMode: BindingMode.OneWay);

my contentpage xaml

 <custom:nxi_lookup Page="{Binding Page,Source={x:Reference Production}}" Margin="0,0,10,10" WidthValue="10"  LabelText="Lookup 1" IsRequired="True"/>

Actual usage for popup inside the contentview

     if (Page != null)
        {
            var popup = new nxi_popup();
            var content = new nxi_lookupcontent();
            popup.Content = content;
            await Page.ShowPopupAsync(popup);
        }

Error XFC0009 No property, BindableProperty, or event found for "Page", or mismatching type.

I tried changing the type of the bindable property but does not work. I expected to bind the contentpage to my property in content view.

Is there any way to properly implement popup in a contentview?

  • But "Production" that you reference in the binding does not have Page property probably – o_w May 10 '23 at 07:51

1 Answers1

0

The offical document said:

The naming convention for bindable properties is that the bindable property identifier must match the property name specified in the Create method, with "Property" appended to it.

So you can change the code public BindableProperty ParentPageProperty = to public BindableProperty PageProperty =.

In addition, did you create accessors for the bindable property?

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14
  • Thanks I have already created the accessors and renamed the bindable property in a correct format but unfortunately It does not work but I was able to solve it with a different implementation. Instead Binding the instance of the ContentPage to a porperty of the ContentView, I directly called the Parent Class inside of my content view and was able to implement popup. – Mark Kenith Simbajon May 10 '23 at 09:45
  • Yes, the contenview.Parent will get the instance of the page. But the error message means the bindable property created wrong. Whats the `typeof(nxi_lookup)`, you can try to change it to the`typeof(ContentView)`. And l'm glad to know your problem was resolved. @MarkKenithSimbajon – Liyun Zhang - MSFT May 10 '23 at 09:52