Skip to content

Commit

Permalink
chore: Fixing windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Jan 22, 2024
1 parent 86d4c6f commit 1aee150
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/Uno.Toolkit.UI/Behaviors/ProgressExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.System;
using Microsoft.Extensions.Logging;
using Uno.Extensions;
using Uno.Logging;
using System.Diagnostics.CodeAnalysis;
using Uno.UI.Extensions;


#if IS_WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -20,10 +10,10 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using ItemsRepeater = Microsoft.UI.Xaml.Controls.ItemsRepeater;
#endif


namespace Uno.Toolkit.UI
{
public static class ProgressExtensions
Expand All @@ -39,14 +29,14 @@ private static void IsActiveChanged(DependencyObject d, DependencyPropertyChange
{
if (d is FrameworkElement element &&
e.NewValue is bool isActive)
{
{
foreach (var item in element.EnumerateDescendants())
{
if(item is ProgressRing progressRing)
if (item is ProgressRing progressRing)
{
progressRing.IsActive = isActive;
}
else if(item is ProgressBar progressBar)
else if (item is ProgressBar progressBar)
{
progressBar.IsIndeterminate = isActive;
}
Expand All @@ -63,5 +53,26 @@ public static bool GetIsActive(this FrameworkElement element)
{
return (bool)element.GetValue(IsActiveProperty);
}

#if WINDOWS_UWP || WINDOWS
// Copied from Uno.UI.Extensions.ViewExtensions for Windows targets
private static IEnumerable<DependencyObject> EnumerateDescendants(this DependencyObject reference)
{
foreach (DependencyObject child in reference.EnumerateChildren())
{
yield return child;
foreach (DependencyObject item in child.EnumerateDescendants())
{
yield return item;
}
}
}

private static IEnumerable<DependencyObject> EnumerateChildren(this DependencyObject reference)
{
return from x in Enumerable.Range(0, VisualTreeHelper.GetChildrenCount(reference))
select VisualTreeHelper.GetChild(reference, x);
}
#endif
}
}

0 comments on commit 1aee150

Please sign in to comment.