Skip to content

Commit 14b2477

Browse files
authored
Merge branch 'main' into Segment/Hover-CornerRadius
2 parents d1e1038 + fae8940 commit 14b2477

7 files changed

Lines changed: 66 additions & 20 deletions

File tree

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"xamlstyler.console": {
12-
"version": "3.2206.4",
12+
"version": "3.2501.8",
1313
"commands": [
1414
"xstyler"
1515
]

.github/workflows/build.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,10 @@ env:
3232
jobs:
3333
# This workflow contains a single job called "Xaml-Style-Check"
3434
Xaml-Style-Check:
35-
runs-on: windows-latest
35+
runs-on: windows-2022
3636

3737
# Steps represent a sequence of tasks that will be executed as part of the job
3838
steps:
39-
# .NET 6 SDK is required for xamlstyler.console to run.
40-
- name: Install .NET SDK v6
41-
uses: actions/setup-dotnet@v4
42-
with:
43-
dotnet-version: 6.0.x
44-
4539
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
4640
uses: actions/setup-dotnet@v4
4741
with:
@@ -63,7 +57,7 @@ jobs:
6357
# Build both Uno.UI/WinUI2/UWP and Uno.WinUI/WinUI3/WindowsAppSDK versions of our packages using a matrix
6458
build:
6559
needs: [Xaml-Style-Check]
66-
runs-on: windows-latest-large
60+
runs-on: windows-2022
6761

6862
# See https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
6963
strategy:
@@ -208,7 +202,7 @@ jobs:
208202
dotnet-dump analyze ${{ steps.detect-dump.outputs.DUMP_FILE }} -c "clrstack" -c "pe -lines" -c "exit"
209203
210204
package:
211-
runs-on: windows-latest-large
205+
runs-on: windows-2022
212206
needs: [build]
213207
strategy:
214208
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
@@ -319,7 +313,7 @@ jobs:
319313
sign:
320314
needs: [package]
321315
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
322-
runs-on: windows-latest
316+
runs-on: windows-2022
323317
permissions:
324318
id-token: write # Required for requesting the JWT
325319

components/ColorPicker/src/ColorPicker.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace CommunityToolkit.WinUI.Controls;
4242
[TemplatePart(Name = nameof(ColorPicker.CheckeredBackground9Border), Type = typeof(Border))]
4343
[TemplatePart(Name = nameof(ColorPicker.CheckeredBackground10Border), Type = typeof(Border))]
4444
[TemplatePart(Name = nameof(ColorPicker.ColorPanelSelector), Type = typeof(Segmented))]
45+
[TemplatePart(Name = nameof(ColorPicker.ContentContainer), Type = typeof(SwitchPresenter))]
4546
[TemplatePart(Name = nameof(ColorPicker.ColorSpectrumControl), Type = typeof(ColorSpectrum))]
4647
[TemplatePart(Name = nameof(ColorPicker.ColorSpectrumAlphaSlider), Type = typeof(ColorPickerSlider))]
4748
[TemplatePart(Name = nameof(ColorPicker.ColorSpectrumThirdDimensionSlider), Type = typeof(ColorPickerSlider))]
@@ -74,7 +75,9 @@ public partial class ColorPicker : Microsoft.UI.Xaml.Controls.ColorPicker
7475
private Color? updatedRgbColor = null;
7576
private DispatcherQueueTimer? dispatcherQueueTimer = null;
7677

77-
private Segmented ColorPanelSelector;
78+
private Segmented ColorPanelSelector;
79+
private SwitchPresenter ContentContainer;
80+
7881
private ColorSpectrum ColorSpectrumControl;
7982
private ColorPickerSlider ColorSpectrumAlphaSlider;
8083
private ColorPickerSlider ColorSpectrumThirdDimensionSlider;
@@ -177,6 +180,7 @@ protected override void OnApplyTemplate()
177180
this.ConnectEvents(false);
178181

179182
this.ColorPanelSelector = (Segmented)GetTemplateChild(nameof(ColorPanelSelector));
183+
this.ContentContainer = (SwitchPresenter)GetTemplateChild(nameof(ContentContainer));
180184

181185
this.ColorSpectrumControl = (ColorSpectrum)GetTemplateChild(nameof(ColorSpectrumControl));
182186
this.ColorSpectrumAlphaSlider = (ColorPickerSlider)this.GetTemplateChild(nameof(ColorSpectrumAlphaSlider));
@@ -255,6 +259,8 @@ private void ConnectEvents(bool connected)
255259
this.eventsConnected == false)
256260
{
257261
// Add all events
262+
if (this.ColorPanelSelector != null) { this.ColorPanelSelector.SelectionChanged += this.ColorPanelSelector_SelectionChanged; }
263+
258264
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.ColorChanged += ColorSpectrum_ColorChanged; }
259265
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.GotFocus += ColorSpectrum_GotFocus; }
260266
if (this.HexInputTextBox != null) { this.HexInputTextBox.KeyDown += HexInputTextBox_KeyDown; }
@@ -299,6 +305,8 @@ private void ConnectEvents(bool connected)
299305
this.eventsConnected == true)
300306
{
301307
// Remove all events
308+
if (this.ColorPanelSelector != null) { this.ColorPanelSelector.SelectionChanged -= this.ColorPanelSelector_SelectionChanged; }
309+
302310
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.ColorChanged -= ColorSpectrum_ColorChanged; }
303311
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.GotFocus -= ColorSpectrum_GotFocus; }
304312
if (this.HexInputTextBox != null) { this.HexInputTextBox.KeyDown -= HexInputTextBox_KeyDown; }
@@ -1186,6 +1194,22 @@ private void CustomPaletteColors_CollectionChanged(object? sender, NotifyCollect
11861194
return;
11871195
}
11881196

1197+
/// <summary>
1198+
/// Event handler for when the color panel selector selection changes.
1199+
/// We are setting the value here instead of ElementName binding as a workaround for AoT issues.
1200+
/// (See https://github.com/microsoft/microsoft-ui-xaml/issues/10214)
1201+
/// </summary>
1202+
private void ColorPanelSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
1203+
{
1204+
if (this.ContentContainer is null ||
1205+
(sender as Segmented)?.SelectedItem is not FrameworkElement selectedItem)
1206+
{
1207+
return;
1208+
}
1209+
1210+
this.ContentContainer.Value = selectedItem.Name;
1211+
}
1212+
11891213
/// <summary>
11901214
/// Event handler for when the color spectrum color is changed.
11911215
/// This occurs when the user presses on the spectrum to select a new color.

components/ColorPicker/src/ColorPicker.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@
237237
</controls:Segmented>
238238

239239
<controls:SwitchPresenter x:Name="ContentContainer"
240-
Grid.Row="2"
241-
Value="{Binding ElementName=ColorPanelSelector, Path=SelectedItem.Name}">
240+
Grid.Row="2">
242241
<controls:Case Value="SpectrumItem">
243242
<Grid HorizontalAlignment="Stretch"
244243
animations:Implicit.HideAnimations="{StaticResource HideTransitions}"

components/SettingsControls/src/SettingsCard/SettingsCard.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System.ComponentModel.Design;
6-
75
namespace CommunityToolkit.WinUI.Controls;
86

97
/// <summary>
@@ -21,6 +19,9 @@ namespace CommunityToolkit.WinUI.Controls;
2119
[TemplateVisualState(Name = PressedState, GroupName = CommonStates)]
2220
[TemplateVisualState(Name = DisabledState, GroupName = CommonStates)]
2321

22+
[TemplateVisualState(Name = BitmapHeaderIconEnabledState, GroupName = BitmapHeaderIconStates)]
23+
[TemplateVisualState(Name = BitmapHeaderIconDisabledState, GroupName = BitmapHeaderIconStates)]
24+
2425
[TemplateVisualState(Name = RightState, GroupName = ContentAlignmentStates)]
2526
[TemplateVisualState(Name = RightWrappedState, GroupName = ContentAlignmentStates)]
2627
[TemplateVisualState(Name = RightWrappedNoIconState, GroupName = ContentAlignmentStates)]
@@ -38,6 +39,10 @@ public partial class SettingsCard : ButtonBase
3839
internal const string PressedState = "Pressed";
3940
internal const string DisabledState = "Disabled";
4041

42+
internal const string BitmapHeaderIconStates = "BitmapHeaderIconStates";
43+
internal const string BitmapHeaderIconEnabledState = "BitmapHeaderIconEnabled";
44+
internal const string BitmapHeaderIconDisabledState = "BitmapHeaderIconDisabled";
45+
4146
internal const string ContentAlignmentStates = "ContentAlignmentStates";
4247
internal const string RightState = "Right";
4348
internal const string RightWrappedState = "RightWrapped";
@@ -76,7 +81,7 @@ protected override void OnApplyTemplate()
7681
CheckInitialVisualState();
7782
SetAccessibleContentName();
7883
RegisterPropertyChangedCallback(ContentProperty, OnContentChanged);
79-
IsEnabledChanged += OnIsEnabledChanged;
84+
IsEnabledChanged += OnIsEnabledChanged;
8085
}
8186

8287
private void CheckInitialVisualState()
@@ -89,6 +94,8 @@ private void CheckInitialVisualState()
8994
CheckVerticalSpacingState(contentAlignmentStatesGroup.CurrentState);
9095
contentAlignmentStatesGroup.CurrentStateChanged += this.ContentAlignmentStates_Changed;
9196
}
97+
98+
CheckHeaderIconState();
9299
}
93100

94101
// We automatically set the AutomationProperties.Name of the Content if not configured.
@@ -183,7 +190,6 @@ private void Control_PointerCanceled(object sender, PointerRoutedEventArgs e)
183190
/// </summary>
184191
protected override void OnPointerPressed(PointerRoutedEventArgs e)
185192
{
186-
// e.Handled = true;
187193
if (IsClickEnabled)
188194
{
189195
base.OnPointerPressed(e);
@@ -228,6 +234,18 @@ private void OnIsClickEnabledChanged()
228234
private void OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
229235
{
230236
VisualStateManager.GoToState(this, IsEnabled ? NormalState : DisabledState, true);
237+
238+
CheckHeaderIconState();
239+
}
240+
241+
private void CheckHeaderIconState()
242+
{
243+
// The Disabled visual state will only set the right Foreground brush, but for images we need to lower the opacity so it looks disabled.
244+
245+
if (HeaderIcon is BitmapIcon)
246+
{
247+
VisualStateManager.GoToState(this, IsEnabled ? BitmapHeaderIconEnabledState : BitmapHeaderIconDisabledState, true);
248+
}
231249
}
232250

233251
private void OnActionIconChanged()
@@ -240,7 +258,7 @@ private void OnActionIconChanged()
240258
}
241259
else
242260
{
243-
actionIconPresenter.Visibility =Visibility.Collapsed;
261+
actionIconPresenter.Visibility = Visibility.Collapsed;
244262
}
245263
}
246264
}

components/SettingsControls/src/SettingsCard/SettingsCard.xaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<x:Double x:Key="SettingsCardVerticalHeaderContentSpacing">8</x:Double>
110110
<x:Double x:Key="SettingsCardWrapThreshold">476</x:Double>
111111
<x:Double x:Key="SettingsCardWrapNoIconThreshold">286</x:Double>
112+
<x:Double x:Key="SettingsCardBitmapIconDisabledOpacity">0.4</x:Double>
112113

113114
<Style BasedOn="{StaticResource DefaultSettingsCardStyle}"
114115
TargetType="local:SettingsCard" />
@@ -294,6 +295,16 @@
294295
</VisualState>
295296
</VisualStateGroup>
296297

298+
<!-- These states are only relevant if a BitmapIcon is used as HeaderIcon or ActionIcon. -->
299+
<VisualStateGroup x:Name="BitmapHeaderIconStates">
300+
<VisualState x:Name="BitmapHeaderIconEnabled" />
301+
<VisualState x:Name="BitmapHeaderIconDisabled">
302+
<VisualState.Setters>
303+
<Setter Target="PART_HeaderIconPresenterHolder.Opacity" Value="{StaticResource SettingsCardBitmapIconDisabledOpacity}" />
304+
</VisualState.Setters>
305+
</VisualState>
306+
</VisualStateGroup>
307+
297308
<VisualStateGroup x:Name="ContentAlignmentStates">
298309
<!-- Default -->
299310
<VisualState x:Name="Right" />

tooling

0 commit comments

Comments
 (0)