File tree Expand file tree Collapse file tree 2 files changed +9
-17
lines changed
components/Extensions/samples/Dispatcher Expand file tree Collapse file tree 2 files changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -26,20 +26,17 @@ public KeyboardDebounceSample()
26
26
27
27
private void TextBox_TextChanged ( object sender , TextChangedEventArgs e )
28
28
{
29
- var interval = this . GeneratedPropertyMetadata ? . FirstOrDefault ( vm => vm . Name == "Interval" ) ? . Value as double ? ;
30
-
31
- if ( sender is TextBox textBox && interval != null )
29
+ if ( sender is TextBox textBox )
32
30
{
33
31
_debounceTimer . Debounce ( ( ) =>
34
32
{
35
33
ResultText . Text = textBox . Text ;
36
34
} ,
37
35
//// i.e. if another keyboard press comes in within 120ms of the last, we'll wait before we fire off the request
38
- interval : TimeSpan . FromMilliseconds ( interval . Value ) ,
36
+ interval : TimeSpan . FromMilliseconds ( Interval ) ,
39
37
//// If we're blanking out or the first character type, we'll start filtering immediately instead to appear more responsive.
40
38
//// We want to switch back to trailing as the user types more so that we still capture all the input.
41
39
immediate : textBox . Text . Length <= 1 ) ;
42
-
43
40
}
44
41
}
45
42
}
Original file line number Diff line number Diff line change @@ -28,17 +28,12 @@ public MouseDebounceSample()
28
28
29
29
private void Button_Click ( object sender , RoutedEventArgs e )
30
30
{
31
- var interval = this . GeneratedPropertyMetadata ? . FirstOrDefault ( vm => vm . Name == "Interval" ) ? . Value as double ? ;
32
-
33
- if ( interval != null )
34
- {
35
- _debounceTimer . Debounce ( ( ) =>
36
- {
37
- ResultText . Text = $ "You hit the button { ++ _count } times!";
38
- } ,
39
- interval : TimeSpan . FromMilliseconds ( interval . Value ) ,
40
- // By being on the leading edge, we ignore inputs past the first for the duration of the interval
41
- immediate : true ) ;
42
- }
31
+ _debounceTimer . Debounce ( ( ) =>
32
+ {
33
+ ResultText . Text = $ "You hit the button { ++ _count } times!";
34
+ } ,
35
+ interval : TimeSpan . FromMilliseconds ( Interval ) ,
36
+ // By being on the leading edge, we ignore inputs past the first for the duration of the interval
37
+ immediate : true ) ;
43
38
}
44
39
}
You can’t perform that action at this time.
0 commit comments