Skip to content

Commit

Permalink
Implement WinUI ProgressBarHandler native events (#874)
Browse files Browse the repository at this point in the history
* Implement WinUI ProgressBarHandler native events

* Enable nullable in WinUI ProgressBarHandler
  • Loading branch information
jsuarezruiz authored May 7, 2021
1 parent 8c171f7 commit 1063b9c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/WinUI/ProgressBarRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void UpdateProgressColor()
}
}

[PortHandler]
void ProgressBarOnValueChanged(object sender, RangeBaseValueChangedEventArgs rangeBaseValueChangedEventArgs)
{
((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged);
Expand Down
19 changes: 18 additions & 1 deletion src/Core/src/Handlers/ProgressBar/ProgressBarHandler.Windows.cs
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();
}
}
}

0 comments on commit 1063b9c

Please sign in to comment.