mirror of
https://gitee.com/chinware/atomui.git
synced 2024-12-02 03:47:52 +08:00
修复 Popup 弹出问题
This commit is contained in:
parent
fe24299338
commit
25563d6f3e
@ -379,6 +379,10 @@ public abstract class AbstractPopup : Control, IPopupHostProvider
|
||||
protected virtual void NotifyClosed() {}
|
||||
protected internal virtual void NotifyPopupRootAboutToShow(PopupRoot popupRoot) {}
|
||||
|
||||
protected Control? GetEffectivePlacementTarget()
|
||||
{
|
||||
return PlacementTarget ?? this.FindLogicalAncestorOfType<Control>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the popup.
|
||||
@ -390,7 +394,7 @@ public abstract class AbstractPopup : Control, IPopupHostProvider
|
||||
return;
|
||||
}
|
||||
|
||||
var placementTarget = PlacementTarget ?? this.FindLogicalAncestorOfType<Control>();
|
||||
var placementTarget = GetEffectivePlacementTarget();
|
||||
|
||||
if (placementTarget == null) {
|
||||
_isOpenRequested = true;
|
||||
@ -654,8 +658,10 @@ public abstract class AbstractPopup : Control, IPopupHostProvider
|
||||
private void HandlePositionChange()
|
||||
{
|
||||
if (_openState != null) {
|
||||
var placementTarget = PlacementTarget ?? this.FindLogicalAncestorOfType<Control>();
|
||||
if (placementTarget == null) return;
|
||||
var placementTarget = GetEffectivePlacementTarget();
|
||||
if (placementTarget == null) {
|
||||
return;
|
||||
}
|
||||
_openState.PopupHost.ConfigurePosition(
|
||||
placementTarget,
|
||||
Placement,
|
||||
|
@ -80,9 +80,9 @@ public class Popup : AbstractPopup
|
||||
protected override void NotifyPopupHostCreated(IPopupHost popupHost)
|
||||
{
|
||||
base.NotifyPopupHostCreated(popupHost);
|
||||
|
||||
if (PlacementTarget is not null) {
|
||||
var toplevel = TopLevel.GetTopLevel(PlacementTarget);
|
||||
var placementTarget = GetEffectivePlacementTarget();
|
||||
if (placementTarget is not null) {
|
||||
var toplevel = TopLevel.GetTopLevel(placementTarget);
|
||||
if (toplevel is null) {
|
||||
throw new InvalidOperationException(
|
||||
"Unable to create shadow layer, top level for PlacementTarget is null.");
|
||||
@ -207,7 +207,7 @@ public class Popup : AbstractPopup
|
||||
VerticalOffset = offsetY;
|
||||
|
||||
var direction = PopupUtils.GetDirection(Placement);
|
||||
var placementTarget = PlacementTarget ?? this.FindLogicalAncestorOfType<Control>();
|
||||
var placementTarget = GetEffectivePlacementTarget();
|
||||
if (placementTarget is null) {
|
||||
throw new InvalidOperationException("Placement mode is not Pointer and PlacementTarget is null");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user