private void Popup_Opened(object sender, EventArgs e) { System.Windows.Controls.Primitives.Popup popup = sender as System.Windows.Controls.Primitives.Popup; if (popup == null || popup.Child == null) { return; } if (_textBlock == null) { _textBlock = FindVisualChild <System.Windows.Controls.TextBlock>(popup.Child, TextBlockKey); } if (popup.PlacementTarget == null || _textBlock == null) { return; } Point relativePoint = _textBlock.TranslatePoint(new Point(0, 0), (UIElement)popup.PlacementTarget); if (relativePoint.X < 0) { FlowDirectionFromOrigin = System.Windows.FlowDirection.RightToLeft; // TODO: find a way to make the binding work (popup.Child as StackPanel).FlowDirection = System.Windows.FlowDirection.RightToLeft; } else { FlowDirectionFromOrigin = System.Windows.FlowDirection.LeftToRight; // TODO: find a way to make the binding work (popup.Child as StackPanel).FlowDirection = System.Windows.FlowDirection.LeftToRight; } }