If you create the Popup with code, you have to explicitly set the PlacementTarget property. Any example?
When the Popup is declared in XAML and you want to center it, attach it to the Page element and set its Placement property to "Center". How to attach it to Page?
1 Answer, 1 is accepted
0
Accepted
Lance | Senior Manager Technical Support
Telerik team
answered on 07 Apr 2022, 01:12 PM
Hi Scofield,
If your ContentPage has an x:Name, then you can use that name for the PlacementTarget:
popup.PlacementTarget = MyPage;
Otherwise, you can use 'this' for the page object, let me explain.
The 'this' keyword means the object that the code's current class. So, if you're writing code in the code -behind of a ContentPage, you can use 'this' for the PlacementTarget.
Regards,
Lance | Manager Technical Support
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Thanks for your feedback and I did the same code in my MianPage of my .Net Maui project, but I got the NullReferenceException, any advice on it?
Lance | Senior Manager Technical Support
Telerik team
commented on 07 Apr 2022, 05:04 PM
Ah, I am also getting an exception, my apologies for missing this earlier. I am opening a Bug Report on your behalf so that I can involve the development team to investigate this.
Hi Lance, I found some workaround for this one, it can work well if we put the teletikUI popup code into other method instead of the structure method in MainPage.
Lance | Senior Manager Technical Support
Telerik team
commented on 11 Apr 2022, 12:35 PM
Correct, anywhere except the constructor of the first page in the project, will be fine. The underlying problem is due to App.Current.Main is not ready by the time we attempt to attach the popup. That's the source of the NullReferenceException you're seeing. We have already fixed this internally and it will be available in the next preview update (0.7.0)