From c7c79de005580fa6a5763144f26741047b22c09c Mon Sep 17 00:00:00 2001 From: Nuklon Date: Wed, 29 Jul 2026 16:26:33 +0200 Subject: [PATCH 1/5] Add PlacementTarget binding to Flyout.xaml --- src/Wpf.Ui/Controls/Flyout/Flyout.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Wpf.Ui/Controls/Flyout/Flyout.xaml b/src/Wpf.Ui/Controls/Flyout/Flyout.xaml index 38517407d..e5a333788 100644 --- a/src/Wpf.Ui/Controls/Flyout/Flyout.xaml +++ b/src/Wpf.Ui/Controls/Flyout/Flyout.xaml @@ -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"> From a4a4f7653301847bef12ef6fe5d77ba635091349 Mon Sep 17 00:00:00 2001 From: Nuklon Date: Wed, 29 Jul 2026 16:27:45 +0200 Subject: [PATCH 2/5] Add PlacementTarget --- src/Wpf.Ui/Controls/Flyout/Flyout.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Wpf.Ui/Controls/Flyout/Flyout.cs b/src/Wpf.Ui/Controls/Flyout/Flyout.cs index 446bf27e7..550573310 100644 --- a/src/Wpf.Ui/Controls/Flyout/Flyout.cs +++ b/src/Wpf.Ui/Controls/Flyout/Flyout.cs @@ -11,12 +11,12 @@ namespace Wpf.Ui.Controls; /// /// Represents a control that creates a pop-up window that displays information for an element in the interface. /// -[TemplatePart(Name = "PART_Popup", Type = typeof(System.Windows.Controls.Primitives.Popup))] +[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; /// Identifies the dependency property. public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register( @@ -34,6 +34,14 @@ public class Flyout : System.Windows.Controls.ContentControl new PropertyMetadata(PlacementMode.Top) ); + /// Identifies the dependency property. + public static readonly DependencyProperty PlacementTargetProperty = DependencyProperty.Register( + nameof(PlacementTarget), + typeof(UIElement), + typeof(Flyout), + new PropertyMetadata(null) + ); + /// Identifies the routed event. public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent( nameof(Opened), @@ -90,6 +98,17 @@ public PlacementMode Placement set => SetValue(PlacementProperty, value); } + /// + /// Gets or sets the target for the control when the control opens. + /// + [Bindable(true)] + [Category("Layout")] + public UIElement? PlacementTarget + { + get => (UIElement?)GetValue(PlacementTargetProperty); + set => SetValue(PlacementTargetProperty, value); + } + /// /// Invoked whenever application code or an internal process, /// such as a rebuilding layout pass, calls the ApplyTemplate method. @@ -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) { From 9a21a512f745a6a4618d6f97ccd17082b574f632 Mon Sep 17 00:00:00 2001 From: Nuklon Date: Thu, 30 Jul 2026 13:55:33 +0200 Subject: [PATCH 3/5] Add dependency properties for Flyout offsets and rectangle --- src/Wpf.Ui/Controls/Flyout/Flyout.cs | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/Wpf.Ui/Controls/Flyout/Flyout.cs b/src/Wpf.Ui/Controls/Flyout/Flyout.cs index 550573310..fae664680 100644 --- a/src/Wpf.Ui/Controls/Flyout/Flyout.cs +++ b/src/Wpf.Ui/Controls/Flyout/Flyout.cs @@ -42,6 +42,30 @@ public class Flyout : System.Windows.Controls.ContentControl new PropertyMetadata(null) ); + /// Identifies the dependency property. + public static readonly DependencyProperty PlacementRectangleProperty = DependencyProperty.Register( + nameof(PlacementRectangle), + typeof(Rect), + typeof(Flyout), + new PropertyMetadata(default(Rect)) + ); + + /// Identifies the dependency property. + public static readonly DependencyProperty HorizontalOffsetProperty = DependencyProperty.Register( + nameof(HorizontalOffset), + typeof(double), + typeof(Flyout), + new PropertyMetadata(0.0) + ); + + /// Identifies the dependency property. + public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.Register( + nameof(VerticalOffset), + typeof(double), + typeof(Flyout), + new PropertyMetadata(0.0) + ); + /// Identifies the routed event. public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent( nameof(Opened), @@ -109,6 +133,39 @@ public UIElement? PlacementTarget set => SetValue(PlacementTargetProperty, value); } + /// + /// Gets or sets the PlacementRectangle property of the Flyout + /// + [Bindable(true)] + [Category("Layout")] + public Rect PlacementRectangle + { + get { return (Rect)GetValue(PlacementRectangleProperty); } + set { SetValue(PlacementRectangleProperty, value); } + } + + /// + /// Gets or sets the horizontal offset of the control when the control opens. + /// + [Bindable(true)] + [Category("Layout")] + public double HorizontalOffset + { + get { return (double)GetValue(HorizontalOffsetProperty); } + set { SetValue(HorizontalOffsetProperty, value); } + } + + /// + /// Gets or sets the vertical offset of the control when the control opens. + /// + [Bindable(true)] + [Category("Layout")] + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + /// /// Invoked whenever application code or an internal process, /// such as a rebuilding layout pass, calls the ApplyTemplate method. From 93937293ce93572c85969eed7a36e51aa6c7f3a8 Mon Sep 17 00:00:00 2001 From: Nuklon Date: Thu, 30 Jul 2026 13:56:03 +0200 Subject: [PATCH 4/5] Bind VerticalOffset and HorizontalOffset in Flyout --- src/Wpf.Ui/Controls/Flyout/Flyout.xaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/Flyout/Flyout.xaml b/src/Wpf.Ui/Controls/Flyout/Flyout.xaml index e5a333788..0ac566cfe 100644 --- a/src/Wpf.Ui/Controls/Flyout/Flyout.xaml +++ b/src/Wpf.Ui/Controls/Flyout/Flyout.xaml @@ -45,12 +45,14 @@ VerticalAlignment="{TemplateBinding VerticalAlignment}" AllowsTransparency="{TemplateBinding Popup.AllowsTransparency}" Focusable="False" + HorizontalOffset="{TemplateBinding HorizontalOffset}" IsOpen="{TemplateBinding IsOpen}" Placement="{TemplateBinding Placement}" + PlacementRectangle="{TemplateBinding PlacementRectangle}" PlacementTarget="{TemplateBinding PlacementTarget}" PopupAnimation="{TemplateBinding Popup.PopupAnimation}" StaysOpen="{TemplateBinding Popup.StaysOpen}" - VerticalOffset="1"> + VerticalOffset="{TemplateBinding VerticalOffset}"> Date: Thu, 30 Jul 2026 14:12:36 +0200 Subject: [PATCH 5/5] Fix defaults --- src/Wpf.Ui/Controls/Flyout/Flyout.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wpf.Ui/Controls/Flyout/Flyout.cs b/src/Wpf.Ui/Controls/Flyout/Flyout.cs index fae664680..323640856 100644 --- a/src/Wpf.Ui/Controls/Flyout/Flyout.cs +++ b/src/Wpf.Ui/Controls/Flyout/Flyout.cs @@ -39,7 +39,7 @@ public class Flyout : System.Windows.Controls.ContentControl nameof(PlacementTarget), typeof(UIElement), typeof(Flyout), - new PropertyMetadata(null) + new PropertyMetadata(defaultValue: null) ); /// Identifies the dependency property. @@ -47,7 +47,7 @@ public class Flyout : System.Windows.Controls.ContentControl nameof(PlacementRectangle), typeof(Rect), typeof(Flyout), - new PropertyMetadata(default(Rect)) + new PropertyMetadata(Rect.Empty) ); /// Identifies the dependency property.