How to create a reusable popup in .net maui

1 Answer 163 Views
Popup
Prabhav
Top achievements
Rank 1
Prabhav asked on 21 Feb 2024, 06:10 AM | edited on 21 Feb 2024, 06:12 AM

How to create a reusable styled popup? I want a popup with rounded corners and 2 styled buttons and then inhreit from this BasePopup and get the styling by default, instead of adding this again and again for each popup I create. And then the popup inherting it can add it’s own content and provide commands or actions accordingly for those buttons

in a contentpage you would do it using ControlTemplate and ContentPresenter but I dont see it for the radpopup

1 Answer, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 26 Feb 2024, 06:42 PM

Hi Prabhav,

Actually RadPopup is not a visual element, it is responsible for showing and positioning its Content, that's why it does not have a ControlTemplate.

You can try to create a custom Popup control which inherits from RadPopup with a predefined Content and plug some additional ContentView or any other View element inside it. I've attached a sample app showing what I mean, please download it and give it a try.

Note this is only a basic implementation that should be further extended to meet the exact requirements you have.

I hope I was of help.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Prabhav
Top achievements
Rank 1
commented on 27 Feb 2024, 06:47 AM | edited

thanks @Yana. 

I was able to get this working with your idea.

i did find some telerik bugs during that, not sure if i should create new discussion/support ticker or documenting here is enough

 

- The binding to BackgroundColor of RadBorder doesnt work. i have a custom markup extension similar to AppThemeBinding. When i give it a color variable, it just goes transparent. The same thing work if I use the maui border control.

- I cant set a x:Name for the radPopup. This makes it not possible to bind to the BindableProperties I have. In your sample you add the layout programtically but the binding way is desired. Infact I cant add a name to any controls inside the radPopup.

Yana
Telerik team
commented on 27 Feb 2024, 01:06 PM

I will go directly to the second issue - that's because the RadPopup is not a visual element, so it's expected.  On second thought, it seems the approach I came up with is suitable for simpler scenarios, and it seems to me,  it will not be the best option for the scenario you have. 

I would suggest instead of creating a custom RadPopup, create a ContentView with the functionality to plug into it additional Content ( you can easily use bindings in this case) and just create a RadPopup instance and set its Content to that ContentView.

As to the issue with the BackgroundColor of the RadBorder - do you reproduce it outside the custom RadPopup? If so, please open a new case with more details on the custom markup extension, so we can take a detailed look on it.

Tags
Popup
Asked by
Prabhav
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or