英文:
Show a topmost popup attached to a control in .NET MAUI
问题
我正在尝试实现一个可以从XAML中创建并继承自ContentView
的用户控件中弹出的标注。这个控件本身是一个圆形,应该占据页面上的一定空间,而标注应该浮在所有其他控件之上。目前,我们只针对Windows进行开发。
在使用该控件时,我已经设置了很高的ZIndex
,并且我使用了一个具有IsClippedToBounds="False"
属性的Grid,并使用LineSegment
绘制标注,让它超出了网格的边界。
但是,如果我现在将这个控件放在CollectionView
中,标注总是被裁剪并显示在集合视图标题下面。我已经尝试在集合的所有元素上设置ZIndex
:单元格、集合视图本身以及包含集合视图的视图,但似乎无法阻止这种行为。
是否有人有想法如何处理这种情况?
英文:
I'm trying to implement a callout that can pop up from a user control that's created in XAML and is derived from ContentView
. The control itself is a circle that should take up a certain space on a page and the callout should float above all other controls. We're only targeting Windows at the moment.
I've set a high ZIndex
when using the control and I've used a Grid with IsClippedToBounds="False"
and draw the callout over the boundaries of the grid using LineSegment
s.
If I now use this control inside a CollectionView
, the callout always gets clipped and ends up under the collection view header. I've tried setting the Zindex
on all elements of the collection: the cell, the collection view itself and the view the collection view is contained in but I can't seem to be able to prevent this behavior.
Does anyone have an idea how to handle a case like this?
答案1
得分: 1
是的。
简短回答:这不适合放在父级元素中,它应该是顶级元素。您需要找到该特定列表项的位置,并使用它来在正确的位置显示弹出窗口。
如果您希望在滚动时跟随该项目,您将很难实现它。
(如果是我,我会从这里“获得灵感”:https://github.com/LuckyDucko/Mopups)
关于这个修剪。首先,这是预期的。其次,您将很难自定义它。第三,它在IOS和Android上的表现不一致。我曾因为这个问题而苦苦挣扎,以使大多数圆角正确呈现。但如果您愿意,可以继续尝试...
英文:
Yes.
Short answer: this has no place in the parent, it should be top element. You need to find the position for that particular list item, and use it to display the popup at the right position.
If you expect this to follow the item when you scroll, you will have hard time implementing it.
(At your place, I would "get inspiration" from here: https://github.com/LuckyDucko/Mopups)
About this trim. First, it is expected. Second, you will have hard time customizing it. Third, it does not behave consistent across IOS and Android. I had hard time to make most round corners render properly. I gave up on some controls ideas because of that.
But if you want, you can keep trying...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论