|
14 | 14 | using Windows.UI.Xaml.Controls;
|
15 | 15 | using Windows.UI.Xaml.Controls.Primitives;
|
16 | 16 | using Windows.UI.Xaml.Data;
|
| 17 | +using Windows.UI.Xaml.Input; |
17 | 18 | using Windows.UI.Xaml.Media;
|
18 | 19 | using Windows.UI.Xaml.Shapes;
|
19 | 20 |
|
@@ -459,6 +460,38 @@ public async Task Test_Flyout_Binding()
|
459 | 460 | #endif
|
460 | 461 | }
|
461 | 462 |
|
| 463 | + [TestMethod] |
| 464 | + [RunsOnUIThread] |
| 465 | + public async Task When_Flyout_Content_Takes_Focus() |
| 466 | + { |
| 467 | + var stackPanel = new StackPanel(); |
| 468 | + var button = new Button() { Content = "Flyout owner" }; |
| 469 | + stackPanel.Children.Add(button); |
| 470 | + TestServices.WindowHelper.WindowContent = stackPanel; |
| 471 | + await TestServices.WindowHelper.WaitForIdle(); |
| 472 | + |
| 473 | + var flyout = new Flyout(); |
| 474 | + var flyoutButton = new Button() { Content = "Flyout content" }; |
| 475 | + flyout.Content = flyoutButton; |
| 476 | + FlyoutBase.SetAttachedFlyout(button, flyout); |
| 477 | + button.Focus(FocusState.Pointer); |
| 478 | + |
| 479 | + Assert.AreEqual(button, FocusManager.GetFocusedElement()); |
| 480 | + |
| 481 | + FlyoutBase.ShowAttachedFlyout(button); |
| 482 | + flyoutButton.Focus(FocusState.Pointer); |
| 483 | + await TestServices.WindowHelper.WaitForIdle(); |
| 484 | + |
| 485 | + Assert.AreNotEqual(button, FocusManager.GetFocusedElement()); |
| 486 | + |
| 487 | + flyout.Hide(); |
| 488 | + await TestServices.WindowHelper.WaitForIdle(); |
| 489 | + |
| 490 | + Assert.AreEqual(button, FocusManager.GetFocusedElement()); |
| 491 | + |
| 492 | + TestServices.WindowHelper.WindowContent = null; |
| 493 | + } |
| 494 | + |
462 | 495 | private static void VerifyRelativeContentPosition(HorizontalPosition horizontalPosition, VerticalPosition verticalPosition, FrameworkElement content, double minimumTargetOffset, FrameworkElement target)
|
463 | 496 | {
|
464 | 497 | var contentScreenBounds = content.GetOnScreenBounds();
|
|
0 commit comments