Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 90c983d

Browse files
committedJan 30, 2025·
feat: Update AppBarSeparator to winui3/release/1.6.4
1 parent 0ca970c commit 90c983d

5 files changed

+155
-149
lines changed
 

‎src/Uno.UI/UI/Xaml/Controls/AppBar/AppBarSeparator.Partial.cs

-67
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,92 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Microsoft.UI.Xaml;
5-
using Microsoft.UI.Xaml.Controls;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
// MUX Reference dxaml\xcp\dxaml\lib\AppBarSeparator_Partial.cpp, tag winui3/release/1.6.4, commit 262a901e09
64

7-
namespace Microsoft.UI.Xaml.Controls
5+
namespace Microsoft.UI.Xaml.Controls;
6+
7+
partial class AppBarSeparator
88
{
9-
partial class AppBarSeparator
9+
/// <summary>
10+
/// Gets or sets the order in which this item is moved to the CommandBar overflow menu.
11+
/// </summary>
12+
public int DynamicOverflowOrder
1013
{
11-
#region IsCompat
12-
13-
public bool IsCompact
14-
{
15-
get => (bool)this.GetValue(IsCompactProperty);
16-
set => this.SetValue(IsCompactProperty, value);
17-
}
14+
get => (int)GetValue(DynamicOverflowOrderProperty);
15+
set => SetValue(DynamicOverflowOrderProperty, value);
16+
}
1817

19-
public static DependencyProperty IsCompactProperty { get; } =
18+
/// <summary>
19+
/// Identifies the DynamicOverflowOrder dependency property.
20+
/// </summary>
21+
public static DependencyProperty DynamicOverflowOrderProperty { get; } =
2022
DependencyProperty.Register(
21-
"IsCompact",
22-
typeof(bool),
23+
nameof(DynamicOverflowOrder),
24+
typeof(int),
2325
typeof(AppBarSeparator),
24-
new FrameworkPropertyMetadata(default(bool))
25-
);
26-
27-
#endregion
28-
29-
#region DynamicOverflowOrder
30-
31-
public int DynamicOverflowOrder
32-
{
33-
get => (int)this.GetValue(DynamicOverflowOrderProperty);
34-
set => this.SetValue(DynamicOverflowOrderProperty, value);
35-
}
26+
new FrameworkPropertyMetadata(default(int)));
3627

37-
public static DependencyProperty DynamicOverflowOrderProperty { get; } =
38-
DependencyProperty.Register(
39-
"DynamicOverflowOrder",
40-
typeof(int),
41-
typeof(AppBarSeparator),
42-
new FrameworkPropertyMetadata(default(int))
43-
);
44-
45-
#endregion
46-
47-
#region IsInOverflow
48-
49-
public bool IsInOverflow
50-
{
51-
get => CommandBar.IsCommandBarElementInOverflow(this);
52-
internal set => this.SetValue(IsInOverflowProperty, value);
53-
}
54-
55-
bool ICommandBarElement3.IsInOverflow
56-
{
57-
get => IsInOverflow;
58-
set => IsInOverflow = value;
59-
}
60-
61-
public static DependencyProperty IsInOverflowProperty { get; } =
62-
DependencyProperty.Register(
63-
"IsInOverflow",
64-
typeof(bool),
65-
typeof(AppBarSeparator),
66-
new FrameworkPropertyMetadata(default(bool))
67-
);
68-
69-
#endregion
28+
/// <summary>
29+
/// Gets or sets a value that indicates whether the separator is shown with reduced padding.
30+
/// </summary>
31+
public bool IsCompact
32+
{
33+
get => (bool)GetValue(IsCompactProperty);
34+
set => SetValue(IsCompactProperty, value);
35+
}
7036

71-
#region UseOverflowStyle
37+
/// <summary>
38+
/// Identifies the IsCompact dependency property.
39+
/// </summary>
40+
public static DependencyProperty IsCompactProperty { get; } =
41+
DependencyProperty.Register(
42+
nameof(IsCompact),
43+
typeof(bool),
44+
typeof(AppBarSeparator),
45+
new FrameworkPropertyMetadata(default(bool))
46+
);
47+
48+
/// <summary>
49+
/// Gets a value that indicates whether this item is in the overflow menu.
50+
/// </summary>
51+
public bool IsInOverflow
52+
{
53+
get => CommandBar.IsCommandBarElementInOverflow(this);
54+
private set => SetValue(IsInOverflowProperty, value);
55+
}
7256

73-
internal bool UseOverflowStyle
74-
{
75-
get => (bool)this.GetValue(UseOverflowStyleProperty);
76-
set => this.SetValue(UseOverflowStyleProperty, value);
77-
}
57+
/// <summary>
58+
/// Identifies the IsInOverflow dependency property.
59+
/// </summary>
60+
public static DependencyProperty IsInOverflowProperty { get; } =
61+
DependencyProperty.Register(
62+
nameof(IsInOverflow),
63+
typeof(bool),
64+
typeof(AppBarSeparator),
65+
new FrameworkPropertyMetadata(default(bool)));
7866

79-
bool ICommandBarOverflowElement.UseOverflowStyle
80-
{
81-
get => UseOverflowStyle;
82-
set => UseOverflowStyle = value;
83-
}
67+
bool ICommandBarElement3.IsInOverflow
68+
{
69+
get => IsInOverflow;
70+
set => IsInOverflow = value;
71+
}
8472

85-
internal static DependencyProperty UseOverflowStyleProperty { get; } =
86-
DependencyProperty.Register(
87-
nameof(UseOverflowStyle),
88-
typeof(bool),
89-
typeof(AppBarSeparator),
90-
new FrameworkPropertyMetadata(default(bool))
91-
);
73+
internal bool UseOverflowStyle
74+
{
75+
get => (bool)GetValue(UseOverflowStyleProperty);
76+
set => SetValue(UseOverflowStyleProperty, value);
77+
}
9278

93-
#endregion
79+
bool ICommandBarOverflowElement.UseOverflowStyle
80+
{
81+
get => UseOverflowStyle;
82+
set => UseOverflowStyle = value;
9483
}
84+
85+
internal static DependencyProperty UseOverflowStyleProperty { get; } =
86+
DependencyProperty.Register(
87+
nameof(UseOverflowStyle),
88+
typeof(bool),
89+
typeof(AppBarSeparator),
90+
new FrameworkPropertyMetadata(default(bool))
91+
);
9592
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Microsoft.UI.Xaml.Controls;
2+
3+
/// <summary>
4+
/// Represents a line that separates items in an AppBar or CommandBar.
5+
/// </summary>
6+
public partial class AppBarSeparator : Control, ICommandBarElement, ICommandBarElement2, ICommandBarElement3, ICommandBarOverflowElement
7+
{
8+
/// <summary>
9+
/// Initializes a new instance of the AppBarSeparator class.
10+
/// </summary>
11+
public AppBarSeparator()
12+
{
13+
DefaultStyleKey = typeof(AppBarSeparator);
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
// MUX Reference dxaml\xcp\dxaml\lib\AppBarSeparator_Partial.cpp, tag winui3/release/1.6.4, commit 262a901e09
4+
5+
#nullable enable
6+
7+
namespace Microsoft.UI.Xaml.Controls;
8+
9+
public partial class AppBarSeparator : Control, ICommandBarElement, ICommandBarElement2, ICommandBarElement3, ICommandBarOverflowElement
10+
{
11+
internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
12+
{
13+
base.OnPropertyChanged2(args);
14+
15+
if (args.Property == IsCompactProperty ||
16+
args.Property == UseOverflowStyleProperty)
17+
{
18+
UpdateVisualState();
19+
}
20+
}
21+
22+
// After template is applied, set the initial view state
23+
// (FullSize or Compact) based on the value of our
24+
// IsCompact property
25+
protected override void OnApplyTemplate()
26+
{
27+
base.OnApplyTemplate();
28+
29+
UpdateVisualState();
30+
}
31+
32+
// Sets the visual state to "Compact" or "FullSize" based on the value
33+
// of our IsCompact property
34+
private protected override void ChangeVisualState(bool useTransitions)
35+
{
36+
base.ChangeVisualState(useTransitions);
37+
38+
var useOverflowStyle = UseOverflowStyle;
39+
var isCompact = IsCompact;
40+
41+
if (useOverflowStyle)
42+
{
43+
GoToState(useTransitions, "Overflow");
44+
}
45+
else if (isCompact)
46+
{
47+
GoToState(useTransitions, "Compact");
48+
}
49+
else
50+
{
51+
GoToState(useTransitions, "FullSize");
52+
}
53+
}
54+
55+
private protected override void OnVisibilityChanged() =>
56+
CommandBar.OnCommandBarElementVisibilityChanged(this);
57+
}

‎src/Uno.UI/UI/Xaml/Controls/AppBar/AppBarToggleButton.partial.mux.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ namespace Microsoft.UI.Xaml.Controls;
2727

2828
public partial class AppBarToggleButton : ToggleButton, ICommandBarElement, ICommandBarElement2, ICommandBarElement3, ICommandBarOverflowElement, ICommandBarLabeledElement, IAppBarButtonHelpersProvider
2929
{
30-
3130
DependencyProperty IAppBarButtonHelpersProvider.GetIsCompactDependencyProperty() => IsCompactProperty;
31+
3232
DependencyProperty IAppBarButtonHelpersProvider.GetUseOverflowStyleDependencyProperty() => UseOverflowStyleProperty;
33+
3334
DependencyProperty IAppBarButtonHelpersProvider.GetLabelPositionDependencyProperty() => LabelPositionProperty;
35+
3436
DependencyProperty IAppBarButtonHelpersProvider.GetLabelDependencyProperty() => LabelProperty;
37+
3538
DependencyProperty IAppBarButtonHelpersProvider.GetIconDependencyProperty() => IconProperty;
39+
3640
DependencyProperty IAppBarButtonHelpersProvider.GetKeyboardAcceleratorTextDependencyProperty() => KeyboardAcceleratorTextOverrideProperty;
3741

3842
/// <summary>

0 commit comments

Comments
 (0)
Please sign in to comment.