-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PlacementMode
-> Placement
#10664
Merged
Merged
PlacementMode
-> Placement
#10664
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2eb04c2
Rename Popup.PlacementMode to Popup.Placement
robloo cc7656e
Rename ContextMenu.PlacementMode to ContextMenu.Placement
robloo a2a60fa
Use newer convention for property get/set
robloo 6f523e1
Inherit some ContextMenu property docs from Popup
robloo dd8f251
Merge branch 'master' into placementmode
robloo c636dc5
Update for latest master changes
robloo 2b33704
Add back PlacementMode properties as obsolete aliases of Placement
robloo b116a87
Attempt to fix CI build failure
robloo 32886d7
Revert "Attempt to fix CI build failure"
robloo 8fa365c
Fix PlacementMode property order
robloo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,11 +54,17 @@ public class ContextMenu : MenuBase, ISetterValue, IPopupHostProvider | |
public static readonly StyledProperty<PopupGravity> PlacementGravityProperty = | ||
Popup.PlacementGravityProperty.AddOwner<ContextMenu>(); | ||
|
||
/// <summary> | ||
/// Defines the <see cref="Placement"/> property. | ||
/// </summary> | ||
public static readonly StyledProperty<PlacementMode> PlacementProperty = | ||
Popup.PlacementProperty.AddOwner<ContextMenu>(); | ||
|
||
/// <summary> | ||
/// Defines the <see cref="PlacementMode"/> property. | ||
/// </summary> | ||
public static readonly StyledProperty<PlacementMode> PlacementModeProperty = | ||
Popup.PlacementModeProperty.AddOwner<ContextMenu>(); | ||
[Obsolete("Use the Placement property instead.")] | ||
public static readonly StyledProperty<PlacementMode> PlacementModeProperty = PlacementProperty; | ||
|
||
/// <summary> | ||
/// Defines the <see cref="PlacementRect"/> property. | ||
|
@@ -108,99 +114,80 @@ public ContextMenu(IMenuInteractionHandler interactionHandler) | |
static ContextMenu() | ||
{ | ||
ItemsPanelProperty.OverrideDefaultValue<ContextMenu>(DefaultPanel); | ||
PlacementModeProperty.OverrideDefaultValue<ContextMenu>(PlacementMode.Pointer); | ||
PlacementProperty.OverrideDefaultValue<ContextMenu>(PlacementMode.Pointer); | ||
ContextMenuProperty.Changed.Subscribe(ContextMenuChanged); | ||
AutomationProperties.AccessibilityViewProperty.OverrideDefaultValue<ContextMenu>(AccessibilityView.Control); | ||
AutomationProperties.ControlTypeOverrideProperty.OverrideDefaultValue<ContextMenu>(AutomationControlType.Menu); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the Horizontal offset of the context menu in relation to the <see cref="PlacementTarget"/>. | ||
/// </summary> | ||
/// <inheritdoc cref="Popup.HorizontalOffset"/> | ||
public double HorizontalOffset | ||
{ | ||
get { return GetValue(HorizontalOffsetProperty); } | ||
set { SetValue(HorizontalOffsetProperty, value); } | ||
get => GetValue(HorizontalOffsetProperty); | ||
set => SetValue(HorizontalOffsetProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the Vertical offset of the context menu in relation to the <see cref="PlacementTarget"/>. | ||
/// </summary> | ||
/// <inheritdoc cref="Popup.VerticalOffset"/> | ||
public double VerticalOffset | ||
{ | ||
get { return GetValue(VerticalOffsetProperty); } | ||
set { SetValue(VerticalOffsetProperty, value); } | ||
get => GetValue(VerticalOffsetProperty); | ||
set => SetValue(VerticalOffsetProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the anchor point on the <see cref="PlacementRect"/> when <see cref="PlacementMode"/> | ||
/// is <see cref="PlacementMode.AnchorAndGravity"/>. | ||
/// </summary> | ||
/// <inheritdoc cref="Popup.PlacementAnchor"/> | ||
public PopupAnchor PlacementAnchor | ||
{ | ||
get { return GetValue(PlacementAnchorProperty); } | ||
set { SetValue(PlacementAnchorProperty, value); } | ||
get => GetValue(PlacementAnchorProperty); | ||
set => SetValue(PlacementAnchorProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value describing how the context menu position will be adjusted if the | ||
/// unadjusted position would result in the context menu being partly constrained. | ||
/// </summary> | ||
/// <inheritdoc cref="Popup.PlacementConstraintAdjustment"/> | ||
public PopupPositionerConstraintAdjustment PlacementConstraintAdjustment | ||
{ | ||
get { return GetValue(PlacementConstraintAdjustmentProperty); } | ||
set { SetValue(PlacementConstraintAdjustmentProperty, value); } | ||
get => GetValue(PlacementConstraintAdjustmentProperty); | ||
set => SetValue(PlacementConstraintAdjustmentProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value which defines in what direction the context menu should open | ||
/// when <see cref="PlacementMode"/> is <see cref="PlacementMode.AnchorAndGravity"/>. | ||
/// </summary> | ||
/// <inheritdoc cref="Popup.PlacementGravity"/> | ||
public PopupGravity PlacementGravity | ||
{ | ||
get { return GetValue(PlacementGravityProperty); } | ||
set { SetValue(PlacementGravityProperty, value); } | ||
get => GetValue(PlacementGravityProperty); | ||
set => SetValue(PlacementGravityProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the placement mode of the context menu in relation to the<see cref="PlacementTarget"/>. | ||
/// </summary> | ||
/// <inheritdoc cref="Placement"/> | ||
[Obsolete("Use the Placement property instead.")] | ||
public PlacementMode PlacementMode | ||
{ | ||
get { return GetValue(PlacementModeProperty); } | ||
set { SetValue(PlacementModeProperty, value); } | ||
get => GetValue(PlacementProperty); | ||
set => SetValue(PlacementProperty, value); | ||
} | ||
|
||
/// <inheritdoc cref="Popup.Placement"/> | ||
public PlacementMode Placement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the Popup "Placement" properties shouldn't really be duplicated here. There is an open question if ContextMenu should be deriving from PopupFlyoutBase as well (like MenuFlyout). |
||
{ | ||
get => GetValue(PlacementProperty); | ||
set => SetValue(PlacementProperty, value); | ||
} | ||
|
||
public bool WindowManagerAddShadowHint | ||
{ | ||
get { return GetValue(WindowManagerAddShadowHintProperty); } | ||
set { SetValue(WindowManagerAddShadowHintProperty, value); } | ||
get => GetValue(WindowManagerAddShadowHintProperty); | ||
set => SetValue(WindowManagerAddShadowHintProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the the anchor rectangle within the parent that the context menu will be placed | ||
/// relative to when <see cref="PlacementMode"/> is <see cref="PlacementMode.AnchorAndGravity"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// The placement rect defines a rectangle relative to <see cref="PlacementTarget"/> around | ||
/// which the popup will be opened, with <see cref="PlacementAnchor"/> determining which edge | ||
/// of the placement target is used. | ||
/// | ||
/// If unset, the anchor rectangle will be the bounds of the <see cref="PlacementTarget"/>. | ||
/// </remarks> | ||
/// <inheritdoc cref="Popup.PlacementRect"/> | ||
public Rect? PlacementRect | ||
{ | ||
get { return GetValue(PlacementRectProperty); } | ||
set { SetValue(PlacementRectProperty, value); } | ||
get => GetValue(PlacementRectProperty); | ||
set => SetValue(PlacementRectProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the control that is used to determine the popup's position. | ||
/// </summary> | ||
/// <inheritdoc cref="Popup.PlacementTarget"/> | ||
public Control? PlacementTarget | ||
{ | ||
get { return GetValue(PlacementTargetProperty); } | ||
set { SetValue(PlacementTargetProperty, value); } | ||
get => GetValue(PlacementTargetProperty); | ||
set => SetValue(PlacementTargetProperty, value); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -343,9 +330,9 @@ private void Open(Control control, Control placementTarget, bool requestedByPoin | |
((ISetLogicalParent)_popup).SetParent(control); | ||
} | ||
|
||
_popup.PlacementMode = !requestedByPointer && PlacementMode == PlacementMode.Pointer | ||
_popup.Placement = !requestedByPointer && Placement == PlacementMode.Pointer | ||
? PlacementMode.Bottom | ||
: PlacementMode; | ||
: Placement; | ||
|
||
//Position of the line below is really important. | ||
//All styles are being applied only when control has logical parent. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm inheriting the docs from Popup now. The only downside is "context menu" wording is replaced by "popup". I don't consider this a major issue and it's better to find more general wording in the base docs than duplicate them everywhere.