File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/FocusBehavior
Microsoft.Toolkit.Uwp.UI/Behaviors Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5- using Windows . UI . Xaml ;
65using Windows . UI . Xaml . Controls ;
76
87namespace Microsoft . Toolkit . Uwp . SampleApp . SamplePages
98{
109 /// <summary>
1110 /// A page that shows how to use the FocusBehavior
1211 /// </summary>
13- public sealed partial class FocusBehaviorPage : Page , IXamlRenderListener
12+ public sealed partial class FocusBehaviorPage : Page
1413 {
1514 public FocusBehaviorPage ( ) => InitializeComponent ( ) ;
16-
17- public void OnXamlRendered ( FrameworkElement control )
18- {
19-
20- }
2115 }
2216}
Original file line number Diff line number Diff line change @@ -30,7 +30,16 @@ public sealed class FocusBehavior : BehaviorBase<UIElement>
3030 typeof ( FocusBehavior ) ,
3131 new PropertyMetadata ( null , OnTargetsPropertyChanged ) ) ;
3232
33- private static readonly TimeSpan FocusEngagementTimeout = TimeSpan . FromMilliseconds ( 100 ) ;
33+
34+ /// <summary>
35+ /// The DP to store the <see cref="FocusEngagementTimeout"/> property value.
36+ /// </summary>
37+ public static readonly DependencyProperty FocusEngagementTimeoutProperty = DependencyProperty . Register (
38+ nameof ( FocusEngagementTimeout ) ,
39+ typeof ( TimeSpan ) ,
40+ typeof ( FocusBehavior ) ,
41+ new PropertyMetadata ( TimeSpan . FromMilliseconds ( 100 ) ) ) ;
42+
3443 private DispatcherTimer _timer ;
3544
3645 /// <summary>
@@ -47,6 +56,16 @@ public FocusTargetList Targets
4756 set => SetValue ( TargetsProperty , value ) ;
4857 }
4958
59+ /// <summary>
60+ /// Gets or sets the timeout before the <see cref="FocusBehavior"/> stops trying to set the focus to a control with
61+ /// a higher priority.
62+ /// </summary>
63+ public TimeSpan FocusEngagementTimeout
64+ {
65+ get => ( TimeSpan ) GetValue ( FocusEngagementTimeoutProperty ) ;
66+ set => SetValue ( FocusEngagementTimeoutProperty , value ) ;
67+ }
68+
5069 /// <inheritdoc/>
5170 protected override void OnAssociatedObjectLoaded ( ) => ApplyFocus ( ) ;
5271
You can’t perform that action at this time.
0 commit comments