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 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
- using Windows . UI . Xaml ;
6
5
using Windows . UI . Xaml . Controls ;
7
6
8
7
namespace Microsoft . Toolkit . Uwp . SampleApp . SamplePages
9
8
{
10
9
/// <summary>
11
10
/// A page that shows how to use the FocusBehavior
12
11
/// </summary>
13
- public sealed partial class FocusBehaviorPage : Page , IXamlRenderListener
12
+ public sealed partial class FocusBehaviorPage : Page
14
13
{
15
14
public FocusBehaviorPage ( ) => InitializeComponent ( ) ;
16
-
17
- public void OnXamlRendered ( FrameworkElement control )
18
- {
19
-
20
- }
21
15
}
22
16
}
Original file line number Diff line number Diff line change @@ -30,7 +30,16 @@ public sealed class FocusBehavior : BehaviorBase<UIElement>
30
30
typeof ( FocusBehavior ) ,
31
31
new PropertyMetadata ( null , OnTargetsPropertyChanged ) ) ;
32
32
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
+
34
43
private DispatcherTimer _timer ;
35
44
36
45
/// <summary>
@@ -47,6 +56,16 @@ public FocusTargetList Targets
47
56
set => SetValue ( TargetsProperty , value ) ;
48
57
}
49
58
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
+
50
69
/// <inheritdoc/>
51
70
protected override void OnAssociatedObjectLoaded ( ) => ApplyFocus ( ) ;
52
71
You can’t perform that action at this time.
0 commit comments