public void GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Sibling_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }), new StackPanel { Children = new Controls { (next = new Button { Name = "Button4" }), new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNextInTabOrder(current); Assert.Equal(next, result); }
private void InitializeComponent() { PerspexXamlLoader.Load(this); _carousel = this.FindControl<Carousel>("carousel"); _left = this.FindControl<Button>("left"); _right = this.FindControl<Button>("right"); }
public void Next_Continue_Returns_Next_Control_In_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { new Button { Name = "Button1" }, (current = new Button { Name = "Button2" }), (next = new Button { Name = "Button3" }), } }), new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); }
public void GetNextInTabOrder_Continue_Returns_Child_Of_Top_Level() { Button next; var top = new StackPanel { Children = new Controls { (next = new Button { Name = "Button1" }), } }; var result = KeyboardNavigationHandler.GetNextInTabOrder(top); Assert.Equal(next, result); }
public void Down_Contained_Stops_At_End() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Down); Assert.Null(result); }
public void Down_Continue_Returns_First_Control_In_Down_Sibling_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { (next = new Button { Name = "Button4" }), new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Down); Assert.Equal(next, result); }
public void Template_Child_Of_Control_With_Two_Classes() { var template = new ControlTemplate(parent => { return new Border { Name = "border", }; }); var control = new Button { Template = template, }; control.ApplyTemplate(); var selector = new Selector() .OfType<Button>() .Class("foo") .Class("bar") .Template() .Name("border"); var border = (Border)((IVisual)control).VisualChildren.Single(); var values = new List<bool>(); var activator = selector.Match(border).ObservableResult; activator.Subscribe(x => values.Add(x)); Assert.Equal(new[] { false }, values); control.Classes.Add("foo", "bar"); Assert.Equal(new[] { false, true }, values); control.Classes.Remove("foo"); Assert.Equal(new[] { false, true, false }, values); }
public void Previous_Continue_Returns_Last_Child_Of_Sibling() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (next = new Button { Name = "Button3" }), } }), (current = new Button { Name = "Button4" }), } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); }
public void GetNextInTabOrder_Never_Skips_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Never, Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, new Button { Name = "Button3" }, } }), new StackPanel { Children = new Controls { (next = new Button { Name = "Button4" }), new Button { Name = "Button5" }, (current = new Button { Name = "Button6" }), } }, } }; KeyboardNavigation.SetTabOnceActiveElement(container, next); var result = KeyboardNavigationHandler.GetNextInTabOrder(current); Assert.Equal(next, result); }
public void GetNextInTabOrder_Cycle_Wraps_To_First() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }), new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNextInTabOrder(current); Assert.Equal(next, result); }
private static TabItem AnimationsTab() { Border border1; Border border2; RotateTransform rotate; Button button1; var result = new TabItem { Header = "Animations", Content = new StackPanel { Orientation = Orientation.Vertical, Gap = 4, Margin = new Thickness(10), Children = new Controls { new TextBlock { Text = "Animations", FontWeight = FontWeight.Medium, FontSize = 20, Foreground = SolidColorBrush.Parse("#212121"), }, new TextBlock { Text = "A few animations showcased below", FontSize = 13, Foreground = SolidColorBrush.Parse("#727272"), Margin = new Thickness(0, 0, 0, 10) }, (button1 = new Button { Content = "Animate", Width = 120, [Grid.ColumnProperty] = 1, [Grid.RowProperty] = 1, }), new Canvas { ClipToBounds = false, Children = new Controls { (border1 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Crimson, RenderTransform = new RotateTransform(), Child = new TextBox { Background = Brushes.White, Text = "Hello!", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, [Canvas.LeftProperty] = 100, [Canvas.TopProperty] = 100, }), (border2 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Coral, Child = new Image { Source = new Bitmap("github_icon.png"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, RenderTransform = (rotate = new RotateTransform { PropertyTransitions = new PropertyTransitions { RotateTransform.AngleProperty.Transition(500), } }), PropertyTransitions = new PropertyTransitions { Layoutable.WidthProperty.Transition(300), Layoutable.HeightProperty.Transition(1000), }, [Canvas.LeftProperty] = 400, [Canvas.TopProperty] = 100, }), } } }, }, }; button1.Click += (s, e) => { if (border2.Width == 100) { border2.Width = border2.Height = 400; rotate.Angle = 180; } else { border2.Width = border2.Height = 100; rotate.Angle = 0; } }; var start = Animate.Stopwatch.Elapsed; var degrees = Animate.Timer .Select(x => { var elapsed = (x - start).TotalSeconds; var cycles = elapsed / 4; var progress = cycles % 1; return 360.0 * progress; }); border1.RenderTransform.Bind( RotateTransform.AngleProperty, degrees, BindingPriority.Animation); return result; }
public void Up_Cycle_Wraps_To_Last() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, Children = new Controls { (current = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (next = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Up); Assert.Equal(next, result); }
private static TabItem ImagesTab() { var imageCarousel = new Carousel { Width = 400, Height = 400, Transition = new PageSlide(TimeSpan.FromSeconds(0.25)), Items = new[] { new Image { Source = new Bitmap(GetImage("github_icon.png")), Width = 400, Height = 400 }, new Image { Source = new Bitmap(GetImage("pattern.jpg")), Width = 400, Height = 400 }, } }; var next = new Button { VerticalAlignment = VerticalAlignment.Center, Padding = new Thickness(20), Content = new Perspex.Controls.Shapes.Path { Data = StreamGeometry.Parse("M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"), Fill = Brushes.Black } }; var prev = new Button { VerticalAlignment = VerticalAlignment.Center, Padding = new Thickness(20), Content = new Perspex.Controls.Shapes.Path { Data = StreamGeometry.Parse("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"), Fill = Brushes.Black } }; prev.Click += (s, e) => { if (imageCarousel.SelectedIndex == 0) imageCarousel.SelectedIndex = 1; else imageCarousel.SelectedIndex--; }; next.Click += (s, e) => { if (imageCarousel.SelectedIndex == 1) imageCarousel.SelectedIndex = 0; else imageCarousel.SelectedIndex++; }; return new TabItem { Header = "Images", Content = new ScrollViewer { Content = new StackPanel { HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Top, Gap = 4, Margin = new Thickness(10), Children = new Controls { new TextBlock { Text = "Carousel", FontWeight = FontWeight.Medium, FontSize = 20, Foreground = SolidColorBrush.Parse("#212121"), }, new TextBlock { Text = "An items control that displays its items as pages that fill the controls.", FontSize = 13, Foreground = SolidColorBrush.Parse("#727272"), Margin = new Thickness(0, 0, 0, 10) }, new StackPanel { Name = "carouselVisual", Orientation = Orientation.Horizontal, Gap = 4, Children = new Controls { prev, imageCarousel, next } } } } } }; }
public void GetPreviousInTabOrder_Continue_Wraps() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { (current = new Button { Name = "Button1" }), new Button { Name = "Button2" }, new Button { Name = "Button3" }, } }), }, }, new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, (next = new Button { Name = "Button6" }), } }, } }; var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); Assert.Equal(next, result); }
private static TabItem AnimationsTab() { Border border1; Border border2; RotateTransform rotate; Button button1; var result = new TabItem { Header = "Animations", Content = new Grid { ColumnDefinitions = new ColumnDefinitions { new ColumnDefinition(1, GridUnitType.Star), new ColumnDefinition(1, GridUnitType.Star), }, RowDefinitions = new RowDefinitions { new RowDefinition(1, GridUnitType.Star), new RowDefinition(GridLength.Auto), }, Children = new Controls { (border1 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Crimson, RenderTransform = new RotateTransform(), Child = new TextBox { Background = Brushes.White, Text = "Hello!", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, }), (border2 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Coral, Child = new Image { Source = new Bitmap("github_icon.png"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, RenderTransform = (rotate = new RotateTransform { PropertyTransitions = new PropertyTransitions { RotateTransform.AngleProperty.Transition(500), } }), PropertyTransitions = new PropertyTransitions { Layoutable.WidthProperty.Transition(300), Layoutable.HeightProperty.Transition(1000), }, [Grid.ColumnProperty] = 1, }), (button1 = new Button { HorizontalAlignment = HorizontalAlignment.Center, Content = "Animate", [Grid.ColumnProperty] = 1, [Grid.RowProperty] = 1, }), }, }, }; button1.Click += (s, e) => { if (border2.Width == 100) { border2.Width = border2.Height = 400; rotate.Angle = 180; } else { border2.Width = border2.Height = 100; rotate.Angle = 0; } }; var start = Animate.Stopwatch.Elapsed; var degrees = Animate.Timer .Select(x => { var elapsed = (x - start).TotalSeconds; var cycles = elapsed / 4; var progress = cycles % 1; return 360.0 * progress; }); border1.RenderTransform.Bind( RotateTransform.AngleProperty, degrees, BindingPriority.Animation); return result; }
private static TabItem ButtonsTab() { Button defaultButton; var showDialog = ReactiveCommand.Create(); Button showDialogButton; var result = new TabItem { Header = "Buttons", Content = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Gap = 8, MinWidth = 120, Children = new Controls { (showDialogButton = new Button { Content = "Button", Command = showDialog, [ToolTip.TipProperty] = "Hello World!", }), new Button { Content = "Button", Background = new SolidColorBrush(0xcc119eda), [ToolTip.TipProperty] = "Goodbye Cruel World!", }, (defaultButton = new Button { Content = "Default", IsDefault = true, }), new Button { Content = "Disabled", IsEnabled = false, }, new Button { Content = "Disabled", IsEnabled = false, Background = new SolidColorBrush(0xcc119eda), }, new ToggleButton { Content = "Toggle", }, new ToggleButton { Content = "Disabled", IsEnabled = false, }, new CheckBox { Content = "Checkbox", }, new RadioButton { Content = "RadioButton 1", IsChecked = true, }, new RadioButton { Content = "RadioButton 2", }, } }, }; defaultButton.Click += (s, e) => { defaultButton.Content = ((string)defaultButton.Content == "Default") ? "Clicked" : "Default"; }; showDialog.Subscribe(async _ => { var close = ReactiveCommand.Create(); var dialog = new Window { Content = new StackPanel { Width = 200, Height = 200, Children = new Controls { new Button { Content = "Yes", Command = close, CommandParameter = "Yes" }, new Button { Content = "No", Command = close, CommandParameter = "No" }, } } }; close.Subscribe(x => dialog.Close(x)); showDialogButton.Content = await dialog.ShowDialog<string>(); }); return result; }
/// <summary> /// The default template for the <see cref="Button"/> control. /// </summary> /// <param name="control">The control being styled.</param> /// <returns>The root of the instantiated template.</returns> public static Control Template(Button control) { Border border = new Border { Name = "border", Padding = new Thickness(3), Child = new ContentPresenter { Name = "contentPresenter", [~ContentPresenter.ContentProperty] = control[~Button.ContentProperty], [~ContentPresenter.HorizontalAlignmentProperty] = control[~Button.HorizontalContentAlignmentProperty], [~ContentPresenter.VerticalAlignmentProperty] = control[~Button.VerticalContentAlignmentProperty], }, [~Border.BackgroundProperty] = control[~Button.BackgroundProperty], }; return border; }
/// <summary> /// The default template for the <see cref="Button"/> control. /// </summary> /// <param name="control">The control being styled.</param> /// <returns>The root of the instantiated template.</returns> public static Control Template(Button control) { Border border = new Border { Name = "border", Padding = new Thickness(3), Child = new ContentPresenter { Name = "contentPresenter", [~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty], [~TextBlock.ForegroundProperty] = control[~TemplatedControl.ForegroundProperty], [~Layoutable.HorizontalAlignmentProperty] = control[~ContentControl.HorizontalContentAlignmentProperty], [~Layoutable.VerticalAlignmentProperty] = control[~ContentControl.VerticalContentAlignmentProperty], }, [~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty], [~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty], [~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty], }; return border; }
public void GetPreviousInTabOrder_Once_Moves_To_Previous_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (next = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, Children = new Controls { new Button { Name = "Button4" }, (current = new Button { Name = "Button5" }), new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); Assert.Equal(next, result); }
public void Previous_Continue_Returns_Parent() { Button current; var top = new Decorator { Focusable = true, Child = current = new Button { Name = "Button", } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(top, result); }
private static TabItem AnimationsTab() { Border border1; Border border2; RotateTransform rotate; Button button1; var result = new TabItem { Header = "Animations", Content = new StackPanel { Orientation = Orientation.Vertical, Gap = 4, Margin = new Thickness(10), Children = new Controls { new TextBlock { Text = "Animations", FontWeight = FontWeight.Medium, FontSize = 20, Foreground = SolidColorBrush.Parse("#212121"), }, new TextBlock { Text = "A few animations showcased below", FontSize = 13, Foreground = SolidColorBrush.Parse("#727272"), Margin = new Thickness(0, 0, 0, 10) }, (button1 = new Button { Content = "Animate", Width = 120, [Grid.ColumnProperty] = 1, [Grid.RowProperty] = 1, }), new Canvas { ClipToBounds = false, Children = new Controls { (border1 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Crimson, RenderTransform = new RotateTransform(), Child = new Grid { Children = new Controls { new Ellipse() { Width = 100, Height = 100, Fill = new RadialGradientBrush() { GradientStops = { new GradientStop(Colors.Blue, 0), new GradientStop(Colors.Green, 1) }, Radius = 75 } }, new Perspex.Controls.Shapes.Path { Data = StreamGeometry.Parse( "F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"), Fill = new LinearGradientBrush() { GradientStops = { new GradientStop(Colors.Green, 0), new GradientStop(Colors.LightSeaGreen, 1) } }, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, RenderTransform = new MatrixTransform(Matrix.CreateScale(2, 2)) } } }, [Canvas.LeftProperty] = 100, [Canvas.TopProperty] = 100, }), (border2 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Coral, Child = new Image { Source = new Bitmap(GetImage("github_icon.png")), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, RenderTransform = (rotate = new RotateTransform { PropertyTransitions = new PropertyTransitions { RotateTransform.AngleProperty.Transition(500), } }), PropertyTransitions = new PropertyTransitions { Layoutable.WidthProperty.Transition(300), Layoutable.HeightProperty.Transition(1000), }, [Canvas.LeftProperty] = 400, [Canvas.TopProperty] = 100, }), } } }, }, }; button1.Click += (s, e) => { if (border2.Width == 100) { border2.Width = border2.Height = 400; rotate.Angle = 180; } else { border2.Width = border2.Height = 100; rotate.Angle = 0; } }; var start = Animate.Stopwatch.Elapsed; var degrees = Animate.Timer .Select(x => { var elapsed = (x - start).TotalSeconds; var cycles = elapsed / 4; var progress = cycles % 1; return 360.0 * progress; }); border1.RenderTransform.Bind( RotateTransform.AngleProperty, degrees, BindingPriority.Animation); return result; }
public void Previous_Contained_Returns_Previous_Control_In_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { (next = new Button { Name = "Button1" }), (current = new Button { Name = "Button2" }), new Button { Name = "Button3" }, } }), new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); }
public void Up_Continue_Returns_Parent() { Button current; var top = new Decorator { Focusable = true, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Child = current = new Button { Name = "Button", } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Up); Assert.Equal(top, result); }
public void Next_Continue_Doesnt_Enter_Panel_With_TabNavigation_None() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None, Children = new Controls { new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } } } }; var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); }
public void Down_Continue_Returns_Child_Of_Top_Level() { Button next; var top = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { (next = new Button { Name = "Button1" }), } }; var result = KeyboardNavigationHandler.GetNext(top, FocusNavigationDirection.Down); Assert.Equal(next, result); }
public void Previous_Once_Moves_To_Active_Element() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, Children = new Controls { new Button { Name = "Button1" }, (next = new Button { Name = "Button2" }), new Button { Name = "Button3" }, } }), new StackPanel { Children = new Controls { (current = new Button { Name = "Button4" }), new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; KeyboardNavigation.SetTabOnceActiveElement(container, next); var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); }