-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement WinUI ProgressBarHandler native events (#874)
* Implement WinUI ProgressBarHandler native events * Enable nullable in WinUI ProgressBarHandler
- Loading branch information
1 parent
8c171f7
commit 1063b9c
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
src/Core/src/Handlers/ProgressBar/ProgressBarHandler.Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
#nullable enable | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
|
||
namespace Microsoft.Maui.Handlers | ||
{ | ||
public partial class ProgressBarHandler : ViewHandler<IProgress, ProgressBar> | ||
{ | ||
protected override ProgressBar CreateNativeView() => new ProgressBar { Minimum = 0, Maximum = 1 }; | ||
|
||
protected override void ConnectHandler(ProgressBar nativeView) | ||
{ | ||
nativeView.ValueChanged += OnProgressBarValueChanged; | ||
} | ||
|
||
protected override void DisconnectHandler(ProgressBar nativeView) | ||
{ | ||
nativeView.ValueChanged -= OnProgressBarValueChanged; | ||
} | ||
|
||
public static void MapProgress(ProgressBarHandler handler, IProgress progress) | ||
{ | ||
handler.NativeView?.UpdateProgress(progress); | ||
} | ||
|
||
void OnProgressBarValueChanged(object? sender, RangeBaseValueChangedEventArgs rangeBaseValueChangedEventArgs) | ||
{ | ||
VirtualView?.InvalidateMeasure(); | ||
} | ||
} | ||
} |