Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/Wpf.Ui/Controls/Flyout/Flyout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Wpf.Ui.Controls;
/// <summary>
/// Represents a control that creates a pop-up window that displays information for an element in the interface.
/// </summary>
[TemplatePart(Name = "PART_Popup", Type = typeof(System.Windows.Controls.Primitives.Popup))]

@Nuklon Nuklon Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this part as it was already imported...

[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))]
public class Flyout : System.Windows.Controls.ContentControl
{
private const string ElementPopup = "PART_Popup";

private System.Windows.Controls.Primitives.Popup? _popup = default;
private Popup? _popup;

/// <summary>Identifies the <see cref="IsOpen"/> dependency property.</summary>
public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register(
Expand All @@ -34,6 +34,14 @@ public class Flyout : System.Windows.Controls.ContentControl
new PropertyMetadata(PlacementMode.Top)
);

/// <summary>Identifies the <see cref="PlacementTarget"/> dependency property.</summary>
public static readonly DependencyProperty PlacementTargetProperty = DependencyProperty.Register(
nameof(PlacementTarget),
typeof(UIElement),
typeof(Flyout),
new PropertyMetadata(null)
);

/// <summary>Identifies the <see cref="Opened"/> routed event.</summary>
public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent(
nameof(Opened),
Expand Down Expand Up @@ -90,6 +98,17 @@ public PlacementMode Placement
set => SetValue(PlacementProperty, value);
}

/// <summary>
/// Gets or sets the target for the <see cref="Flyout" /> control when the control opens.
/// </summary>
[Bindable(true)]
[Category("Layout")]
public UIElement? PlacementTarget
{
get => (UIElement?)GetValue(PlacementTargetProperty);
set => SetValue(PlacementTargetProperty, value);
}

/// <summary>
/// Invoked whenever application code or an internal process,
/// such as a rebuilding layout pass, calls the ApplyTemplate method.
Expand All @@ -98,7 +117,7 @@ public override void OnApplyTemplate()
{
base.OnApplyTemplate();

_popup = GetTemplateChild(ElementPopup) as System.Windows.Controls.Primitives.Popup;
_popup = GetTemplateChild(ElementPopup) as Popup;

if (_popup is null)
{
Expand Down
1 change: 1 addition & 0 deletions src/Wpf.Ui/Controls/Flyout/Flyout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
Focusable="False"
IsOpen="{TemplateBinding IsOpen}"
Placement="{TemplateBinding Placement}"
PlacementTarget="{TemplateBinding PlacementTarget}"
PopupAnimation="{TemplateBinding Popup.PopupAnimation}"
StaysOpen="{TemplateBinding Popup.StaysOpen}"
VerticalOffset="1">
Expand Down
Loading