Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

#if IS_WINUI
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
#else
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;
#endif

namespace Uno.Toolkit.Samples.Converters
Expand All @@ -24,13 +26,7 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
return value;
}

hex = hex.Replace("#", string.Empty);
byte a = (byte)(System.Convert.ToUInt32(hex.Substring(0, 2), 16));
byte r = (byte)(System.Convert.ToUInt32(hex.Substring(2, 2), 16));
byte g = (byte)(System.Convert.ToUInt32(hex.Substring(4, 2), 16));
byte b = (byte)(System.Convert.ToUInt32(hex.Substring(6, 2), 16));

return Color.FromArgb(a, r, g, b);
return XamlBindingHelper.ConvertValue(typeof(Color), hex);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;

namespace Uno.Toolkit.UI;
Expand All @@ -8,6 +9,7 @@ public class ShadowCollection : ObservableCollection<Shadow>
public bool HasInnerShadow() => this.Any(s => s.IsInner);

public string ToKey(double width, double height, Windows.UI.Color? contentBackground)
=> $"w{width},h{height}" + (contentBackground.HasValue ? $",cb{contentBackground.Value}:" : ":") +
=> string.Create(CultureInfo.InvariantCulture, $"w{width},h{height}") +
(contentBackground.HasValue ? $",cb{contentBackground.Value}:" : ":") +
string.Join("/", this.Select(x => x.ToKey()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class ShadowContainer : ContentControl
nameof(Shadows),
typeof(ShadowCollection),
typeof(ShadowContainer),
new(new ShadowCollection(), OnShadowsChanged));
new(null, OnShadowsChanged));

/// <summary>
/// The collection of shadows that will be displayed under your control.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public partial class ShadowContainer : ContentControl

public ShadowContainer()
{
Shadows = new();

DefaultStyleKey = typeof(ShadowContainer);

_cornerRadius = new CornerRadius(0);
Expand Down