-
-
Notifications
You must be signed in to change notification settings - Fork 941
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I tried to modify the Placement property on the <ContextMenu Placement="Top"> in xaml, but it didn't take effect.
Here is the complete code:
<ui:DropDownButton Content="Hello" Icon="{ui:SymbolIcon Fluent24}">
<ui:DropDownButton.Flyout>
<ContextMenu Placement="Top">
<MenuItem Header="Add" />
<MenuItem Header="Remove" />
</ContextMenu>
</ui:DropDownButton.Flyout>
</ui:DropDownButton>
After checking, I found that there is such code in DropDownButtons.cs
private void OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (_contextMenu is null)
{
return;
}
_contextMenu.SetCurrentValue(MinWidthProperty, ActualWidth);
_contextMenu.SetCurrentValue(ContextMenu.PlacementTargetProperty, this);
_contextMenu.SetCurrentValue(
ContextMenu.PlacementProperty,
System.Windows.Controls.Primitives.PlacementMode.Bottom
);
_contextMenu.SetCurrentValue(ContextMenu.IsOpenProperty, true);
}
Maybe
_contextMenu.SetCurrentValue(
ContextMenu.PlacementProperty,
System.Windows.Controls.Primitives.PlacementMode.Bottom
);
should be removed or modified.
To Reproduce
Define a DropDownButton in the xaml file and modify the placement of Flyout.
Sample code:
<ui:DropDownButton Content="Hello">
<ui:DropDownButton.Flyout>
<ContextMenu Placement="Top">
<MenuItem Header="Add" />
<MenuItem Header="Remove" />
</ContextMenu>
</ui:DropDownButton.Flyout>
</ui:DropDownButton>
Expected behavior
The placement property of flyout can be modified through xaml.
Screenshots
No response
OS version
Windows 11 Pro 25H2, build 26200.7922
.NET version
.net framework 4.8.1
WPF-UI NuGet version
WPFUI 4.2.0
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working