Skip to content

Commit 1fd605d

Browse files
committed
fix layout helpers that take CommandBarElement children
1 parent 2108c8c commit 1fd605d

File tree

16 files changed

+279
-280
lines changed

16 files changed

+279
-280
lines changed

src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/WinUICsMarkupExamples.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
2626
<PackageReference Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
2727
<PackageReference Include="Uno.WinUI" Version="4.9.20" />
28-
<PackageReference Include="CSharpMarkup.WinUI" Version="2.1.14" />
28+
<PackageReference Include="CSharpMarkup.WinUI" Version="2.2.21" />
2929
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
3030
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="All" />
3131
</ItemGroup>

src/CSharpMarkup.WinUI/CSharpMarkup.WinUI.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2222
<RepositoryType>git</RepositoryType>
2323
<Product>$(AssemblyName) ($(TargetFramework))</Product>
24-
<Version>2.2.12</Version>
24+
<Version>2.2.21</Version>
2525
<NeutralLanguage>en</NeutralLanguage>
2626

2727
<NoWarn>CS1591;CS1573;Uno0001</NoWarn>

src/CSharpMarkup.WinUI/CommandBarElement.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22

33
namespace CSharpMarkup.WinUI;
44

5-
public class CommandBarElement : Xaml.Controls.ICommandBarElement
5+
public class CommandBarElement : IAnyUI<Xaml.Controls.ICommandBarElement>
66
{
7-
readonly Xaml.Controls.ICommandBarElement element;
8-
9-
#region ICommandBarElement implementation
10-
public int DynamicOverflowOrder { get => element.DynamicOverflowOrder; set => element.DynamicOverflowOrder = value; }
11-
public bool IsCompact { get => element.IsCompact; set => element.IsCompact = value; }
12-
public bool IsInOverflow => element.IsInOverflow;
13-
#endregion
7+
public Xaml.Controls.ICommandBarElement UI { get; }
148

159
public static implicit operator CommandBarElement(AppBarButton e) => new (e.UI);
1610
public static implicit operator CommandBarElement(AppBarElementContainer e) => new (e.UI);
1711
public static implicit operator CommandBarElement(AppBarSeparator e) => new (e.UI);
1812
public static implicit operator CommandBarElement(AppBarToggleButton e) => new (e.UI);
1913

20-
public CommandBarElement(Xaml.Controls.ICommandBarElement element) => this.element = element;
14+
public CommandBarElement(Xaml.Controls.ICommandBarElement ui) => this.UI = ui;
2115
}

src/CSharpMarkup.WinUI/DependencyObject.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ public static string BindingExpressionToPath(string pathExpression)
3030
}
3131
}
3232

33-
public interface IUI<TUI> where TUI : Xaml.DependencyObject
33+
public interface IUI<TUI> : IAnyUI<TUI> where TUI : Xaml.DependencyObject { }
34+
35+
public interface IAnyUI<TUI> : IAnyUI // Support non-DependencyObject UI types, e.g. an interface
3436
{
3537
TUI UI { get; }
3638
}
3739

40+
public interface IAnyUI { }
41+
3842
#if !WINUI
3943
public partial class DependencyObject : IUI<Xaml.DependencyObject>
4044
{
@@ -48,7 +52,7 @@ protected DependencyObject() { }
4852
/// Allows to specify <see cref="CSharpMarkup.WinUI"/> types (e.g. <see cref="TextBlock"/>) as well as commonly used built-in C# / UI types (e.g. <see cref="string"/> or <see cref="Xaml.Thickness"/>).
4953
/// </summary>
5054
/// <remarks>For types not supported by implicit conversion, use the <see cref="UIObject(object)"/> contructor, e.g.: <code>new (FontCapitals.Normal)</code></remarks>
51-
public class UIObject
55+
public class UIObject : IAnyUI<object>
5256
{
5357
public object UI { get; }
5458

src/CSharpMarkup.WinUI/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET7_0.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8320,9 +8320,9 @@ public static CommandBar CommandBar(params CommandBarElement[] PrimaryCommands)
83208320
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
83218321
if (subChildren is not null)
83228322
for (int j = 0; j < subChildren.Length; j++)
8323-
ui.PrimaryCommands.Add(subChildren[j]);
8323+
ui.PrimaryCommands.Add(subChildren[j].UI);
83248324
else
8325-
ui.PrimaryCommands.Add(child);
8325+
ui.PrimaryCommands.Add(child.UI);
83268326
}
83278327
return CSharpMarkup.WinUI.CommandBar.StartChain(ui);
83288328
}
@@ -27950,9 +27950,9 @@ public static CommandBarFlyoutCommandBar CommandBarFlyoutCommandBar(params Comma
2795027950
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
2795127951
if (subChildren is not null)
2795227952
for (int j = 0; j < subChildren.Length; j++)
27953-
ui.PrimaryCommands.Add(subChildren[j]);
27953+
ui.PrimaryCommands.Add(subChildren[j].UI);
2795427954
else
27955-
ui.PrimaryCommands.Add(child);
27955+
ui.PrimaryCommands.Add(child.UI);
2795627956
}
2795727957
return CSharpMarkup.WinUI.CommandBarFlyoutCommandBar.StartChain(ui);
2795827958
}

src/CSharpMarkup.WinUI/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET7_0_ANDROID.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8544,9 +8544,9 @@ public static CommandBar CommandBar(params CommandBarElement[] PrimaryCommands)
85448544
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
85458545
if (subChildren is not null)
85468546
for (int j = 0; j < subChildren.Length; j++)
8547-
ui.PrimaryCommands.Add(subChildren[j]);
8547+
ui.PrimaryCommands.Add(subChildren[j].UI);
85488548
else
8549-
ui.PrimaryCommands.Add(child);
8549+
ui.PrimaryCommands.Add(child.UI);
85508550
}
85518551
return CSharpMarkup.WinUI.CommandBar.StartChain(ui);
85528552
}
@@ -29954,9 +29954,9 @@ public static CommandBarFlyoutCommandBar CommandBarFlyoutCommandBar(params Comma
2995429954
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
2995529955
if (subChildren is not null)
2995629956
for (int j = 0; j < subChildren.Length; j++)
29957-
ui.PrimaryCommands.Add(subChildren[j]);
29957+
ui.PrimaryCommands.Add(subChildren[j].UI);
2995829958
else
29959-
ui.PrimaryCommands.Add(child);
29959+
ui.PrimaryCommands.Add(child.UI);
2996029960
}
2996129961
return CSharpMarkup.WinUI.CommandBarFlyoutCommandBar.StartChain(ui);
2996229962
}

src/CSharpMarkup.WinUI/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET7_0_IOS.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8673,9 +8673,9 @@ public static CommandBar CommandBar(params CommandBarElement[] PrimaryCommands)
86738673
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
86748674
if (subChildren is not null)
86758675
for (int j = 0; j < subChildren.Length; j++)
8676-
ui.PrimaryCommands.Add(subChildren[j]);
8676+
ui.PrimaryCommands.Add(subChildren[j].UI);
86778677
else
8678-
ui.PrimaryCommands.Add(child);
8678+
ui.PrimaryCommands.Add(child.UI);
86798679
}
86808680
return CSharpMarkup.WinUI.CommandBar.StartChain(ui);
86818681
}
@@ -31827,9 +31827,9 @@ public static CommandBarFlyoutCommandBar CommandBarFlyoutCommandBar(params Comma
3182731827
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
3182831828
if (subChildren is not null)
3182931829
for (int j = 0; j < subChildren.Length; j++)
31830-
ui.PrimaryCommands.Add(subChildren[j]);
31830+
ui.PrimaryCommands.Add(subChildren[j].UI);
3183131831
else
31832-
ui.PrimaryCommands.Add(child);
31832+
ui.PrimaryCommands.Add(child.UI);
3183331833
}
3183431834
return CSharpMarkup.WinUI.CommandBarFlyoutCommandBar.StartChain(ui);
3183531835
}

src/CSharpMarkup.WinUI/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET7_0_MACCATALYST.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8673,9 +8673,9 @@ public static CommandBar CommandBar(params CommandBarElement[] PrimaryCommands)
86738673
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
86748674
if (subChildren is not null)
86758675
for (int j = 0; j < subChildren.Length; j++)
8676-
ui.PrimaryCommands.Add(subChildren[j]);
8676+
ui.PrimaryCommands.Add(subChildren[j].UI);
86778677
else
8678-
ui.PrimaryCommands.Add(child);
8678+
ui.PrimaryCommands.Add(child.UI);
86798679
}
86808680
return CSharpMarkup.WinUI.CommandBar.StartChain(ui);
86818681
}
@@ -31827,9 +31827,9 @@ public static CommandBarFlyoutCommandBar CommandBarFlyoutCommandBar(params Comma
3182731827
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
3182831828
if (subChildren is not null)
3182931829
for (int j = 0; j < subChildren.Length; j++)
31830-
ui.PrimaryCommands.Add(subChildren[j]);
31830+
ui.PrimaryCommands.Add(subChildren[j].UI);
3183131831
else
31832-
ui.PrimaryCommands.Add(child);
31832+
ui.PrimaryCommands.Add(child.UI);
3183331833
}
3183431834
return CSharpMarkup.WinUI.CommandBarFlyoutCommandBar.StartChain(ui);
3183531835
}

src/CSharpMarkup.WinUI/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET7_0_MACOS.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8673,9 +8673,9 @@ public static CommandBar CommandBar(params CommandBarElement[] PrimaryCommands)
86738673
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
86748674
if (subChildren is not null)
86758675
for (int j = 0; j < subChildren.Length; j++)
8676-
ui.PrimaryCommands.Add(subChildren[j]);
8676+
ui.PrimaryCommands.Add(subChildren[j].UI);
86778677
else
8678-
ui.PrimaryCommands.Add(child);
8678+
ui.PrimaryCommands.Add(child.UI);
86798679
}
86808680
return CSharpMarkup.WinUI.CommandBar.StartChain(ui);
86818681
}
@@ -30618,9 +30618,9 @@ public static CommandBarFlyoutCommandBar CommandBarFlyoutCommandBar(params Comma
3061830618
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
3061930619
if (subChildren is not null)
3062030620
for (int j = 0; j < subChildren.Length; j++)
30621-
ui.PrimaryCommands.Add(subChildren[j]);
30621+
ui.PrimaryCommands.Add(subChildren[j].UI);
3062230622
else
30623-
ui.PrimaryCommands.Add(child);
30623+
ui.PrimaryCommands.Add(child.UI);
3062430624
}
3062530625
return CSharpMarkup.WinUI.CommandBarFlyoutCommandBar.StartChain(ui);
3062630626
}

src/CSharpMarkup.WinUI/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/WinUI.NET7_0_WINDOWS10_0_18362_0.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -7076,9 +7076,9 @@ public static CommandBar CommandBar(params CommandBarElement[] PrimaryCommands)
70767076
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
70777077
if (subChildren is not null)
70787078
for (int j = 0; j < subChildren.Length; j++)
7079-
ui.PrimaryCommands.Add(subChildren[j]);
7079+
ui.PrimaryCommands.Add(subChildren[j].UI);
70807080
else
7081-
ui.PrimaryCommands.Add(child);
7081+
ui.PrimaryCommands.Add(child.UI);
70827082
}
70837083
return CSharpMarkup.WinUI.CommandBar.StartChain(ui);
70847084
}
@@ -7177,9 +7177,9 @@ public static CommandBarFlyout CommandBarFlyout(params CommandBarElement[] Prima
71777177
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
71787178
if (subChildren is not null)
71797179
for (int j = 0; j < subChildren.Length; j++)
7180-
ui.PrimaryCommands.Add(subChildren[j]);
7180+
ui.PrimaryCommands.Add(subChildren[j].UI);
71817181
else
7182-
ui.PrimaryCommands.Add(child);
7182+
ui.PrimaryCommands.Add(child.UI);
71837183
}
71847184
return CSharpMarkup.WinUI.CommandBarFlyout.StartChain(ui);
71857185
}
@@ -20674,9 +20674,9 @@ public static TextCommandBarFlyout TextCommandBarFlyout(params CommandBarElement
2067420674
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
2067520675
if (subChildren is not null)
2067620676
for (int j = 0; j < subChildren.Length; j++)
20677-
ui.PrimaryCommands.Add(subChildren[j]);
20677+
ui.PrimaryCommands.Add(subChildren[j].UI);
2067820678
else
20679-
ui.PrimaryCommands.Add(child);
20679+
ui.PrimaryCommands.Add(child.UI);
2068020680
}
2068120681
return CSharpMarkup.WinUI.TextCommandBarFlyout.StartChain(ui);
2068220682
}
@@ -23393,9 +23393,9 @@ public static CommandBarFlyoutCommandBar CommandBarFlyoutCommandBar(params Comma
2339323393
var subChildren = Spreader<CommandBarElement>.ExtractChildren(child);
2339423394
if (subChildren is not null)
2339523395
for (int j = 0; j < subChildren.Length; j++)
23396-
ui.PrimaryCommands.Add(subChildren[j]);
23396+
ui.PrimaryCommands.Add(subChildren[j].UI);
2339723397
else
23398-
ui.PrimaryCommands.Add(child);
23398+
ui.PrimaryCommands.Add(child.UI);
2339923399
}
2340023400
return CSharpMarkup.WinUI.CommandBarFlyoutCommandBar.StartChain(ui);
2340123401
}

src/CSharpMarkup.WinUI/Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ Get started quickly with the [mcs-winui3-app and mcs-winui3-view dotnet new temp
1313

1414
[Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
1515

16-
[Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/csharpmarkup2-winui-wpf-2-2-12)
16+
[Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/csharpmarkup2-winui-wpf-2-2-21)

src/CSharpMarkup.Wpf.Examples/CSharpMarkup.Wpf.Examples.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="CSharpMarkup.WPF" Version="2.1.14" />
12+
<PackageReference Include="CSharpMarkup.WPF" Version="2.2.21" />
1313
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="All" />
1414
</ItemGroup>
1515

src/CSharpMarkup.Wpf/CSharpMarkup.Wpf.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2727
<RepositoryType>git</RepositoryType>
2828
<Product>$(AssemblyName) ($(TargetFramework))</Product>
29-
<Version>2.1.14</Version>
29+
<Version>2.2.21</Version>
3030
<NeutralLanguage>en</NeutralLanguage>
3131

3232
<NoWarn>CS1591;CS1573</NoWarn>

src/CSharpMarkup.Wpf/DependencyObject.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,22 @@ public static (string, string) NamesExpressionToNames(string? nameExpression)
134134
}
135135
}
136136

137-
public interface IUI<TUI> where TUI : System.Windows.DependencyObject
138-
{
139-
TUI UI { get; }
140-
}
137+
public interface IUI<TUI> : IAnyUI<TUI> where TUI : System.Windows.DependencyObject { }
141138

142-
public interface IUI_Dispatcher<TUI> where TUI : System.Windows.Threading.DispatcherObject
139+
public interface IUI_Dispatcher<TUI> : IAnyUI<TUI> where TUI : System.Windows.Threading.DispatcherObject { }
140+
141+
public interface IAnyUI<TUI> : IAnyUI // Support non-DependencyObject/DispatcherObject UI types, e.g. an interface
143142
{
144143
TUI UI { get; }
145144
}
146145

146+
public interface IAnyUI { }
147+
147148
/// <summary>
148149
/// Allows to specify <see cref="CSharpMarkup.Wpf"/> types (e.g. <see cref="TextBlock"/>) as well as commonly used built-in C# / UI types (e.g. <see cref="string"/> or <see cref="System.Windows.Thickness"/>).
149150
/// </summary>
150151
/// <remarks>For types not supported by implicit conversion, use the <see cref="UIObject(object)"/> contructor, e.g.: <code>new (FontCapitals.Normal)</code></remarks>
151-
public class UIObject
152+
public class UIObject : IAnyUI<object>
152153
{
153154
public object UI { get; }
154155

0 commit comments

Comments
 (0)