Skip to content

Commit 8f16836

Browse files
committed
timeout is now a DP and removed unused method
1 parent 516914f commit 8f16836

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/FocusBehavior/FocusBehaviorPage.xaml.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@
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;
65
using Windows.UI.Xaml.Controls;
76

87
namespace 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
}

Microsoft.Toolkit.Uwp.UI/Behaviors/FocusBehavior.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)