Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"uno.check": {
"version": "1.20.2",
"version": "1.27.4",
"commands": [
"uno-check"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:

- name: Run SourceGenerators tests
id: test-generator
run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net6.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"
run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net8.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"

- name: Run component tests against ${{ matrix.multitarget }}
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
Expand Down
3 changes: 3 additions & 0 deletions components/Behaviors/src/Headers/FadeHeaderBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ protected override bool AssignAnimation()
return false;
}

/// <summary>
/// Stops the animation.
/// </summary>
protected override void StopAnimation()
{
if (_headerVisual != null)
Expand Down
15 changes: 15 additions & 0 deletions components/Behaviors/src/Headers/HeaderBehaviorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,24 @@ public abstract class HeaderBehaviorBase : BehaviorBase<FrameworkElement>
// From Doc: https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.canvas.zindex
private const int CanvasZIndexMax = 1_000_000;

/// <summary>
/// The ScrollViewer associated with the ListViewBase control.
/// </summary>
protected ScrollViewer? _scrollViewer;

/// <summary>
/// The CompositionPropertySet associated with the ScrollViewer.
/// </summary>
protected CompositionPropertySet? _scrollProperties;

/// <summary>
/// The CompositionPropertySet associated with the animation.
/// </summary>
protected CompositionPropertySet? _animationProperties;

/// <summary>
/// The Visual associated with the header element.
/// </summary>
protected Visual? _headerVisual;

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions components/Primitives/src/SwitchPresenter/SwitchConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ public SwitchConverter()
SwitchCases = new CaseCollection();
}

/// <summary>
/// Converts the provided value based on the defined cases.
/// </summary>
public object Convert(object value, Type targetType, object parameter, string language)
{
var result = SwitchCases.EvaluateCases(value, TargetType ?? targetType);

return result?.Content!;
}

/// <summary>
/// Not implemented.
/// </summary>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
Expand Down
1 change: 1 addition & 0 deletions components/Primitives/src/SwitchPresenter/SwitchHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ internal static partial class SwitchHelpers
/// </summary>
/// <param name="compare">Our main value in our SwitchPresenter.</param>
/// <param name="value">The value from the case to compare to.</param>
/// <param name="targetType">The desired type of the result for automatic conversion.</param>
/// <returns>true if the two values are equal</returns>
internal static bool CompareValues(object compare, object value, Type targetType)
{
Expand Down
12 changes: 12 additions & 0 deletions components/Segmented/src/EqualPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@

namespace CommunityToolkit.WinUI.Controls;

/// <summary>
/// A panel that arranges its children in equal columns.
/// </summary>
public partial class EqualPanel : Panel
{
private double _maxItemWidth = 0;
private double _maxItemHeight = 0;
private int _visibleItemsCount = 0;

/// <summary>
/// Gets or sets the spacing between items.
/// </summary>
public double Spacing
{
get { return (double)GetValue(SpacingProperty); }
Expand All @@ -27,11 +34,15 @@ public double Spacing
typeof(EqualPanel),
new PropertyMetadata(default(double), OnSpacingChanged));

/// <summary>
/// Creates a new instance of the <see cref="EqualPanel"/> class.
/// </summary>
public EqualPanel()
{
RegisterPropertyChangedCallback(HorizontalAlignmentProperty, OnHorizontalAlignmentChanged);
}

/// <inheritdoc/>
protected override Size MeasureOverride(Size availableSize)
{
_maxItemWidth = 0;
Expand Down Expand Up @@ -69,6 +80,7 @@ protected override Size MeasureOverride(Size availableSize)
}
}

/// <inheritdoc/>
protected override Size ArrangeOverride(Size finalSize)
{
double x = 0;
Expand Down
5 changes: 5 additions & 0 deletions components/Segmented/src/Helpers/SegmentedMarginConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace CommunityToolkit.WinUI.Controls;

/// <summary>
/// A converter that returns a margin based on the position of the item in a segmented control.
/// </summary>
public partial class SegmentedMarginConverter : DependencyObject, IValueConverter
{
/// <summary>
Expand Down Expand Up @@ -51,6 +54,7 @@ public Thickness RightItemMargin
set { SetValue(RightItemMarginProperty, value); }
}

/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, string language)
{
var segmentedItem = value as SegmentedItem;
Expand All @@ -72,6 +76,7 @@ public object Convert(object value, Type targetType, object parameter, string la
}
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value;
Expand Down
19 changes: 19 additions & 0 deletions components/Segmented/src/Segmented/Segmented.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,38 @@

namespace CommunityToolkit.WinUI.Controls;

/// <summary>
/// A control that displays a set of items that can be selected by the user.
/// </summary>
public partial class Segmented : ListViewBase
{
private int _internalSelectedIndex = -1;
private bool _hasLoaded = false;

/// <summary>
/// Creates a new instance of <see cref="Segmented"/>.
/// </summary>
public Segmented()
{
this.DefaultStyleKey = typeof(Segmented);

RegisterPropertyChangedCallback(SelectedIndexProperty, OnSelectedIndexChanged);
}

/// <summary>
/// Get the container for the item.
/// </summary>
protected override DependencyObject GetContainerForItemOverride() => new SegmentedItem();

/// <summary>
/// Check if the item is its own container.
/// </summary>
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is SegmentedItem;
}

/// <inheritdoc/>
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
Expand All @@ -37,6 +50,9 @@ protected override void OnApplyTemplate()
PreviewKeyDown += Segmented_PreviewKeyDown;
}

/// <summary>
/// Prepare the container for the item.
/// </summary>
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
base.PrepareContainerForItemOverride(element, item);
Expand All @@ -63,6 +79,9 @@ private void SegmentedItem_Loaded(object sender, RoutedEventArgs e)
}
}

/// <summary>
/// Handles the ItemsChanged event
/// </summary>
protected override void OnItemsChanged(object e)
{
base.OnItemsChanged(e);
Expand Down
13 changes: 13 additions & 0 deletions components/Segmented/src/SegmentedItem/SegmentedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,35 @@

namespace CommunityToolkit.WinUI.Controls;

/// <summary>
/// Represents an item in a <see cref="Segmented"/> control.
/// </summary>
[ContentProperty(Name = nameof(Content))]
public partial class SegmentedItem : ListViewItem
{
internal const string IconLeftState = "IconLeft";
internal const string IconOnlyState = "IconOnly";
internal const string ContentOnlyState = "ContentOnly";

/// <summary>
/// Creates a new instance of <see cref="SegmentedItem"/>.
/// </summary>
public SegmentedItem()
{
this.DefaultStyleKey = typeof(SegmentedItem);
}

/// <inheritdoc/>
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
OnIconChanged();
ContentChanged();
}

/// <summary>
/// Handles changes to the Content property.
/// </summary>
protected override void OnContentChanged(object oldContent, object newContent)
{
base.OnContentChanged(oldContent, newContent);
Expand All @@ -41,6 +51,9 @@ private void ContentChanged()
}
}

/// <summary>
/// Handles changes to the Icon property.
/// </summary>
protected virtual void OnIconPropertyChanged(IconElement oldValue, IconElement newValue)
{
OnIconChanged();
Expand Down
16 changes: 15 additions & 1 deletion components/SettingsControls/src/Helpers/StyleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,38 @@

namespace CommunityToolkit.WinUI.Controls;

// Adapted from https://github.com/rudyhuyn/XamlPlus
/// <summary>
/// Helper class for setting a ResourceDictionary on a Style.
/// </summary>
/// <remarks>
/// Adapted from https://github.com/rudyhuyn/XamlPlus
/// </remarks>
public static partial class StyleExtensions
{
// Used to distinct normal ResourceDictionary and the one we add.
private sealed partial class StyleExtensionResourceDictionary : ResourceDictionary
{
}

/// <summary>
/// Get a ResourceDictionary from a Style.
/// </summary>
public static ResourceDictionary GetResources(Style obj)
{
return (ResourceDictionary)obj.GetValue(ResourcesProperty);
}

/// <summary>
/// Set the <see cref="ResourcesProperty"/> on a Style to a ResourceDictionary value.
/// </summary>
public static void SetResources(Style obj, ResourceDictionary value)
{
obj.SetValue(ResourcesProperty, value);
}

/// <summary>
/// Attached property to set a Style to a ResourceDictionary value.
/// </summary>
public static readonly DependencyProperty ResourcesProperty =
DependencyProperty.RegisterAttached("Resources", typeof(ResourceDictionary), typeof(StyleExtensions), new PropertyMetadata(null, ResourcesChanged));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,41 +152,62 @@ public bool IsActionIconVisible
set => SetValue(IsActionIconVisibleProperty, value);
}

/// <summary>
/// Called when the IsClickEnabled property changes.
/// </summary>
protected virtual void OnIsClickEnabledPropertyChanged(bool oldValue, bool newValue)
{
OnIsClickEnabledChanged();
}

/// <summary>
/// Called when the HeaderIcon property changes.
/// </summary>
protected virtual void OnHeaderIconPropertyChanged(IconElement oldValue, IconElement newValue)
{
OnHeaderIconChanged();
}

/// <summary>
/// Called when the Header property changes.
/// </summary>
protected virtual void OnHeaderPropertyChanged(object oldValue, object newValue)
{
OnHeaderChanged();
}

/// <summary>
/// Called when the Description property changes.
/// </summary>
protected virtual void OnDescriptionPropertyChanged(object oldValue, object newValue)
{
OnDescriptionChanged();
}

/// <summary>
/// Called when the IsActionIconVisible property changes.
/// </summary>
protected virtual void OnIsActionIconVisiblePropertyChanged(bool oldValue, bool newValue)
{
OnActionIconChanged();
}
}

/// <summary>
/// The alignment of Content.
/// </summary>
public enum ContentAlignment
{
/// <summary>
/// The Content is aligned to the right. Default state.
/// </summary>
Right,

/// <summary>
/// The Content is left-aligned while the Header, HeaderIcon and Description are collapsed. This is commonly used for Content types such as CheckBoxes, RadioButtons and custom layouts.
/// </summary>
Left,

/// <summary>
/// The Content is vertically aligned.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions components/SettingsControls/src/SettingsCard/SettingsCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,18 @@ private void Control_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
}
}

/// <summary>
/// Handles the PointerEntered event.
/// </summary>
public void Control_PointerEntered(object sender, PointerRoutedEventArgs e)
{
base.OnPointerEntered(e);
VisualStateManager.GoToState(this, PointerOverState, true);
}

/// <summary>
/// Handles the PointerExited event.
/// </summary>
public void Control_PointerExited(object sender, PointerRoutedEventArgs e)
{
base.OnPointerExited(e);
Expand All @@ -172,6 +178,9 @@ private void Control_PointerCanceled(object sender, PointerRoutedEventArgs e)
VisualStateManager.GoToState(this, NormalState, true);
}

/// <summary>
/// Handles the PointerPressed event.
/// </summary>
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
// e.Handled = true;
Expand All @@ -182,6 +191,9 @@ protected override void OnPointerPressed(PointerRoutedEventArgs e)
}
}

/// <summary>
/// Handles the PointerReleased event.
/// </summary>
protected override void OnPointerReleased(PointerRoutedEventArgs e)
{
if (IsClickEnabled)
Expand Down
Loading
Loading