├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── NuGet.config
├── README.md
├── global.json
├── img
├── CSharpMarkup2-UnoCSharpMarkup-XAML.png
├── bind-default-parameter.png
├── bind-inline-conversion.png
├── bindcommand.png
├── improve-markup-colors-in-vs.png
├── in-app-hot-reload-button.png
├── markup-attached-properties-set-multiple.png
├── markup-attached-properties.png
├── markup-basic-anatomy.png
├── markup-binding-expression.png
├── markup-controltemplate-in-style.png
├── markup-controltemplate.png
├── markup-converter-cornerradius-doc.png
├── markup-converters.png
├── markup-datatemplate.png
├── markup-enums-for-grid-rows-columns-usage.png
├── markup-enums-for-grid-rows-columns.png
├── markup-example-flutter-page.png
├── markup-layout-insert-children-conditional-spread.png
├── markup-logic-assign-1.png
├── markup-logic-assign-2.png
├── markup-logic-invoke-1.png
├── markup-logic-invoke-2.png
├── markup-page-files.png
├── markup-property-enum-values.png
├── markup-shorthand-1.png
├── markup-shorthand-2.png
├── markup-style-definition.png
├── markup-style-setter-binding.png
├── markup-style-usage.png
├── markup-view-convenience-overload.png
├── markup-view-defined-properties.png
├── mcs-winui3-app-default-sln.png
├── mcs-winui3-app-mainpage-debug.png
├── mcs-winui3-hotreload-in-app-button.png
├── mcs-winui3-hotreload-in-app-navigation.png
├── mcs-winui3-hotreload-menu.png
├── mcs-winui3-hotreload-output.png
├── mcs-winui3-hotreload-rebuild-enabled.png
├── mcs-winui3-new-view-output.png
├── mcs-winui3-new-view.png
├── poll202303.png
├── unoconf-announce-csharp-markup-2.png
├── visual-studio-dotnet-hot-reload-button.png
└── visual-studio-dotnet-hot-reload-statusbar.png
└── src
├── CSharpMarkup.WinUI.Examples
├── .editorconfig
├── .gitignore
├── .run
│ ├── Readme.md
│ └── WinUICsMarkupExamples.run.xml
├── .vscode
│ ├── extensions.json
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── .vsconfig
├── Directory.Build.props
├── Directory.Build.targets
├── Directory.Packages.props
├── WinUICsMarkupExamples.Presentation
│ ├── .filenesting.json
│ ├── Core
│ │ ├── BasePage.cs
│ │ ├── BasePage.logic.cs
│ │ ├── BaseUserControl.cs
│ │ ├── BaseViewModel.cs
│ │ ├── Constants.cs
│ │ ├── GlobalUsings.cs
│ │ └── MarkupExtensions.cs
│ ├── Example
│ │ ├── FlutterPage.cs
│ │ ├── FlutterPage.logic.cs
│ │ ├── FlutterViewModel.cs
│ │ ├── Routes.cs
│ │ ├── SearchPage.cs
│ │ ├── SearchPage.logic.cs
│ │ ├── SearchViewModel.cs
│ │ ├── Shell.cs
│ │ ├── Shell.logic.cs
│ │ └── ShellViewModel.cs
│ ├── New-View.ps1
│ ├── Readme.md
│ └── WinUICsMarkupExamples.Presentation.csproj
├── WinUICsMarkupExamples.sln
└── WinUICsMarkupExamples
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Assets
│ ├── Icons
│ │ ├── icon.svg
│ │ └── icon_foreground.svg
│ ├── Images
│ │ ├── forward.svg
│ │ └── search.svg
│ ├── SharedAssets.md
│ └── Splash
│ │ └── splash_screen.svg
│ ├── GlobalUsings.cs
│ ├── Models
│ └── AppConfig.cs
│ ├── Package.appxmanifest
│ ├── Platforms
│ ├── Android
│ │ ├── AndroidManifest.xml
│ │ ├── Assets
│ │ │ └── AboutAssets.txt
│ │ ├── Main.Android.cs
│ │ ├── MainActivity.Android.cs
│ │ ├── Resources
│ │ │ ├── AboutResources.txt
│ │ │ └── values
│ │ │ │ ├── Strings.xml
│ │ │ │ └── Styles.xml
│ │ └── environment.conf
│ ├── Desktop
│ │ └── Program.cs
│ ├── WebAssembly
│ │ ├── LinkerConfig.xml
│ │ ├── Program.cs
│ │ ├── WasmCSS
│ │ │ └── Fonts.css
│ │ ├── WasmScripts
│ │ │ └── AppManifest.js
│ │ ├── manifest.webmanifest
│ │ └── wwwroot
│ │ │ ├── staticwebapp.config.json
│ │ │ └── web.config
│ └── iOS
│ │ ├── Entitlements.plist
│ │ ├── Info.plist
│ │ ├── Main.iOS.cs
│ │ ├── Media.xcassets
│ │ └── LaunchImages.launchimage
│ │ │ └── Contents.json
│ │ └── PrivacyInfo.xcprivacy
│ ├── Properties
│ ├── PublishProfiles
│ │ ├── win-arm64.pubxml
│ │ ├── win-x64.pubxml
│ │ └── win-x86.pubxml
│ └── launchSettings.json
│ ├── ReadMe.md
│ ├── Strings
│ ├── en
│ │ └── Resources.resw
│ ├── es
│ │ └── Resources.resw
│ ├── fr
│ │ └── Resources.resw
│ └── pt-BR
│ │ └── Resources.resw
│ ├── Styles
│ ├── ColorPaletteOverride.json
│ ├── ColorPaletteOverride.xaml
│ └── Example.xaml
│ ├── WinUICsMarkupExamples.csproj
│ ├── app.manifest
│ ├── appsettings.development.json
│ └── appsettings.json
├── CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView
├── CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView.csproj
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_Android.cs
│ │ ├── UnoWinUI.NET8_0_MacCatalyst.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ ├── UnoWinUI.NET8_0_iOS.cs
│ │ └── WinUI.NET8_0_WinAppSdk.cs
├── Readme.md
├── _Helpers.cs
├── _View.Template.cs
└── global.json
├── CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit
├── CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.csproj
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_ANDROID.cs
│ │ ├── UnoWinUI.NET8_0_IOS.cs
│ │ ├── UnoWinUI.NET8_0_MACCATALYST.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ └── WinUI.NET8_0_WinAppSdk.cs
├── Readme.md
├── _Helpers.cs
├── _View.Template.cs
└── global.json
├── CSharpMarkup.WinUI.Uno.Extensions.Navigation
├── CSharpMarkup.WinUI.Uno.Extensions.Navigation.csproj
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_ANDROID.cs
│ │ ├── UnoWinUI.NET8_0_IOS.cs
│ │ ├── UnoWinUI.NET8_0_MACCATALYST.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ └── WinUI.NET8_0_WinAppSdk.cs
├── Readme.md
├── _Helpers.cs
├── _View.Template.cs
└── global.json
├── CSharpMarkup.WinUI.Uno.Extensions.Reactive
├── CSharpMarkup.WinUI.Uno.Extensions.Reactive.csproj
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_ANDROID.cs
│ │ ├── UnoWinUI.NET8_0_IOS.cs
│ │ ├── UnoWinUI.NET8_0_MACCATALYST.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ └── WinUI.NET8_0_WinAppSdk.cs
├── Readme.md
├── _Helpers.cs
├── _View.Template.cs
└── global.json
├── CSharpMarkup.WinUI.Uno.Toolkit
├── CSharpMarkup.WinUI.Uno.Toolkit.csproj
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_Android.cs
│ │ ├── UnoWinUI.NET8_0_MacCatalyst.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ ├── UnoWinUI.NET8_0_iOS.cs
│ │ └── WinUI.NET8_0_WinAppSdk.cs
├── NavigationBar.cs
├── Readme.md
├── _Helpers.cs
├── _View.Template.cs
└── global.json
├── CSharpMarkup.WinUI
├── Attributes.cs
├── CSharpMarkup.WinUI.csproj
├── CSharpMarkup.WinUI.sln
├── CommandBarElement.cs
├── CompileTests
│ ├── TestModel.cs
│ ├── TestPage.cs
│ └── TestPage.logic.cs
├── Control.cs
├── DefaultBindProperties.cs
├── Delegators.cs
├── DependencyObject.cs
├── DependencyProperty.cs
├── DevTools.cs
├── FrameworkElement.cs
├── FrameworkElementInGridExtensions.cs
├── FuncConverter.cs
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_ANDROID.cs
│ │ ├── UnoWinUI.NET8_0_IOS.cs
│ │ ├── UnoWinUI.NET8_0_MACCATALYST.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ ├── UnoWinUI.NET9_0_Android.cs
│ │ ├── UnoWinUI.NET9_0_MacCatalyst.cs
│ │ ├── UnoWinUI.NET9_0_WasmOrSkia.cs
│ │ ├── UnoWinUI.NET9_0_iOS.cs
│ │ ├── WinUI.NET8_0_WinAppSdk.cs
│ │ └── WinUI.NET9_0_WinAppSdk.cs
├── Grid.cs
├── Hyperlink.cs
├── InlineCollection.cs
├── ItemsRepeater.cs
├── ListView.cs
├── MarkupExtensions.cs
├── Readme.md
├── Spread.cs
├── StackPanel.cs
├── Style.cs
├── Templates.cs
├── ThemeResource.cs
├── Thickness.cs
├── VisualStateManager.cs
├── _Helpers.cs
├── _TypeConvertors.cs
├── _View.Template.cs
└── global.json
├── CSharpMarkup.Wpf.Examples
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── CSharpMarkup.Wpf.Examples.csproj
├── CSharpMarkup.Wpf.Examples.sln
├── Core
│ ├── BasePage.cs
│ ├── BaseViewModel.cs
│ ├── Constants.cs
│ ├── GlobalUsings.cs
│ ├── HotReloadManager.cs
│ ├── IBuild.cs
│ ├── MarkupExtensions.cs
│ ├── RelayCommand.cs
│ └── XLog.cs
├── FlutterPage.cs
├── FlutterPage.logic.cs
├── FlutterViewModel.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── NuGet.config
├── SearchPage.cs
├── SearchPage.logic.cs
├── SearchViewModel.cs
└── Styles.cs
├── CSharpMarkup.Wpf
├── Attributes.cs
├── CSharpMarkup.Wpf.csproj
├── DefaultBindProperties.cs
├── Delegators.cs
├── DependencyObject.cs
├── DependencyProperty.cs
├── FrameworkElement.cs
├── FrameworkElementInGridExtensions.cs
├── FuncConverter.cs
├── Generated
│ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ └── Wpf.NET7_0.cs
├── Grid.cs
├── Hyperlink.cs
├── InlineCollection.cs
├── ListView.cs
├── MarkupExtensions.cs
├── MenuItem.cs
├── NameScopes.cs
├── Readme.md
├── Spread.cs
├── StackPanel.cs
├── StoryBoard.cs
├── Style.cs
├── Templates.cs
├── Thickness.cs
├── _Helpers.cs
├── _TypeConvertors.cs
└── _View.Template.cs
├── Directory.Build.props
├── Directory.Build.targets
└── Directory.Packages.props
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: VincentH-Net
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Vincent Hoogendoorn
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Uno.Sdk": "6.0.96"
4 | },
5 | "sdk": {
6 | "version": "9.0.300",
7 | "rollForward": "latestPatch"
8 | }
9 | }
--------------------------------------------------------------------------------
/img/CSharpMarkup2-UnoCSharpMarkup-XAML.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/CSharpMarkup2-UnoCSharpMarkup-XAML.png
--------------------------------------------------------------------------------
/img/bind-default-parameter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/bind-default-parameter.png
--------------------------------------------------------------------------------
/img/bind-inline-conversion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/bind-inline-conversion.png
--------------------------------------------------------------------------------
/img/bindcommand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/bindcommand.png
--------------------------------------------------------------------------------
/img/improve-markup-colors-in-vs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/improve-markup-colors-in-vs.png
--------------------------------------------------------------------------------
/img/in-app-hot-reload-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/in-app-hot-reload-button.png
--------------------------------------------------------------------------------
/img/markup-attached-properties-set-multiple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-attached-properties-set-multiple.png
--------------------------------------------------------------------------------
/img/markup-attached-properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-attached-properties.png
--------------------------------------------------------------------------------
/img/markup-basic-anatomy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-basic-anatomy.png
--------------------------------------------------------------------------------
/img/markup-binding-expression.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-binding-expression.png
--------------------------------------------------------------------------------
/img/markup-controltemplate-in-style.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-controltemplate-in-style.png
--------------------------------------------------------------------------------
/img/markup-controltemplate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-controltemplate.png
--------------------------------------------------------------------------------
/img/markup-converter-cornerradius-doc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-converter-cornerradius-doc.png
--------------------------------------------------------------------------------
/img/markup-converters.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-converters.png
--------------------------------------------------------------------------------
/img/markup-datatemplate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-datatemplate.png
--------------------------------------------------------------------------------
/img/markup-enums-for-grid-rows-columns-usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-enums-for-grid-rows-columns-usage.png
--------------------------------------------------------------------------------
/img/markup-enums-for-grid-rows-columns.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-enums-for-grid-rows-columns.png
--------------------------------------------------------------------------------
/img/markup-example-flutter-page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-example-flutter-page.png
--------------------------------------------------------------------------------
/img/markup-layout-insert-children-conditional-spread.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-layout-insert-children-conditional-spread.png
--------------------------------------------------------------------------------
/img/markup-logic-assign-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-logic-assign-1.png
--------------------------------------------------------------------------------
/img/markup-logic-assign-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-logic-assign-2.png
--------------------------------------------------------------------------------
/img/markup-logic-invoke-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-logic-invoke-1.png
--------------------------------------------------------------------------------
/img/markup-logic-invoke-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-logic-invoke-2.png
--------------------------------------------------------------------------------
/img/markup-page-files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-page-files.png
--------------------------------------------------------------------------------
/img/markup-property-enum-values.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-property-enum-values.png
--------------------------------------------------------------------------------
/img/markup-shorthand-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-shorthand-1.png
--------------------------------------------------------------------------------
/img/markup-shorthand-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-shorthand-2.png
--------------------------------------------------------------------------------
/img/markup-style-definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-style-definition.png
--------------------------------------------------------------------------------
/img/markup-style-setter-binding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-style-setter-binding.png
--------------------------------------------------------------------------------
/img/markup-style-usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-style-usage.png
--------------------------------------------------------------------------------
/img/markup-view-convenience-overload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-view-convenience-overload.png
--------------------------------------------------------------------------------
/img/markup-view-defined-properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/markup-view-defined-properties.png
--------------------------------------------------------------------------------
/img/mcs-winui3-app-default-sln.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-app-default-sln.png
--------------------------------------------------------------------------------
/img/mcs-winui3-app-mainpage-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-app-mainpage-debug.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-in-app-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-hotreload-in-app-button.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-in-app-navigation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-hotreload-in-app-navigation.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-hotreload-menu.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-hotreload-output.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-rebuild-enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-hotreload-rebuild-enabled.png
--------------------------------------------------------------------------------
/img/mcs-winui3-new-view-output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-new-view-output.png
--------------------------------------------------------------------------------
/img/mcs-winui3-new-view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/mcs-winui3-new-view.png
--------------------------------------------------------------------------------
/img/poll202303.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/poll202303.png
--------------------------------------------------------------------------------
/img/unoconf-announce-csharp-markup-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/unoconf-announce-csharp-markup-2.png
--------------------------------------------------------------------------------
/img/visual-studio-dotnet-hot-reload-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/visual-studio-dotnet-hot-reload-button.png
--------------------------------------------------------------------------------
/img/visual-studio-dotnet-hot-reload-statusbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/97e05735ea711c533935dd74f41126ae8cb6aebd/img/visual-studio-dotnet-hot-reload-statusbar.png
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.run/Readme.md:
--------------------------------------------------------------------------------
1 | # About the `.run` folder
2 |
3 | This folder is present to add support for the [Rider IDE](https://aka.platform.uno/rider-getstarted). You can remove this folder safely if you're not using Rider.
4 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.run/WinUICsMarkupExamples.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "unoplatform.vscode"
4 | ],
5 | }
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Uno Platform Mobile Debug",
9 | "type": "Uno",
10 | "request": "launch",
11 | // any Uno* task will do, this is simply to satisfy vscode requirement when a launch.json is present
12 | "preLaunchTask": "Uno: android | Debug | android-x64"
13 | },
14 | {
15 | // Use IntelliSense to find out which attributes exist for C# debugging
16 | // Use hover for the description of the existing attributes
17 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
18 | "name": "Uno Platform WebAssembly Debug (Chrome)",
19 | "type": "chrome",
20 | "request": "launch",
21 | "url": "http://localhost:5000",
22 | "webRoot": "${workspaceFolder}/WinUICsMarkupExamples",
23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
24 | "timeout": 30000,
25 | "preLaunchTask": "build-wasm",
26 | "server": {
27 | "runtimeExecutable": "dotnet",
28 | "program": "run",
29 | "args": ["--no-build","-f","net9.0-browserwasm","--launch-profile", "WinUICsMarkupExamples (WebAssembly)"],
30 | "outputCapture": "std",
31 | "timeout": 30000,
32 | "cwd": "${workspaceFolder}/WinUICsMarkupExamples"
33 | }
34 | },
35 | {
36 | // Use IntelliSense to find out which attributes exist for C# debugging
37 | // Use hover for the description of the existing attributes
38 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
39 | "name": "Uno Platform WebAssembly Debug (Edge)",
40 | "type": "msedge",
41 | "request": "launch",
42 | "url": "http://localhost:5000",
43 | "webRoot": "${workspaceFolder}/WinUICsMarkupExamples",
44 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
45 | "timeout": 30000,
46 | "preLaunchTask": "build-wasm",
47 | "server": {
48 | "runtimeExecutable": "dotnet",
49 | "program": "run",
50 | "args": ["--no-build","-f","net9.0-browserwasm","--launch-profile", "WinUICsMarkupExamples (WebAssembly)"],
51 | "outputCapture": "std",
52 | "timeout": 30000,
53 | "cwd": "${workspaceFolder}/WinUICsMarkupExamples"
54 | }
55 | },
56 | {
57 | // Use IntelliSense to find out which attributes exist for C# debugging
58 | // Use hover for the description of the existing attributes
59 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
60 | "name": "Uno Platform Desktop Debug",
61 | "type": "coreclr",
62 | "request": "launch",
63 | "preLaunchTask": "build-desktop",
64 | // If you have changed target frameworks, make sure to update the program path.
65 | "program": "${workspaceFolder}/WinUICsMarkupExamples/bin/Debug/net9.0-desktop/WinUICsMarkupExamples.dll",
66 | "args": [],
67 | "launchSettingsProfile": "WinUICsMarkupExamples (Desktop)",
68 | "env": {
69 | "DOTNET_MODIFIABLE_ASSEMBLIES": "debug"
70 | },
71 | "cwd": "${workspaceFolder}/WinUICsMarkupExamples",
72 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
73 | "console": "internalConsole",
74 | "stopAtEntry": false
75 | },
76 | ]
77 | }
78 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "explorer.fileNesting.enabled": true,
3 | "explorer.fileNesting.expand": false,
4 | "explorer.fileNesting.patterns": {
5 | "*.xaml": "$(capture).xaml.cs"
6 | },
7 | "files.associations": {
8 | "global.json": "jsonc"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build-wasm",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/WinUICsMarkupExamples/WinUICsMarkupExamples.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/property:TargetFramework=net9.0-browserwasm",
13 | "/consoleloggerparameters:NoSummary"
14 | ],
15 | "problemMatcher": "$msCompile"
16 | },
17 | {
18 | "label": "publish-wasm",
19 | "command": "dotnet",
20 | "type": "process",
21 | "args": [
22 | "publish",
23 | "${workspaceFolder}/WinUICsMarkupExamples/WinUICsMarkupExamples.csproj",
24 | "/property:GenerateFullPaths=true",
25 | "/property:TargetFramework=net9.0-browserwasm",
26 | "/consoleloggerparameters:NoSummary"
27 | ],
28 | "problemMatcher": "$msCompile"
29 | },
30 | {
31 | "label": "build-desktop",
32 | "command": "dotnet",
33 | "type": "process",
34 | "args": [
35 | "build",
36 | "${workspaceFolder}/WinUICsMarkupExamples/WinUICsMarkupExamples.csproj",
37 | "/property:GenerateFullPaths=true",
38 | "/property:TargetFramework=net9.0-desktop",
39 | "/consoleloggerparameters:NoSummary"
40 | ],
41 | "problemMatcher": "$msCompile"
42 | },
43 | {
44 | "label": "publish-desktop",
45 | "command": "dotnet",
46 | "type": "process",
47 | "args": [
48 | "publish",
49 | "${workspaceFolder}/WinUICsMarkupExamples/WinUICsMarkupExamples.csproj",
50 | "/property:GenerateFullPaths=true",
51 | "/property:TargetFramework=net9.0-desktop",
52 | "/consoleloggerparameters:NoSummary"
53 | ],
54 | "problemMatcher": "$msCompile"
55 | }
56 | ]
57 | }
58 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.vsconfig:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0",
3 | "components": [
4 | "Microsoft.VisualStudio.Component.CoreEditor",
5 | "Microsoft.VisualStudio.Workload.CoreEditor",
6 | "Microsoft.NetCore.Component.SDK",
7 | "Microsoft.NetCore.Component.DevelopmentTools",
8 | "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites",
9 | "Microsoft.VisualStudio.Component.TextTemplating",
10 | "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions",
11 | "Microsoft.NetCore.Component.Web",
12 | "Microsoft.VisualStudio.Component.IISExpress",
13 | "Component.Microsoft.Web.LibraryManager",
14 | "Microsoft.VisualStudio.ComponentGroup.Web",
15 | "Microsoft.VisualStudio.Component.Web",
16 | "Microsoft.VisualStudio.ComponentGroup.Web.Client",
17 | "Microsoft.VisualStudio.Workload.NetWeb",
18 | "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.TemplateEngine",
19 | "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging",
20 | "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites",
21 | "Microsoft.VisualStudio.Component.Debugger.JustInTime",
22 | "Microsoft.VisualStudio.Workload.ManagedDesktop",
23 | "Component.Xamarin.RemotedSimulator",
24 | "Microsoft.VisualStudio.Component.MonoDebugger",
25 | "Microsoft.VisualStudio.ComponentGroup.Maui.All",
26 | "Component.Android.SDK34",
27 | "Component.OpenJDK",
28 | "Microsoft.VisualStudio.Workload.NetCrossPlat",
29 | "Microsoft.VisualStudio.Workload.NetCoreTools"
30 | ]
31 | }
32 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | enable
4 | enable
5 | true
6 |
7 |
13 | $(NoWarn);NU1507;NETSDK1201;PRI257
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/.filenesting.json:
--------------------------------------------------------------------------------
1 | {
2 | "help": "https://go.microsoft.com/fwlink/?linkid=866610",
3 | "root": false,
4 |
5 | "dependentFileProviders": {
6 | "add": {
7 | "pathSegment": {}
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/BasePage.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Core;
2 |
3 | partial class BasePage
4 | {
5 | new protected Page Content(UIElement content) => this.Content(ShowTools,
6 | content
7 | .SafeArea_Insets().All()
8 | .UI
9 | ) .Background(ThemeResource.ApplicationPageBackgroundThemeBrush);
10 | }
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/BasePage.logic.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml.Navigation;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Core;
4 |
5 | public abstract partial class BasePage : BasePage where TViewModel : class
6 | {
7 | protected TViewModel? vm => DataContext as TViewModel;
8 | }
9 |
10 | // Because instances of this class are created with new instead of with a C# Markup 2 helper,
11 | // derive this class from the UI type instead of from the C# Markup 2 type
12 | public abstract partial class BasePage : UIControls.Page
13 | {
14 | const bool ShowTools =
15 | #if DEBUG
16 | true;
17 | #else
18 | false;
19 | #endif
20 |
21 | protected BasePage() => NavigationCacheMode = NavigationCacheMode.Required;
22 | }
23 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/BaseUserControl.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Core;
2 |
3 | public abstract partial class BaseUserControl : BaseUserControl where TViewModel : class
4 | {
5 | protected TViewModel? vm => DataContext as TViewModel;
6 | }
7 |
8 | // Because instances of this class are created with new instead of with a C# Markup 2 helper,
9 | // derive this class from the UI type instead of from the C# Markup 2 type
10 | public abstract partial class BaseUserControl : UIControls.UserControl
11 | {
12 | new public UserControl Content(UI.Xaml.UIElement content)
13 | => CSharpMarkup.WinUI.Helpers.Content(this, content);
14 | }
15 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Core;
2 |
3 | public class BaseViewModel : ObservableObject
4 | {
5 | }
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Core;
2 |
3 | static class Constants
4 | {
5 | public static Uri CsMarkupUri { get; } = new Uri("https://github.com/VincentH-Net/CSharpForMarkup");
6 | }
7 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | // Non-Uno global usings that would be generated if ImplicitUsings was enabled in the project file:
2 | global using global::System;
3 | global using global::System.Collections.Generic;
4 | global using global::System.IO;
5 | global using global::System.Linq;
6 | global using global::System.Net.Http;
7 | global using global::System.Threading;
8 | global using global::System.Threading.Tasks;
9 |
10 | // MVVM presentation pattern:
11 | global using CommunityToolkit.Mvvm.ComponentModel;
12 | global using CommunityToolkit.Mvvm.Input;
13 |
14 | // Uno navigation for use in models:
15 | global using Uno.Extensions.Navigation;
16 |
17 | // Markup extension methods:
18 | global using CSharpMarkup.WinUI;
19 | global using CSharpMarkup.WinUI.Uno.Extensions.Navigation;
20 | global using CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit;
21 | global using CSharpMarkup.WinUI.Uno.Toolkit;
22 | global using WinUICsMarkupExamples.Presentation.Core;
23 |
24 | // Markup helpers:
25 | global using static CSharpMarkup.WinUI.Helpers;
26 | global using static CSharpMarkup.WinUI.Uno.Extensions.Navigation.Helpers;
27 | global using static CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.Helpers;
28 | global using static CSharpMarkup.WinUI.Uno.Toolkit.Helpers;
29 | global using static WinUICsMarkupExamples.Presentation.Core.MarkupHelpers;
30 |
31 | // Aliases for WinUI namespaces and types
32 | // - Use to avoid including WinUI namespaces, which can cause ambiguities with the CSharpMarkup namespaces
33 | // - Prefix namespaces and view type aliases with "UI"
34 | global using UI = Microsoft.UI;
35 | global using UIBindable = Microsoft.UI.Xaml.Data.BindableAttribute;
36 | global using UIControls = Microsoft.UI.Xaml.Controls;
37 | // - Non-view types, e.g. enums, don't need a UI prefix because they are not mirrored as types in the CSharpMarkup namespaces
38 | global using BindingMode = Microsoft.UI.Xaml.Data.BindingMode;
39 | global using Visibility = Microsoft.UI.Xaml.Visibility;
40 |
41 | // Example-specific global usings:
42 | global using static Microsoft.UI.Colors; // Or use an application specific palette class; can have dynamic values for theming
43 | global using Tweet = WinUICsMarkupExamples.Presentation.Example.SearchViewModel.Tweet;
44 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Core/MarkupExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Input;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Core;
4 |
5 | static class MarkupExtensions
6 | {
7 | /// Set
8 | public static TView Icon(this TView view, string appAsset) where TView : AppBarButton
9 | => view.Icon(MarkupHelpers.Icon(appAsset));
10 |
11 | public static TView OnClick(this TView view, ICommand command) where TView : ButtonBase
12 | {
13 | view.UI.Click += (_, _) => command.Execute(null);
14 | return view;
15 | }
16 |
17 | public static TextBlock OnDataContextChanged(this TextBlock target, Action onChanged)
18 | => target.OnDataContextChanged(onChanged);
19 |
20 | // Add any application-specific Markup extensions here
21 | }
22 |
23 | static class MarkupHelpers
24 | {
25 | internal static UIControls.BitmapIcon Icon(string appAsset) => BitmapIcon(UriSource: new Uri($"ms-appx:///Assets/{appAsset}.png"));
26 |
27 | internal static Image Image(string appAsset) => CSharpMarkup.WinUI.Helpers.Image(Source: BitmapImage(new Uri($"ms-appx:///Assets/{appAsset}.png")));
28 |
29 | internal static TextBlock ExampleFooter() => TextBlock(
30 | Span("Built with C# Markup "), Span("2") .FontSize(18), Span(" for Uno")
31 | ) .FontStyle().Italic()
32 | .Bottom() .HCenter();
33 |
34 | // Add more application-specific Markup helpers here
35 | }
36 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/FlutterPage.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | partial class FlutterPage
4 | {
5 | enum Row { Header, Body }
6 |
7 | public void BuildUI() => Content ( VStack (
8 | NavigationBar()
9 | .Content().Bind(vm?.Title),
10 |
11 | Button("Button with default style"),
12 |
13 | Button("Button with AccentButtonStyle").Style(ThemeResource.AccentButtonStyle),
14 |
15 | Button("Point here to see\nVisual State Manager in action!")
16 | .Style().AppResource("AnimatedButtonStyle") .Width(200) .Height(75),
17 |
18 | Button () .Template (RoundButton)
19 | .Foreground (Black) .Background (Gold) .Size (75)
20 | .Content().Bind (vm?.ToggleMoreText)
21 | .Bind (vm?.ToggleMoreCommand),
22 |
23 | vm!.ShowMore ?
24 | Border (
25 | TextBlock ("Demonstrate Flutter-like UI building features:\nConditional UI and the Spread() operator")
26 | ) .Background (ThemeResource.InfoBarSuccessSeverityBackgroundBrush)
27 | : null,
28 |
29 | TextBlock ("Subtitles:"),
30 | Spread (Subtitles),
31 |
32 | TextBlock ("Pairs:"),
33 | Spread (Pairs())
34 | ));
35 |
36 | IEnumerable Subtitles => vm!.Subtitles.Select(subtitle => TextBlock(subtitle).Margin(0, 5).UI);
37 |
38 | static IEnumerable Pairs()
39 | {
40 | for (int i = 1; i <= 5; i++)
41 | {
42 | yield return TextBlock($"Field {i}:").Margins(top: 20);
43 | yield return TextBox(PlaceholderText: $"Enter value for {i}");
44 | }
45 | }
46 |
47 | static ControlTemplate RoundButton => ControlTemplate(typeof(Button), () =>
48 | Grid(
49 | Ellipse()
50 | .Fill().BindTemplate (b?.Background)
51 | .Stroke().BindTemplate (b?.Foreground),
52 | ContentPresenter()
53 | .Center()
54 | ));
55 | }
56 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/FlutterPage.logic.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | [UIBindable]
4 | public sealed partial class FlutterPage : BasePage, IBuildUI
5 | {
6 | #pragma warning disable CS0649
7 | static readonly UIControls.Button? b;
8 | #pragma warning restore
9 |
10 | public FlutterPage()
11 | {
12 | DataContextChanged += (_, _) =>
13 | {
14 | if (vm is null) return;
15 | BuildUI();
16 | vm.PropertyChanged += (_, e) => { if (e.PropertyName == nameof(vm.ShowMore)) BuildUI(); };
17 | };
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/FlutterViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | [UIBindable]
4 | public sealed partial class FlutterViewModel : BaseViewModel
5 | {
6 | readonly List subTitles = ["Subtitle 1", "Subtitle 2", "Subtitle 3"];
7 |
8 | [ObservableProperty]
9 | public partial string Title { get; set; } = "Flutter-Like UI markup";
10 |
11 | [ObservableProperty][NotifyPropertyChangedFor(nameof(ToggleMoreText))]
12 | public partial bool ShowMore { get; set; } = true;
13 |
14 | public string ToggleMoreText => ShowMore ? "Less" : "More";
15 |
16 | public List Subtitles => subTitles;
17 |
18 | [RelayCommand] void ToggleMore() => ShowMore = !ShowMore;
19 | }
20 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/Routes.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | public static class Routes
4 | {
5 | public static void Register(IViewRegistry views, IRouteRegistry routes)
6 | {
7 | views.Register(
8 | new ViewMap(ViewModel: typeof(ShellViewModel)),
9 | new ViewMap(),
10 | new ViewMap()
11 | );
12 |
13 | routes.Register(
14 | new RouteMap("", View: views.FindByViewModel(),
15 | Nested: new RouteMap[]
16 | {
17 | new RouteMap("Search", View: views.FindByViewModel(), IsDefault:true),
18 | new RouteMap("Flutter", View: views.FindByViewModel())
19 | }
20 | )
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/SearchPage.cs:
--------------------------------------------------------------------------------
1 | using VM = WinUICsMarkupExamples.Presentation.Example.SearchViewModel;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Example;
4 |
5 | partial class SearchPage
6 | {
7 | public void BuildUI() => Content(
8 | Grid(
9 | Rows(Auto, Star, Auto),
10 |
11 | Header,
12 | SearchResults .Grid_Row(1),
13 | Footer .Grid_Row(2)
14 | )
15 | ) .Background(Black);
16 |
17 | NavigationBar Header => NavigationBar(
18 | TextBox(PlaceholderText: "Search") .Style(ThemeResource.ComboBoxTextBoxStyle) .VerticalAlignment().Center() .Bind(vm?.SearchText, BindingMode.TwoWay),
19 | AppBarButton() .Icon("Images/search" ) .OnClick(vm!.SearchCommand),
20 | AppBarButton() .Icon("Images/forward") .OnClick(vm!.ForwardCommand)
21 | ) .HorizontalContentAlignment().Stretch()
22 | #if HAS_UNO
23 | .Style().AppResource("XamlDefaultNavigationBar")
24 | #endif
25 | ;
26 |
27 | enum TweetRow { Title, Body, Actions }
28 | enum TweetColumn { AuthorImage, Content }
29 |
30 | ListView SearchResults => ListView(() =>
31 | Grid(
32 | Rows(
33 | (TweetRow.Title, Auto),
34 | (TweetRow.Body, Auto),
35 | (TweetRow.Actions, Auto)
36 | ),
37 |
38 | Columns(
39 | (TweetColumn.AuthorImage, 70),
40 | (TweetColumn.Content, Star)
41 | ),
42 |
43 | RoundImage(53)
44 | .Grid(TweetRow.Title, TweetRow.Actions, TweetColumn.AuthorImage) .HCenter() .Top() .Margins(left: 10, top: 4),
45 |
46 | TextBlock()
47 | .TextTrimming().CharacterEllipsis() .FontSize(16)
48 | .Grid(TweetRow.Title, TweetColumn.Content) .Margins(right: 10)
49 | .Bind(tweet.Header),
50 |
51 | TextBlock()
52 | .FontSize(15) .TextWrapping().WrapWholeWords()
53 | .Grid(TweetRow.Body, TweetColumn.Content) .Margins(right: 10)
54 | .OnDataContextChanged(Format),
55 |
56 | LikeButton()
57 | .Grid(TweetRow.Actions, TweetColumn.Content) .Left() .Top()
58 | .BindCommand(vm?.LikeCommand, vm)
59 |
60 | ) .BorderThicknesses(top: 0.5) .BorderBrush(Gray)
61 | .Padding(0, 6) .RowSpacing(6) .ColumnSpacing(6)
62 |
63 | ) .Background("#171F2A") .SelectionMode().None()
64 | .Bind(vm?.SearchResults);
65 |
66 | static Ellipse RoundImage(double size) => Ellipse() .Size(size) .Fill(ImageBrush() .Bind(tweet.AuthorImage));
67 |
68 | void Format(UIControls.TextBlock textBlock, Tweet? tweet)
69 | {
70 | textBlock.Inlines.Clear();
71 |
72 | tweet?.Body?.ForEach(fragment => textBlock.Inlines.Add(
73 | fragment.IsMatch ?
74 | Link(fragment.Text, VM.LinkUri(fragment.Text)) .FontSize(15) :
75 | Run(fragment.Text)
76 | ));
77 | }
78 |
79 | static Button LikeButton() => Button() .Style().AppResource("LikeButtonStyle")
80 | .Foreground(White) .FontSize(20)
81 | .HorizontalContentAlignment().Center() .VerticalContentAlignment().Center() .Margin(0) .Size(32) .Padding(0)
82 | .Content().Bind(tweet.IsLikedByMe, convert: (bool like) => like ? "\u2764" : "\u2661");
83 |
84 |
85 | static TextBlock Footer => TextBlock("See ", Link("C# Markup 2 on GitHub", Constants.CsMarkupUri), " for more information")
86 | .FontSize(14) .Foreground(White)
87 | .HCenter()
88 | .Margins(bottom: 24);
89 |
90 | static Hyperlink Link(string text, Uri uri) => Hyperlink(uri, text) .Foreground(CornflowerBlue);
91 | }
92 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/SearchPage.logic.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | [UIBindable]
4 | public sealed partial class SearchPage : BasePage, IBuildUI
5 | {
6 | static readonly Tweet tweet = new();
7 |
8 | public SearchPage()
9 | {
10 | DataContextChanged += (_, _) =>
11 | {
12 | if (vm is not null) BuildUI();
13 | };
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/Shell.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | partial class Shell
4 | {
5 | public void BuildUI() => Content (
6 | Border (
7 | ExtendedSplashScreen()
8 | .HVStretch() .StretchContent()
9 | .LoadingContentTemplate(DataTemplate(() =>
10 | Grid(
11 | Rows(Stars(2), Star),
12 |
13 | ProgressRing() .Grid_Row(1) .Center() .Size(100)
14 | )
15 | ))
16 | .Invoke(splash => ContentControl = splash)
17 | ) .Background(ThemeResource.ApplicationPageBackgroundThemeBrush)
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/Shell.logic.cs:
--------------------------------------------------------------------------------
1 | using Uno.Extensions.Hosting;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Example;
4 |
5 | [UIBindable]
6 | public sealed partial class Shell : BaseUserControl, IContentControlProvider, IBuildUI
7 | {
8 | public Shell() => BuildUI();
9 |
10 | public UIControls.ContentControl ContentControl { get; private set; } = null!;
11 | }
12 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/ShellViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | // TODO: not needed? [UIBindable]
4 | public class ShellViewModel : BaseViewModel
5 | {
6 | readonly INavigator _navigator;
7 |
8 | public ShellViewModel(INavigator navigator)
9 | {
10 | _navigator = navigator;
11 | _ = Start();
12 | }
13 |
14 | public async Task Start() => await _navigator.NavigateViewModelAsync(this);
15 | }
16 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/New-View.ps1:
--------------------------------------------------------------------------------
1 | # Tip: to use in Visual Studio:
2 | # 1) In solution explorer, right-click the WinUICsMarkupExamples.Presentation project and select "Open in Terminal"
3 | # 2) In the terminal window, type "new" + TAB to expand to ".\New-View.ps1", followed by the view name
4 |
5 | Param(
6 | [Parameter(Mandatory, HelpMessage="The view name ('Page' suffix will be added, use dots to add subnamespaces and subfolders)")]
7 | [string]
8 | $Name,
9 |
10 | [Parameter(HelpMessage="Select the update pattern to use for this view")]
11 | [ValidateSet("none", "mvvm", "mvux")]
12 | [string]$Presentation = "mvvm"
13 | )
14 |
15 | $SubNamespace = ""
16 | $OutputParameter = ""
17 | $lastDotPos = $Name.LastIndexOf('.')
18 | if ($lastDotPos -ge 0)
19 | {
20 | $OutputParameter = "-o " + $Name.Substring(0, $lastDotPos).Replace('.', '\')
21 | $SubNamespace = "." + $Name.Substring(0, $lastDotPos)
22 | $Name = $Name.Substring($lastDotPos + 1)
23 | }
24 |
25 | Invoke-Expression "dotnet new mcs-uno-view $OutputParameter -n $Name --namespace WinUICsMarkupExamples.Presentation$SubNamespace --presentation $Presentation"
26 | Write-Host "Note: if you target Windows native (WinAppSDK), you may need to rebuild the main Uno project once before using the new view, to generate it's XamlTypeInfo"
27 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Readme.md:
--------------------------------------------------------------------------------
1 | # Welcome to C# Markup 2 for Uno Platform
2 |
3 | This C# Markup 2 Presentation project was created with `dotnet new mcs-uno-markup2 --presentation mvvm --renderer native` (template version [`Modern.CSharp.Templates 3.2.0`](https://www.nuget.org/packages/Modern.CSharp.Templates/3.2.0))
4 |
5 | ## Get Started
6 |
7 | To start working with the C# Markup 2 project, follow these steps:
8 |
9 | 1. In `WinUICsMarkupExamples.Presentation.csproj`, replace the `` elements with the `` elements from `WinUICsMarkupExamples.csproj`; both projects should have the same target frameworks
10 | (the generated C# Markup 2 project targets all platforms supported by Uno).
11 |
12 | 2. To quickly try out the C# Markup 2 `Example`, add it to your navigation.
13 | If you are using `Uno.Extensions.Navigation`, you can do this in `App.cs`:
14 |
15 | At the top, add:
16 | ```csharp
17 | using CsMarkup2Example = WinUICsMarkupExamples.Presentation.Example;
18 | ```
19 |
20 | In the `.UseNavigation` call, pass in `CsMarkup2Example.Routes.Register` for the `viewRouteBuilder`:
21 | ```csharp
22 | .UseNavigation(CsMarkup2Example.Routes.Register)
23 | ```
24 |
25 | And finally specify `CsMarkup2Example.Shell` in the `builder.NavigateAsync` call:
26 | ```csharp
27 | Host = await builder.NavigateAsync();
28 | ```
29 |
30 | 3. If you target Windows native (WinAppSDK), **Rebuild** the `WinUICsMarkupExamples` project
31 | (the rebuild is to ensure that the Windows codegen for new pages has run; without that codegen you will get an exception on page display).
32 |
33 | 4. Run the `WinUICsMarkupExamples` project
34 |
35 | ## Add views and (view)models
36 | You can use `New-View.ps1` (located in the `WinUICsMarkupExamples.Presentation` project folder) to quickly add new views - including (view)model, if applicable. See `New-View.ps1` for tips and parameters.
37 |
38 | ## C# Hot Reload - Automatic & Manual
39 | Enjoy the fastest and most stable C# Hot Reload, with automatic UI updates, by debugging the **Desktop** target. This is a good reason to keep the Desktop target even if you don't deploy it.
40 |
41 | C# Hot Reload does work to some extent in more target platforms, however the UI does not yet update automatically in all platforms, due to issues in Visual Studio.
42 |
43 | The template contains code to overlay a 🔥 button in debug builds. This button lets you manually trigger a page rebuild, for cases where the IDE reports that C# hot reload succeeded but the UI does not update automatically.
44 |
45 | ## More info
46 | See the [Readme in the GitHub CSharpForMarkup repo](https://github.com/VincentH-Net/CSharpForMarkup#c-markup-2) for an overview of features, usage examples and best practices
47 |
48 | NJoy *concise* C# Markup 2 - the next-gen C# Markup for Uno!
49 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/WinUICsMarkupExamples.Presentation.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0-android;net9.0-ios;net9.0-windows10.0.26100;net9.0-browserwasm;net9.0-desktop
4 |
5 |
6 | Preview
7 |
8 | true
9 | Library
10 |
11 | true
12 |
13 | disable
14 | enable
15 | Mvvm;
16 | WinUICsMarkupExamples.Presentation
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Assets/Icons/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
43 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Assets/Images/forward.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Assets/Images/search.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Assets/SharedAssets.md:
--------------------------------------------------------------------------------
1 | # Shared Assets
2 |
3 | See documentation about assets here: https://github.com/unoplatform/uno/blob/master/doc/articles/features/working-with-assets.md
4 |
5 | ## Here is a cheat sheet
6 |
7 | 1. Add the image file to the `Assets` directory of a shared project.
8 | 2. Set the build action to `Content`.
9 | 3. (Recommended) Provide an asset for various scales/dpi
10 |
11 | ### Examples
12 |
13 | ```text
14 | \Assets\Images\logo.scale-100.png
15 | \Assets\Images\logo.scale-200.png
16 | \Assets\Images\logo.scale-400.png
17 |
18 | \Assets\Images\scale-100\logo.png
19 | \Assets\Images\scale-200\logo.png
20 | \Assets\Images\scale-400\logo.png
21 | ```
22 |
23 | ### Table of scales
24 |
25 | | Scale | WinUI | iOS | Android |
26 | |-------|:-----------:|:---------------:|:-------:|
27 | | `100` | scale-100 | @1x | mdpi |
28 | | `125` | scale-125 | N/A | N/A |
29 | | `150` | scale-150 | N/A | hdpi |
30 | | `200` | scale-200 | @2x | xhdpi |
31 | | `300` | scale-300 | @3x | xxhdpi |
32 | | `400` | scale-400 | N/A | xxxhdpi |
33 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using System.Collections.Immutable;
2 | global using Microsoft.Extensions.DependencyInjection;
3 | global using Microsoft.Extensions.Hosting;
4 | global using Microsoft.Extensions.Localization;
5 | global using Microsoft.Extensions.Logging;
6 | global using Microsoft.Extensions.Options;
7 | global using WinUICsMarkupExamples.Models;
8 | global using WinUICsMarkupExamples.Presentation;
9 | global using Uno.Extensions.Http.Kiota;
10 | global using ApplicationExecutionState = Windows.ApplicationModel.Activation.ApplicationExecutionState;
11 | global using CommunityToolkit.Mvvm.ComponentModel;
12 | global using CommunityToolkit.Mvvm.Input;
13 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Models/AppConfig.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Models;
2 |
3 | public record AppConfig
4 | {
5 | public string? Environment { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | To add cross-platform image assets for your Uno Platform app, use the Assets folder
2 | in the shared project instead. Assets in this folder are Android-only assets.
3 |
4 | Any raw assets you want to be deployed with your application can be placed in
5 | this directory (and child directories) and given a Build Action of "AndroidAsset".
6 |
7 | These files will be deployed with your package and will be accessible using Android's
8 | AssetManager, like this:
9 |
10 | public class ReadAsset : Activity
11 | {
12 | protected override void OnCreate (Bundle bundle)
13 | {
14 | base.OnCreate (bundle);
15 |
16 | InputStream input = Assets.Open ("my_asset.txt");
17 | }
18 | }
19 |
20 | Additionally, some Android functions will automatically load asset files:
21 |
22 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
23 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/Main.Android.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Android.App;
6 | using Android.Content;
7 | using Android.OS;
8 | using Android.Runtime;
9 | using Android.Views;
10 | using Android.Widget;
11 | using Microsoft.UI.Xaml.Media;
12 |
13 | namespace WinUICsMarkupExamples.Droid;
14 |
15 | [global::Android.App.ApplicationAttribute(
16 | Label = "@string/ApplicationName",
17 | Icon = "@mipmap/icon",
18 | LargeHeap = true,
19 | HardwareAccelerated = true,
20 | Theme = "@style/Theme.App.Starting"
21 | )]
22 | public class Application : Microsoft.UI.Xaml.NativeApplication
23 | {
24 | public Application(IntPtr javaReference, JniHandleOwnership transfer)
25 | : base(() => new App(), javaReference, transfer)
26 | {
27 | }
28 |
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/MainActivity.Android.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 | using Android.Views;
5 | using Android.Widget;
6 |
7 | namespace WinUICsMarkupExamples.Droid;
8 |
9 | [Activity(
10 | MainLauncher = true,
11 | ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges,
12 | WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden
13 | )]
14 | public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity
15 | {
16 | protected override void OnCreate(Bundle? savedInstanceState)
17 | {
18 | global::AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen(this);
19 |
20 | base.OnCreate(savedInstanceState);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | To add cross-platform image assets for your Uno Platform app, use the Assets folder
2 | in the shared project instead. Resources in this folder are Android-only.
3 |
4 | Images, layout descriptions, binary blobs and string dictionaries can be included
5 | in your application as resource files. Various Android APIs are designed to
6 | operate on the resource IDs instead of dealing with images, strings or binary blobs
7 | directly.
8 |
9 | For example, a sample Android app that contains a user interface layout (main.axml),
10 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
11 | would keep its resources in the "Resources" directory of the application:
12 |
13 | Resources/
14 | drawable/
15 | icon.png
16 |
17 | layout/
18 | main.axml
19 |
20 | values/
21 | strings.xml
22 |
23 | In order to get the build system to recognize Android resources, set the build action to
24 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
25 | instead operate on resource IDs. When you compile an Android application that uses resources,
26 | the build system will package the resources for distribution and generate a class called "R"
27 | (this is an Android convention) that contains the tokens for each one of the resources
28 | included. For example, for the above Resources layout, this is what the R class would expose:
29 |
30 | public class R {
31 | public class drawable {
32 | public const int icon = 0x123;
33 | }
34 |
35 | public class layout {
36 | public const int main = 0x456;
37 | }
38 |
39 | public class strings {
40 | public const int first_string = 0xabc;
41 | public const int second_string = 0xbcd;
42 | }
43 | }
44 |
45 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
46 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
47 | string in the dictionary file values/strings.xml.
48 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World, Click Me!
4 | WinUICsMarkupExamples
5 |
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/Resources/values/Styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
20 |
21 |
25 |
26 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/environment.conf:
--------------------------------------------------------------------------------
1 | # See this for more details: http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/
2 | MONO_GC_PARAMS=bridge-implementation=new,nursery-size=32m,soft-heap-limit=256m
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Desktop/Program.cs:
--------------------------------------------------------------------------------
1 | using Uno.UI.Hosting;
2 | using WinUICsMarkupExamples;
3 |
4 | internal class Program
5 | {
6 | [STAThread]
7 | public static void Main(string[] args)
8 | {
9 |
10 | var host = UnoPlatformHostBuilder.Create()
11 | .App(() => new App())
12 | .UseX11()
13 | .UseLinuxFrameBuffer()
14 | .UseMacOS()
15 | .UseWin32()
16 | .Build();
17 |
18 | host.Run();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/LinkerConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/Program.cs:
--------------------------------------------------------------------------------
1 | using Uno.UI.Hosting;
2 | using WinUICsMarkupExamples;
3 |
4 | var host = UnoPlatformHostBuilder.Create()
5 | .App(() => new App())
6 | .UseWebAssembly()
7 | .Build();
8 |
9 | await host.RunAsync();
10 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/WasmCSS/Fonts.css:
--------------------------------------------------------------------------------
1 | /**
2 | When adding fonts here, make sure to add them using a base64 data uri, otherwise
3 | fonts loading are delayed, and text may get displayed incorrectly.
4 | */
5 |
6 | /* https://github.com/unoplatform/uno/issues/3954 */
7 | @font-face {
8 | font-family: 'Segoe UI';
9 | src: local('Segoe UI'), local('-apple-system'), local('BlinkMacSystemFont'), local('Inter'), local('Cantarell'), local('Ubuntu'), local('Roboto'), local('Open Sans'), local('Noto Sans'), local('Helvetica Neue'), local('sans-serif');
10 | }
11 |
12 | @font-face {
13 | font-family: 'Roboto';
14 | src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf) format('truetype');
15 | font-weight: 300;
16 | }
17 |
18 | @font-face {
19 | font-family: 'Roboto';
20 | src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf) format('truetype');
21 | font-weight: 400;
22 | }
23 |
24 | @font-face {
25 | font-family: 'Roboto';
26 | src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf) format('truetype');
27 | font-weight: 500;
28 | }
29 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/WasmScripts/AppManifest.js:
--------------------------------------------------------------------------------
1 | var UnoAppManifest = {
2 | displayName: "WinUICsMarkupExamples"
3 | }
4 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/manifest.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "background_color": "#ffffff",
3 | "description": "WinUICsMarkupExamples",
4 | "display": "standalone",
5 | "name": "WinUICsMarkupExamples",
6 | "short_name": "WinUICsMarkupExamples",
7 | "start_url": "/index.html",
8 | "theme_color": "#ffffff",
9 | "scope": "/"
10 | }
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/wwwroot/staticwebapp.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationFallback": {
3 | "rewrite": "/index.html",
4 | "exclude": [
5 | "*.{css,js}",
6 | "*.{png}",
7 | "*.{c,h,wasm,clr,pdb,dat,txt}"
8 | ]
9 | },
10 | "routes": [
11 | {
12 | "route": "/package_*",
13 | "headers": {
14 | "cache-control": "public, immutable, max-age=31536000"
15 | }
16 | },
17 | {
18 | "route": "/*.ttf",
19 | "headers": {
20 | "cache-control": "public, immutable, max-age=31536000"
21 | }
22 | },
23 | {
24 | "route": "/*",
25 | "headers": {
26 | "cache-control": "must-revalidate, max-age=3600"
27 | }
28 | }
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/wwwroot/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | LSRequiresIPhoneOS
6 |
7 | UIDeviceFamily
8 |
9 | 1
10 | 2
11 |
12 | UIRequiredDeviceCapabilities
13 |
14 | armv7
15 | arm64
16 |
17 | UISupportedInterfaceOrientations
18 |
19 | UIInterfaceOrientationPortrait
20 | UIInterfaceOrientationLandscapeLeft
21 | UIInterfaceOrientationLandscapeRight
22 |
23 | UISupportedInterfaceOrientations~ipad
24 |
25 | UIInterfaceOrientationPortrait
26 | UIInterfaceOrientationPortraitUpsideDown
27 | UIInterfaceOrientationLandscapeLeft
28 | UIInterfaceOrientationLandscapeRight
29 |
30 | UIViewControllerBasedStatusBarAppearance
31 |
32 | XSAppIconAssets
33 | Assets.xcassets/icon.appiconset
34 | UIApplicationSupportsIndirectInputEvents
35 |
36 |
37 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/iOS/Main.iOS.cs:
--------------------------------------------------------------------------------
1 | using UIKit;
2 | using Uno.UI.Hosting;
3 | using WinUICsMarkupExamples;
4 |
5 | var host = UnoPlatformHostBuilder.Create()
6 | .App(() => new App())
7 | .UseAppleUIKit()
8 | .Build();
9 |
10 | host.Run();
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/iOS/Media.xcassets/LaunchImages.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "orientation": "portrait",
5 | "extent": "full-screen",
6 | "minimum-system-version": "7.0",
7 | "scale": "2x",
8 | "size": "640x960",
9 | "idiom": "iphone"
10 | },
11 | {
12 | "orientation": "portrait",
13 | "extent": "full-screen",
14 | "minimum-system-version": "7.0",
15 | "subtype": "retina4",
16 | "scale": "2x",
17 | "size": "640x1136",
18 | "idiom": "iphone"
19 | },
20 | {
21 | "orientation": "portrait",
22 | "extent": "full-screen",
23 | "minimum-system-version": "7.0",
24 | "scale": "1x",
25 | "size": "768x1024",
26 | "idiom": "ipad"
27 | },
28 | {
29 | "orientation": "landscape",
30 | "extent": "full-screen",
31 | "minimum-system-version": "7.0",
32 | "scale": "1x",
33 | "size": "1024x768",
34 | "idiom": "ipad"
35 | },
36 | {
37 | "orientation": "portrait",
38 | "extent": "full-screen",
39 | "minimum-system-version": "7.0",
40 | "scale": "2x",
41 | "size": "1536x2048",
42 | "idiom": "ipad"
43 | },
44 | {
45 | "orientation": "landscape",
46 | "extent": "full-screen",
47 | "minimum-system-version": "7.0",
48 | "scale": "2x",
49 | "size": "2048x1536",
50 | "idiom": "ipad"
51 | }
52 | ],
53 | "properties": {},
54 | "info": {
55 | "version": 1,
56 | "author": ""
57 | }
58 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/iOS/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategorySystemBootTime
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | 35F9.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategoryDiskSpace
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | E174.1
29 |
30 |
31 |
32 |
33 |
34 | NSPrivacyAccessedAPIType
35 | NSPrivacyAccessedAPICategoryUserDefaults
36 | NSPrivacyAccessedAPITypeReasons
37 |
38 | CA92.1
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Properties/PublishProfiles/win-arm64.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | FileSystem
8 | arm64
9 | win-arm64
10 | bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
11 | true
12 | False
13 | False
14 | True
15 | False
16 | True
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Properties/PublishProfiles/win-x64.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | FileSystem
8 | x64
9 | win-x64
10 | bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
11 | true
12 | False
13 | False
14 | True
15 | False
16 | True
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Properties/PublishProfiles/win-x86.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | FileSystem
8 | x86
9 | win-x86
10 | bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
11 | true
12 | False
13 | False
14 | True
15 | False
16 | True
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:8080",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | // This profile is first in order for dotnet run to pick it up by default
12 | "WinUICsMarkupExamples (WebAssembly)": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "applicationUrl": "http://localhost:5000",
17 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
18 | "environmentVariables": {
19 | "ASPNETCORE_ENVIRONMENT": "Development"
20 | }
21 | },
22 | "WinUICsMarkupExamples (WebAssembly IIS Express)": {
23 | "commandName": "IISExpress",
24 | "launchBrowser": true,
25 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
26 | "environmentVariables": {
27 | "ASPNETCORE_ENVIRONMENT": "Development"
28 | }
29 | },
30 | // Note: In order to select this profile, you'll need to comment the `Packaged` profile below until this is fixed: https://aka.platform.uno/wasdk-maui-debug-profile-issue
31 | "WinUICsMarkupExamples (WinAppSDK Unpackaged)": {
32 | "commandName": "Project",
33 | "compatibleTargetFramework": "windows"
34 | },
35 | "WinUICsMarkupExamples (WinAppSDK Packaged)": {
36 | "commandName": "MsixPackage",
37 | "compatibleTargetFramework": "windows"
38 | },
39 | "WinUICsMarkupExamples (Desktop)": {
40 | "commandName": "Project",
41 | "compatibleTargetFramework": "desktop"
42 | },
43 | "WinUICsMarkupExamples (Desktop WSL2)": {
44 | "commandName": "WSL2",
45 | "commandLineArgs": "{ProjectDir}/bin/Debug/net9.0-desktop/WinUICsMarkupExamples.dll",
46 | "distributionName": "",
47 | "compatibleTargetFramework": "desktop"
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | Welcome to the Uno Platform!
4 |
5 | To discover how to get started with your new app: https://aka.platform.uno/get-started
6 |
7 | For more information on how to use the Uno.Sdk or upgrade Uno Platform packages in your solution: https://aka.platform.uno/using-uno-sdk
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Styles/ColorPaletteOverride.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Default Uno Material colors",
3 | "seed": "#5946d2",
4 | "coreColors": {
5 | "primary": "#5946d2",
6 | "secondary": "#6b4ea2"
7 | },
8 | "extendedColors": [],
9 | "schemes": {
10 | "light": {
11 | "primary": "#5946d2",
12 | "surfaceTint": "#5946d2",
13 | "onPrimary": "#ffffff",
14 | "primaryContainer": "#e5deff",
15 | "onPrimaryContainer": "#170065",
16 | "secondary": "#6b4ea2",
17 | "onSecondary": "#ffffff",
18 | "secondaryContainer": "#ebddff",
19 | "onSecondaryContainer": "#220555",
20 | "tertiary": "#0061a4",
21 | "onTertiary": "#ffffff",
22 | "tertiaryContainer": "#cfe4ff",
23 | "onTertiaryContainer": "#001d36",
24 | "error": "#b3261e",
25 | "onError": "#ffffff",
26 | "errorContainer": "#f9dedc",
27 | "onErrorContainer": "#410e0b",
28 | "background": "#fcfbff",
29 | "onBackground": "#1c1b1f",
30 | "surface": "#ffffff",
31 | "onSurface": "#1c1b1f",
32 | "surfaceVariant": "#f2eff5",
33 | "onSurfaceVariant": "#8b8494",
34 | "outline": "#79747e",
35 | "outlineVariant": "#c9c5d0",
36 | "shadow": "#000000",
37 | "scrim": "#000000",
38 | "inverseSurface": "#e6e1e5",
39 | "inverseOnSurface": "#1c1b1f",
40 | "inversePrimary": "#2a009f"
41 | },
42 | "dark": {
43 | "primary": "#c7bfff",
44 | "surfaceTint": "#c7bfff",
45 | "onPrimary": "#2a009f",
46 | "primaryContainer": "#4129ba",
47 | "onPrimaryContainer": "#e4dfff",
48 | "secondary": "#cdc2dc",
49 | "onSecondary": "#332d41",
50 | "secondaryContainer": "#433c52",
51 | "onSecondaryContainer": "#eddfff",
52 | "tertiary": "#9fcaff",
53 | "onTertiary": "#003258",
54 | "tertiaryContainer": "#00497d",
55 | "onTertiaryContainer": "#d1e4ff",
56 | "error": "#ffb4ab",
57 | "onError": "#690005",
58 | "errorContainer": "#93000a",
59 | "onErrorContainer": "#ffdad6",
60 | "background": "#1c1b1f",
61 | "onBackground": "#e5e1e6",
62 | "surface": "#302d37",
63 | "onSurface": "#e6e1e5",
64 | "surfaceVariant": "#47464f",
65 | "onSurfaceVariant": "#c9c5d0",
66 | "outline": "#928f99",
67 | "outlineVariant": "#57545d",
68 | "shadow": "#000000",
69 | "scrim": "#000000",
70 | "inverseSurface": "#e6e1e5",
71 | "inverseOnSurface": "#1c1b1f",
72 | "inversePrimary": "#2a009f"
73 | }
74 | },
75 | "palettes": {}
76 | }
77 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Styles/ColorPaletteOverride.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #5946D2
6 | #FFFFFF
7 | #E5DEFF
8 | #170065
9 | #6B4EA2
10 | #FFFFFF
11 | #EBDDFF
12 | #220555
13 | #0061A4
14 | #FFFFFF
15 | #CFE4FF
16 | #001D36
17 | #B3261E
18 | #F9DEDC
19 | #FFFFFF
20 | #410E0B
21 | #FCFBFF
22 | #1C1B1F
23 | #FFFFFF
24 | #1C1B1F
25 | #F2EFF5
26 | #8B8494
27 | #79747E
28 | #F4EFF4
29 | #313033
30 | #C8BFFF
31 | #5946D2
32 | #C9C5D0
33 |
34 |
35 | #C7BFFF
36 | #2A009F
37 | #4129BA
38 | #E4DFFF
39 | #CDC2DC
40 | #332D41
41 | #433C52
42 | #EDDFFF
43 | #9FCAFF
44 | #003258
45 | #00497D
46 | #D1E4FF
47 | #FFB4AB
48 | #93000A
49 | #690005
50 | #FFDAD6
51 | #1C1B1F
52 | #E5E1E6
53 | #302D37
54 | #E6E1E5
55 | #47464F
56 | #C9C5D0
57 | #928F99
58 | #1C1B1F
59 | #E6E1E5
60 | #2A009F
61 | #C7BFFF
62 | #57545D
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Styles/Example.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
34 |
35 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/WinUICsMarkupExamples.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net9.0-android;net9.0-ios;net9.0-windows10.0.26100;net9.0-browserwasm;net9.0-desktop
7 |
8 | Exe
9 | true
10 |
11 |
12 | WinUICsMarkupExamples
13 |
14 | com.companyname.winuicsmarkupexamples
15 |
16 | 1.0
17 | 1
18 |
19 | WinUICsMarkupExamples
20 |
21 | WinUICsMarkupExamples powered by Uno Platform.
22 |
32 |
33 |
34 |
38 |
39 | Material;
40 | Dsp;
41 | Hosting;
42 | Toolkit;
43 | Logging;
44 | Mvvm;
45 | Configuration;
46 | HttpKiota;
47 | Serialization;
48 | Localization;
49 | Navigation;
50 | ThemeService;
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
21 | true/PM
22 | PerMonitorV2, PerMonitor
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/appsettings.development.json:
--------------------------------------------------------------------------------
1 | {
2 | "AppConfig": {
3 | "Environment": "Development"
4 | },
5 | "ApiClient": {
6 | "Url": "https://localhost:5002",
7 | "UseNativeHandler": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "AppConfig": {
3 | "Environment": "Production"
4 | },
5 | "ApiClient": {
6 | "UseNativeHandler": true
7 | },
8 | "LocalizationConfiguration": {
9 | "Cultures": [
10 | "es",
11 | "fr",
12 | "pt-BR",
13 | "en"
14 | ]
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [LiveChartsCore.SkiaSharpView.Uno](https://www.nuget.org/packages/LiveChartsCore.SkiaSharpView.Uno) NuGet
2 |
3 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
4 | - Build .NET applications **fully in C#**
5 | - Target browsers and native desktop / mobile
6 |
7 | No XAML / HTML / JavaScript / CSS required
8 |
9 | This release targets WinUI 3 (Windows App SDK) and Uno Platform - including browser webassembly - with C# 13 and .NET 8.
10 |
11 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
12 |
13 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
14 |
15 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView/_Helpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xaml = Microsoft.UI.Xaml;
3 | #if GENERATE
4 | using CSharpMarkup.Generate.WinUI;
5 | using Controls = Microsoft.UI.Xaml.Controls;
6 |
7 | [assembly: MarkupHelpers(
8 | markupHelpersType: typeof(CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView
13 | {
14 | public static partial class Helpers
15 | {
16 |
17 | #if GENERATE
18 | /// Used by codegen to generate a implementation on markup types. Not used at runtime.
19 | /// Types must be fully specified for codegen to work
20 | static Xaml.DependencyProperty[] DefaultBindProperties => new Xaml.DependencyProperty[]
21 | {
22 | // Microsoft.UI.Xaml.Controls.AutoSuggestBox.TextProperty,
23 | };
24 |
25 | ///
26 | /// Used by codegen to identify which assemblies to scan for UI types.
27 | /// Markup types will be generated for these UI types (e.g. controls).
28 | ///
29 | static Type[] UIAssemblies => new Type[] // Assemblies in UI NuGets that contain UI types
30 | {
31 | typeof(global::LiveChartsCore.SkiaSharpView.WinUI.PieChart)
32 | };
33 | #endif
34 | }
35 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET8_0_ANDROID.cs:
--------------------------------------------------------------------------------
1 | // Start of generated C# Markup API for Uno.WinUI
2 | #if NET8_0 && __ANDROID__
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Numerics;
7 | using System.Windows.Input;
8 | using System.Runtime.Versioning;
9 | using Microsoft;
10 | using CSharpMarkup.WinUI.GeneratedCodeUtilities;
11 | using UI = Microsoft.UI;
12 | using Collections = System.Collections;
13 | using Xaml = Microsoft.UI.Xaml;
14 | using VirtualKey = Windows.System.VirtualKey;
15 | using VirtualKeyModifiers = Windows.System.VirtualKeyModifiers;
16 | using Drawing = System.Drawing;
17 | using UnoExtensionsNavigationToolkit = Uno.Extensions.Navigation.Toolkit;
18 |
19 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit // ModalFlyout
20 | {
21 | public static partial class Helpers
22 | {
23 | /// Create a
24 | public static ModalFlyout ModalFlyout(Xaml.UIElement Content)
25 | {
26 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
27 | if (Content != null) ui.Content = Content;
28 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
29 | }
30 |
31 | /// Create a
32 | public static ModalFlyout ModalFlyout()
33 | {
34 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
35 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
36 | }
37 | }
38 |
39 | public partial class ModalFlyout : Flyout, IUI
40 | {
41 | static ModalFlyout instance;
42 |
43 | internal static ModalFlyout StartChain(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui)
44 | {
45 | if (instance == null) instance = new ModalFlyout();
46 | instance.UI = ui;
47 | return instance;
48 | }
49 |
50 | UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui;
51 |
52 | public new UnoExtensionsNavigationToolkit.Controls.ModalFlyout UI
53 | {
54 | get => ui;
55 | protected set => base.UI = ui = value;
56 | }
57 |
58 | public static implicit operator UnoExtensionsNavigationToolkit.Controls.ModalFlyout(ModalFlyout view) => view?.UI;
59 |
60 | public static implicit operator ModalFlyout(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui) => ModalFlyout.StartChain(ui);
61 |
62 | public ModalFlyout Invoke(Action action) { action?.Invoke(UI); return this; }
63 |
64 | protected ModalFlyout() { }
65 | }
66 | }
67 |
68 |
69 | #endif
70 | // End of generated C# Markup API for Uno.WinUI
71 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET8_0_IOS.cs:
--------------------------------------------------------------------------------
1 | // Start of generated C# Markup API for Uno.WinUI
2 | #if NET8_0 && __IOS__ && !__MACCATALYST__
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Numerics;
7 | using System.Windows.Input;
8 | using System.Runtime.Versioning;
9 | using Microsoft;
10 | using CSharpMarkup.WinUI.GeneratedCodeUtilities;
11 | using UI = Microsoft.UI;
12 | using Collections = System.Collections;
13 | using Xaml = Microsoft.UI.Xaml;
14 | using VirtualKey = Windows.System.VirtualKey;
15 | using VirtualKeyModifiers = Windows.System.VirtualKeyModifiers;
16 | using Drawing = System.Drawing;
17 | using UnoExtensionsNavigationToolkit = Uno.Extensions.Navigation.Toolkit;
18 |
19 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit // ModalFlyout
20 | {
21 | public static partial class Helpers
22 | {
23 | /// Create a
24 | public static ModalFlyout ModalFlyout(Xaml.UIElement Content)
25 | {
26 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
27 | if (Content != null) ui.Content = Content;
28 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
29 | }
30 |
31 | /// Create a
32 | public static ModalFlyout ModalFlyout()
33 | {
34 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
35 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
36 | }
37 | }
38 |
39 | public partial class ModalFlyout : Flyout, IUI
40 | {
41 | static ModalFlyout instance;
42 |
43 | internal static ModalFlyout StartChain(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui)
44 | {
45 | if (instance == null) instance = new ModalFlyout();
46 | instance.UI = ui;
47 | return instance;
48 | }
49 |
50 | UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui;
51 |
52 | public new UnoExtensionsNavigationToolkit.Controls.ModalFlyout UI
53 | {
54 | get => ui;
55 | protected set => base.UI = ui = value;
56 | }
57 |
58 | public static implicit operator UnoExtensionsNavigationToolkit.Controls.ModalFlyout(ModalFlyout view) => view?.UI;
59 |
60 | public static implicit operator ModalFlyout(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui) => ModalFlyout.StartChain(ui);
61 |
62 | public ModalFlyout Invoke(Action action) { action?.Invoke(UI); return this; }
63 |
64 | protected ModalFlyout() { }
65 | }
66 | }
67 |
68 |
69 | #endif
70 | // End of generated C# Markup API for Uno.WinUI
71 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET8_0_MACCATALYST.cs:
--------------------------------------------------------------------------------
1 | // Start of generated C# Markup API for Uno.WinUI
2 | #if NET8_0 && __MACCATALYST__
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Numerics;
7 | using System.Windows.Input;
8 | using System.Runtime.Versioning;
9 | using Microsoft;
10 | using CSharpMarkup.WinUI.GeneratedCodeUtilities;
11 | using UI = Microsoft.UI;
12 | using Collections = System.Collections;
13 | using Xaml = Microsoft.UI.Xaml;
14 | using VirtualKey = Windows.System.VirtualKey;
15 | using VirtualKeyModifiers = Windows.System.VirtualKeyModifiers;
16 | using Drawing = System.Drawing;
17 | using UnoExtensionsNavigationToolkit = Uno.Extensions.Navigation.Toolkit;
18 |
19 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit // ModalFlyout
20 | {
21 | public static partial class Helpers
22 | {
23 | /// Create a
24 | public static ModalFlyout ModalFlyout(Xaml.UIElement Content)
25 | {
26 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
27 | if (Content != null) ui.Content = Content;
28 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
29 | }
30 |
31 | /// Create a
32 | public static ModalFlyout ModalFlyout()
33 | {
34 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
35 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
36 | }
37 | }
38 |
39 | public partial class ModalFlyout : Flyout, IUI
40 | {
41 | static ModalFlyout instance;
42 |
43 | internal static ModalFlyout StartChain(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui)
44 | {
45 | if (instance == null) instance = new ModalFlyout();
46 | instance.UI = ui;
47 | return instance;
48 | }
49 |
50 | UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui;
51 |
52 | public new UnoExtensionsNavigationToolkit.Controls.ModalFlyout UI
53 | {
54 | get => ui;
55 | protected set => base.UI = ui = value;
56 | }
57 |
58 | public static implicit operator UnoExtensionsNavigationToolkit.Controls.ModalFlyout(ModalFlyout view) => view?.UI;
59 |
60 | public static implicit operator ModalFlyout(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui) => ModalFlyout.StartChain(ui);
61 |
62 | public ModalFlyout Invoke(Action action) { action?.Invoke(UI); return this; }
63 |
64 | protected ModalFlyout() { }
65 | }
66 | }
67 |
68 |
69 | #endif
70 | // End of generated C# Markup API for Uno.WinUI
71 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/UnoWinUI.NET8_0_WasmOrSkia.cs:
--------------------------------------------------------------------------------
1 | // Start of generated C# Markup API for Uno.WinUI
2 | #if NET8_0 && __WASM_OR_SKIA__ && !DESKTOP && !BROWSERWASM
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Numerics;
7 | using System.Windows.Input;
8 | using System.Runtime.Versioning;
9 | using Microsoft;
10 | using CSharpMarkup.WinUI.GeneratedCodeUtilities;
11 | using UI = Microsoft.UI;
12 | using Collections = System.Collections;
13 | using Xaml = Microsoft.UI.Xaml;
14 | using VirtualKey = Windows.System.VirtualKey;
15 | using VirtualKeyModifiers = Windows.System.VirtualKeyModifiers;
16 | using Drawing = System.Drawing;
17 | using UnoExtensionsNavigationToolkit = Uno.Extensions.Navigation.Toolkit;
18 |
19 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit // ModalFlyout
20 | {
21 | public static partial class Helpers
22 | {
23 | /// Create a
24 | public static ModalFlyout ModalFlyout(Xaml.UIElement Content)
25 | {
26 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
27 | if (Content != null) ui.Content = Content;
28 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
29 | }
30 |
31 | /// Create a
32 | public static ModalFlyout ModalFlyout()
33 | {
34 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
35 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
36 | }
37 | }
38 |
39 | public partial class ModalFlyout : Flyout, IUI
40 | {
41 | static ModalFlyout instance;
42 |
43 | internal static ModalFlyout StartChain(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui)
44 | {
45 | if (instance == null) instance = new ModalFlyout();
46 | instance.UI = ui;
47 | return instance;
48 | }
49 |
50 | UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui;
51 |
52 | public new UnoExtensionsNavigationToolkit.Controls.ModalFlyout UI
53 | {
54 | get => ui;
55 | protected set => base.UI = ui = value;
56 | }
57 |
58 | public static implicit operator UnoExtensionsNavigationToolkit.Controls.ModalFlyout(ModalFlyout view) => view?.UI;
59 |
60 | public static implicit operator ModalFlyout(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui) => ModalFlyout.StartChain(ui);
61 |
62 | public ModalFlyout Invoke(Action action) { action?.Invoke(UI); return this; }
63 |
64 | protected ModalFlyout() { }
65 | }
66 | }
67 |
68 |
69 | #endif
70 | // End of generated C# Markup API for Uno.WinUI
71 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/Generated/SourceGenerators/SourceGenerators.CsMarkupApiSourceGenerator/WinUI.NET8_0_WinAppSdk.cs:
--------------------------------------------------------------------------------
1 | // Start of generated C# Markup API for Microsoft.WindowsAppSDK
2 | #if NET8_0 && WINUI
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Numerics;
7 | using System.Windows.Input;
8 | using System.Runtime.Versioning;
9 | using Microsoft;
10 | using CSharpMarkup.WinUI.GeneratedCodeUtilities;
11 | using UI = Microsoft.UI;
12 | using Collections = System.Collections;
13 | using Xaml = Microsoft.UI.Xaml;
14 | using VirtualKey = Windows.System.VirtualKey;
15 | using VirtualKeyModifiers = Windows.System.VirtualKeyModifiers;
16 | using Drawing = System.Drawing;
17 | using UnoExtensionsNavigationToolkit = Uno.Extensions.Navigation.Toolkit;
18 |
19 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit // ModalFlyout
20 | {
21 | public static partial class Helpers
22 | {
23 | /// Create a
24 | public static ModalFlyout ModalFlyout(Xaml.UIElement Content)
25 | {
26 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
27 | if (Content != null) ui.Content = Content;
28 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
29 | }
30 |
31 | /// Create a
32 | public static ModalFlyout ModalFlyout()
33 | {
34 | var ui = new UnoExtensionsNavigationToolkit.Controls.ModalFlyout();
35 | return CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.ModalFlyout.StartChain(ui);
36 | }
37 | }
38 |
39 | public partial class ModalFlyout : Flyout, IUI
40 | {
41 | static ModalFlyout instance;
42 |
43 | internal static ModalFlyout StartChain(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui)
44 | {
45 | if (instance == null) instance = new ModalFlyout();
46 | instance.UI = ui;
47 | return instance;
48 | }
49 |
50 | UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui;
51 |
52 | public new UnoExtensionsNavigationToolkit.Controls.ModalFlyout UI
53 | {
54 | get => ui;
55 | protected set => base.UI = ui = value;
56 | }
57 |
58 | public static implicit operator UnoExtensionsNavigationToolkit.Controls.ModalFlyout(ModalFlyout view) => view?.UI;
59 |
60 | public static implicit operator ModalFlyout(UnoExtensionsNavigationToolkit.Controls.ModalFlyout ui) => ModalFlyout.StartChain(ui);
61 |
62 | public ModalFlyout Invoke(Action action) { action?.Invoke(UI); return this; }
63 |
64 | protected ModalFlyout() { }
65 | }
66 | }
67 |
68 |
69 | #endif
70 | // End of generated C# Markup API for Microsoft.WindowsAppSDK
71 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [Uno.Extensions.Navigation.Toolkit.WinUI](https://www.nuget.org/packages/Uno.Extensions.Navigation.Toolkit.WinUI) NuGet
2 |
3 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
4 | - Build .NET applications **fully in C#**
5 | - Target browsers and native desktop / mobile
6 |
7 | No XAML / HTML / JavaScript / CSS required
8 |
9 | This release targets WinUI 3 (Windows App SDK) and Uno Platform - including browser webassembly - with C# 13 and .NET 8.
10 |
11 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
12 |
13 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
14 |
15 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/_Helpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xaml = Microsoft.UI.Xaml;
3 | #if GENERATE
4 | using CSharpMarkup.Generate.WinUI;
5 | using Controls = Microsoft.UI.Xaml.Controls;
6 |
7 | [assembly: MarkupHelpers(
8 | markupHelpersType: typeof(CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit
13 | {
14 | public static partial class Helpers
15 | {
16 | #if GENERATE
17 | /// Used by codegen to generate a implementation on markup types. Not used at runtime.
18 | /// Types must be fully specified for codegen to work
19 | static Xaml.DependencyProperty[] DefaultBindProperties => new Xaml.DependencyProperty[]
20 | {
21 | // Microsoft.UI.Xaml.Controls.AutoSuggestBox.TextProperty,
22 | };
23 |
24 | ///
25 | /// Used by codegen to identify which assemblies to scan for UI types.
26 | /// Markup types will be generated for these UI types (e.g. controls).
27 | ///
28 | static Type[] UIAssemblies => new Type[] // Assemblies in NuGet Uno.Toolkit.WinUI that contain UI types
29 | {
30 | typeof(global::Uno.Extensions.Navigation.Toolkit.Controls.ModalFlyout)
31 | };
32 | #endif
33 | }
34 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Uno.Sdk": "6.0.96"
4 | },
5 | "sdk": {
6 | "version": "9.0.300",
7 | "rollForward": "latestPatch"
8 | }
9 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [Uno.Extensions.Navigation.WinUI](https://www.nuget.org/packages/Uno.Extensions.Navigation.WinUI) NuGet
2 |
3 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
4 | - Build .NET applications **fully in C#**
5 | - Target browsers and native desktop / mobile
6 |
7 | No XAML / HTML / JavaScript / CSS required
8 |
9 | This release targets WinUI 3 (Windows App SDK) and Uno Platform - including browser webassembly - with C# 13 and .NET 8.
10 |
11 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
12 |
13 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
14 |
15 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation/_Helpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xaml = Microsoft.UI.Xaml;
3 | #if GENERATE
4 | using CSharpMarkup.Generate.WinUI;
5 | using Controls = Microsoft.UI.Xaml.Controls;
6 |
7 | [assembly: MarkupHelpers(
8 | markupHelpersType: typeof(CSharpMarkup.WinUI.Uno.Extensions.Navigation.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.Uno.Extensions.Navigation
13 | {
14 | public static partial class Helpers
15 | {
16 | #if GENERATE
17 | /// Used by codegen to generate a implementation on markup types. Not used at runtime.
18 | /// Types must be fully specified for codegen to work
19 | static Xaml.DependencyProperty[] DefaultBindProperties => new Xaml.DependencyProperty[]
20 | {
21 | // Microsoft.UI.Xaml.Controls.AutoSuggestBox.TextProperty,
22 | };
23 |
24 | ///
25 | /// Used by codegen to identify which assemblies to scan for UI types.
26 | /// Markup types will be generated for these UI types (e.g. controls).
27 | ///
28 | static Type[] UIAssemblies => new Type[] // Assemblies in NuGet Uno.Toolkit.WinUI that contain UI types
29 | {
30 | typeof(global::Uno.Extensions.Navigation.UI.Region)
31 | };
32 | #endif
33 | }
34 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Navigation/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Uno.Sdk": "6.0.96"
4 | },
5 | "sdk": {
6 | "version": "9.0.300",
7 | "rollForward": "latestPatch"
8 | }
9 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Reactive/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [Uno.Extensions.Reactive.WinUI](https://www.nuget.org/packages/Uno.Extensions.Reactive.WinUI) NuGet
2 |
3 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
4 | - Build .NET applications **fully in C#**
5 | - Target browsers and native desktop / mobile
6 |
7 | No XAML / HTML / JavaScript / CSS required
8 |
9 | This release targets WinUI 3 (Windows App SDK) and Uno Platform - including browser webassembly - with C# 13 and .NET 8.
10 |
11 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
12 |
13 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
14 |
15 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Reactive/_Helpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xaml = Microsoft.UI.Xaml;
3 | #if GENERATE
4 | using CSharpMarkup.Generate.WinUI;
5 | using Controls = Microsoft.UI.Xaml.Controls;
6 |
7 | [assembly: MarkupHelpers(
8 | markupHelpersType: typeof(CSharpMarkup.WinUI.Uno.Extensions.Reactive.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.Uno.Extensions.Reactive
13 | {
14 | public static partial class Helpers
15 | {
16 | #if GENERATE
17 | /// Used by codegen to generate a implementation on markup types. Not used at runtime.
18 | /// Types must be fully specified for codegen to work
19 | static Xaml.DependencyProperty[] DefaultBindProperties => new Xaml.DependencyProperty[]
20 | {
21 | // Microsoft.UI.Xaml.Controls.AutoSuggestBox.TextProperty,
22 | };
23 |
24 | ///
25 | /// Used by codegen to identify which assemblies to scan for UI types.
26 | /// Markup types will be generated for these UI types (e.g. controls).
27 | ///
28 | static Type[] UIAssemblies => new Type[] // Assemblies in NuGet Uno.Extensions.Reactive.WinUI that contain UI types
29 | {
30 | typeof(global::Uno.Extensions.Reactive.UI.FeedView)
31 | };
32 | #endif
33 | }
34 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Extensions.Reactive/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Uno.Sdk": "6.0.96"
4 | },
5 | "sdk": {
6 | "version": "9.0.300",
7 | "rollForward": "latestPatch"
8 | }
9 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Toolkit/CSharpMarkup.WinUI.Uno.Toolkit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug;Release;Generate
4 | true
5 |
6 |
7 | true
8 | true
9 |
10 |
11 |
12 | CSharpMarkup.WinUI.Uno.Toolkit
13 | CSharpMarkup.WinUI.Uno.Toolkit
14 | Build .NET browser / native UI in declarative C#
15 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and WinUI 3, using Windows App SDK and/or Uno Platform. Build .NET applications fully in C#. Target browsers and native desktop / mobile. No XAML / HTML / JavaScript / CSS required
16 | Readme.md
17 | csharpformarkup,csharpmarkup,markup,csharp,ui,winui,windowsappsdk,uno,webassembly,windows,desktop,flutter
18 | Copyright © VincentH.NET
19 | MIT
20 | VincentH.NET
21 | VincentH.NET
22 | https://github.com/VincentH-Net/CSharpForMarkup
23 | https://github.com/VincentH-Net/CSharpForMarkup
24 | See source repository for release notes
25 | false
26 | git
27 | $(AssemblyName) ($(TargetFramework))
28 | $(CSharpMarkupVersion)
29 | en
30 |
31 | CS1591;CS1573;Uno0001
32 |
33 | true
34 | true
35 |
36 |
37 | true
38 | true
39 | snupkg
40 |
41 | portable
42 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb;.xml
43 | true
44 |
45 |
46 |
47 | net8.0-windows10.0.19041.0;net8.0;net8.0-android34.0;net8.0-ios18.0;net8.0-maccatalyst18.0
48 | CSharpMarkup.WinUI.Uno.Toolkit
49 | false
50 |
51 |
52 |
53 | true
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Analyzer
65 | false
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Toolkit/NavigationBar.cs:
--------------------------------------------------------------------------------
1 | #if !GENERATE
2 | using UnoToolkitUI = Uno.Toolkit.UI;
3 |
4 | namespace CSharpMarkup.WinUI.Uno.Toolkit
5 | {
6 | public static partial class Helpers
7 | {
8 | /// Create a with
9 | public static NavigationBar NavigationBar(UIObject Content, params CommandBarElement[] PrimaryCommands)
10 | {
11 | var bar = NavigationBar(PrimaryCommands);
12 | bar.UI.Content = Content.UI;
13 | return bar;
14 | }
15 | }
16 |
17 | public static partial class NavigationBarExtensions
18 | {
19 | /// Set
20 | public static TView SecondaryCommands(this TView view, params CommandBarElement[] SecondaryCommands) where TView : NavigationBar
21 | {
22 | // TODO: Add support to generate non-primary collection type properties setters - taking care not to allow chain breaking;
23 | // below code is currently only generated for the primary children of layouts in helpers, not in property setters.
24 | // For now, code the rare case where this occurs and is safe wrt chain breaking (meaning nested subchains of the same type
25 | // as a parent chain cannot occur) manually, like below.
26 | var ui = view.UI;
27 | for (int i = 0; i < SecondaryCommands.Length; i++)
28 | {
29 | var child = SecondaryCommands[i];
30 | if (child == null) continue;
31 |
32 | var subChildren = Spreader.ExtractChildren(child);
33 | if (subChildren is not null)
34 | for (int j = 0; j < subChildren.Length; j++)
35 | ui.SecondaryCommands.Add(subChildren[j].UI);
36 | else
37 | ui.SecondaryCommands.Add(child.UI);
38 | }
39 | return view;
40 | }
41 | }
42 | }
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Toolkit/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [Uno.Toolkit.WinUI](https://www.nuget.org/packages/Uno.Toolkit.WinUI) NuGet
2 |
3 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
4 | - Build .NET applications **fully in C#**
5 | - Target browsers and native desktop / mobile
6 |
7 | No XAML / HTML / JavaScript / CSS required
8 |
9 | This release targets WinUI 3 (Windows App SDK) and Uno Platform - including browser webassembly - with C# 13 and .NET 8.
10 |
11 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
12 |
13 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
14 |
15 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Toolkit/_Helpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xaml = Microsoft.UI.Xaml;
3 | #if GENERATE
4 | using CSharpMarkup.Generate.WinUI;
5 | using Controls = Microsoft.UI.Xaml.Controls;
6 |
7 | [assembly: MarkupHelpers(
8 | markupHelpersType: typeof(CSharpMarkup.WinUI.Uno.Toolkit.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.Uno.Toolkit
13 | {
14 | public static partial class Helpers
15 | {
16 | #if GENERATE
17 | /// Used by codegen to generate a implementation on markup types. Not used at runtime.
18 | /// Types must be fully specified for codegen to work
19 | static Xaml.DependencyProperty[] DefaultBindProperties => new Xaml.DependencyProperty[]
20 | {
21 | // Microsoft.UI.Xaml.Controls.AutoSuggestBox.TextProperty,
22 | };
23 |
24 | ///
25 | /// Used by codegen to identify which assemblies to scan for UI types.
26 | /// Markup types will be generated for these UI types (e.g. controls).
27 | ///
28 | static Type[] UIAssemblies => new Type[] // Assemblies in NuGet Uno.Toolkit.WinUI that contain UI types
29 | {
30 | typeof(global::Uno.Toolkit.UI.ToolkitResources)
31 | };
32 | #endif
33 | }
34 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Toolkit/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/Attributes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | ///
6 | /// Apply to a helper method that is shorthand for a (sequence of) other helpers, e.g. [ShortFor("HorizontalAlignment().Left()")]
on a Left()
helper.
7 | /// Specify multiple sequences if the helper method is shorthand for a combination of helper sequences, e.g. [ShortFor("HorizontalAlignment().Center()", "VerticalAlignment().Center()")]
on a Center()
helper.
8 | ///
9 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
10 | public class ShortForAttribute : Attribute
11 | {
12 | public ShortForAttribute(params string[] helperSequences) { HelperSequences = helperSequences; }
13 | public string[] HelperSequences { get; }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/CSharpMarkup.WinUI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug;Release;Generate
4 |
5 |
6 |
7 | CSharpMarkup.WinUI
8 | CSharpMarkup.WinUI
9 | Build .NET browser / native UI in declarative C#
10 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and WinUI 3, using Windows App SDK and/or Uno Platform. Build .NET applications fully in C#. Target browsers and native desktop / mobile. No XAML / HTML / JavaScript / CSS required
11 | Readme.md
12 | csharpformarkup,csharpmarkup,markup,csharp,ui,winui,windowsappsdk,uno,webassembly,windows,desktop,flutter
13 | Copyright © VincentH.NET
14 | MIT
15 | VincentH.NET
16 | VincentH.NET
17 | https://github.com/VincentH-Net/CSharpForMarkup
18 | https://github.com/VincentH-Net/CSharpForMarkup
19 | See source repository for release notes
20 | false
21 | git
22 | $(AssemblyName) ($(TargetFramework))
23 | $(CSharpMarkupVersion)
24 | en
25 |
26 | CS1591;CS1573;Uno0001
27 |
28 | true
29 | true
30 |
31 |
32 | true
33 | true
34 | snupkg
35 |
36 | portable
37 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb;.xml
38 | true
39 |
40 |
41 |
42 | CSharpMarkup.WinUI
43 | $(CSharpMarkupWinUITargetFrameworks)
44 | false
45 |
46 |
47 |
48 | true
49 |
50 |
51 | true
52 | true
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Analyzer
70 | false
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/CSharpMarkup.WinUI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.31911.260
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpMarkup.WinUI", "CSharpMarkup.WinUI.csproj", "{27B1A0CA-6F64-4778-A663-55EF5F6E2022}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Generate|Any CPU = Generate|Any CPU
12 | Release|Any CPU = Release|Any CPU
13 | EndGlobalSection
14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
15 | {27B1A0CA-6F64-4778-A663-55EF5F6E2022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16 | {27B1A0CA-6F64-4778-A663-55EF5F6E2022}.Debug|Any CPU.Build.0 = Debug|Any CPU
17 | {27B1A0CA-6F64-4778-A663-55EF5F6E2022}.Generate|Any CPU.ActiveCfg = Generate|Any CPU
18 | {27B1A0CA-6F64-4778-A663-55EF5F6E2022}.Generate|Any CPU.Build.0 = Generate|Any CPU
19 | {27B1A0CA-6F64-4778-A663-55EF5F6E2022}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {27B1A0CA-6F64-4778-A663-55EF5F6E2022}.Release|Any CPU.Build.0 = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(SolutionProperties) = preSolution
23 | HideSolutionNode = FALSE
24 | EndGlobalSection
25 | GlobalSection(ExtensibilityGlobals) = postSolution
26 | SolutionGuid = {54A6D6D9-D799-485B-A8DC-6DB648B045A6}
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/CommandBarElement.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 |
3 | namespace CSharpMarkup.WinUI;
4 |
5 | public class CommandBarElement : IAnyUI
6 | {
7 | public Xaml.Controls.ICommandBarElement UI { get; }
8 |
9 | public static implicit operator CommandBarElement(AppBarButton e) => new (e.UI);
10 | public static implicit operator CommandBarElement(AppBarElementContainer e) => new (e.UI);
11 | public static implicit operator CommandBarElement(AppBarSeparator e) => new (e.UI);
12 | public static implicit operator CommandBarElement(AppBarToggleButton e) => new (e.UI);
13 |
14 | public CommandBarElement(Xaml.Controls.ICommandBarElement ui) => this.UI = ui;
15 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/CompileTests/TestModel.cs:
--------------------------------------------------------------------------------
1 | #if DEBUG
2 | namespace CompileTests
3 | {
4 | public partial class TestViewModel
5 | {
6 | public string Title { get; set; }
7 | public bool Right { get; set; }
8 | public bool IsOk { get; set; }
9 | public string Avatar { get; set; }
10 |
11 | public int Columns { get; set; }
12 | }
13 | }
14 | #endif
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/CompileTests/TestPage.logic.cs:
--------------------------------------------------------------------------------
1 | #if DEBUG
2 | using Microsoft.UI.Xaml.Controls;
3 | using static Microsoft.UI.Colors;
4 | using Color = Windows.UI.Color;
5 | using Markup = CSharpMarkup.WinUI;
6 | using UI = Microsoft.UI.Xaml;
7 |
8 | namespace CompileTests
9 | {
10 | partial class TestPage : Page
11 | {
12 | TestViewModel vm = new();
13 |
14 | Button button;
15 | readonly Markup.FuncConverter okBrushConverter;
16 |
17 | public TestPage()
18 | {
19 | okBrushConverter = new (OkBrush);
20 | // Set viewmodel and set content to markup here
21 | }
22 |
23 | UI.Media.Brush OkBrush(bool isOk) => new UI.Media.SolidColorBrush(OkColor(isOk));
24 |
25 | Color OkColor(bool isOk) => isOk ? Green : Red;
26 | }
27 | }
28 | #endif
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/Control.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | public static partial class Helpers
6 | {
7 | ///Short for:.HorizontalContentAlignment().Left()
8 | [ShortFor("HorizontalContentAlignment().Left()")]
9 | public static TControl LeftContent(this TControl control) where TControl : Control
10 | { control.UI.HorizontalContentAlignment = Xaml.HorizontalAlignment.Left; return control; }
11 |
12 | ///Short for:.HorizontalContentAlignment().Center()
13 | [ShortFor("HorizontalContentAlignment().Center()")]
14 | public static TControl HCenterContent(this TControl control) where TControl : Control
15 | { control.UI.HorizontalContentAlignment = Xaml.HorizontalAlignment.Center; return control; }
16 |
17 | ///Short for:.HorizontalContentAlignment().Right()
18 | [ShortFor("HorizontalContentAlignment().Right()")]
19 | public static TControl RightContent(this TControl control) where TControl : Control
20 | { control.UI.HorizontalContentAlignment = Xaml.HorizontalAlignment.Right; return control; }
21 |
22 | ///Short for:.VerticalContentAlignment().Top()
23 | [ShortFor("VerticalContentAlignment().Top()")]
24 | public static TControl TopContent(this TControl control) where TControl : Control
25 | { control.UI.VerticalContentAlignment = Xaml.VerticalAlignment.Top; return control; }
26 |
27 | ///Short for:.VerticalContentAlignment().Center()
28 | [ShortFor("VerticalContentAlignment().Center()")]
29 | public static TControl VCenterContent(this TControl control) where TControl : Control
30 | { control.UI.VerticalContentAlignment = Xaml.VerticalAlignment.Center; return control; }
31 |
32 | ///Short for:.VerticalContentAlignment().Bottom()
33 | [ShortFor("VerticalContentAlignment().Bottom()")]
34 | public static TControl BottomContent(this TControl control) where TControl : Control
35 | { control.UI.VerticalContentAlignment = Xaml.VerticalAlignment.Bottom; return control; }
36 |
37 | ///Short for:HorizontalContentAlignment().Center() .VerticalContentAlignment().Center()
38 | [ShortFor("HorizontalContentAlignment().Center() .VerticalContentAlignment().Center()")]
39 | public static TControl CenterContent(this TControl control) where TControl : Control
40 | { control.UI.HorizontalContentAlignment = Xaml.HorizontalAlignment.Center; control.UI.VerticalContentAlignment = Xaml.VerticalAlignment.Center; return control; }
41 |
42 | ///Short for:HorizontalContentAlignment().Stretch() .VerticalContentAlignment().Stretch()
43 | [ShortFor("HorizontalContentAlignment().Stretch() .VerticalContentAlignment().Stretch()")]
44 | public static TControl StretchContent(this TControl control) where TControl : Control
45 | { control.UI.HorizontalContentAlignment = Xaml.HorizontalAlignment.Stretch; control.UI.VerticalContentAlignment = Xaml.VerticalAlignment.Stretch; return control; }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/DefaultBindProperties.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 | using Controls = Microsoft.UI.Xaml.Controls;
3 |
4 | namespace CSharpMarkup.WinUI
5 | {
6 | public interface IDefaultBindProperty // TODO: Generate this automatically if only one possibility
7 | {
8 | Xaml.DependencyProperty DefaultBindProperty { get; }
9 | }
10 |
11 | public interface IDefaultBindCommandProperties // TODO: Generate this automatically if only one possibility, and from helpers where specified (if needed) ? only if there is a property CommandParameterProperty and CommandProperty?
12 | {
13 | Xaml.DependencyProperty DefaultBindCommandProperty { get; }
14 | Xaml.DependencyProperty DefaultBindCommandParameterProperty { get; }
15 | }
16 |
17 | public partial class MenuFlyoutItem : IDefaultBindCommandProperties
18 | {
19 | public Xaml.DependencyProperty DefaultBindCommandProperty => Controls.MenuFlyoutItem.CommandProperty;
20 | public Xaml.DependencyProperty DefaultBindCommandParameterProperty => Controls.MenuFlyoutItem.CommandParameterProperty;
21 | }
22 |
23 | public partial class SplitButton : IDefaultBindCommandProperties
24 | {
25 | public Xaml.DependencyProperty DefaultBindCommandProperty => Controls.SplitButton.CommandProperty;
26 | public Xaml.DependencyProperty DefaultBindCommandParameterProperty => Controls.SplitButton.CommandParameterProperty;
27 | }
28 |
29 | public partial class SwipeItem : IDefaultBindCommandProperties
30 | {
31 | public Xaml.DependencyProperty DefaultBindCommandProperty => Controls.SwipeItem.CommandProperty;
32 | public Xaml.DependencyProperty DefaultBindCommandParameterProperty => Controls.SwipeItem.CommandParameterProperty;
33 | }
34 |
35 | public partial class TabView : IDefaultBindCommandProperties
36 | {
37 | public Xaml.DependencyProperty DefaultBindCommandProperty => Controls.TabView.AddTabButtonCommandProperty;
38 | public Xaml.DependencyProperty DefaultBindCommandParameterProperty => Controls.TabView.AddTabButtonCommandParameterProperty;
39 | }
40 |
41 | public partial class ButtonBase : IDefaultBindCommandProperties
42 | {
43 | public Xaml.DependencyProperty DefaultBindCommandProperty => Controls.Primitives.ButtonBase.CommandProperty;
44 | public Xaml.DependencyProperty DefaultBindCommandParameterProperty => Controls.Primitives.ButtonBase.CommandParameterProperty;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/DependencyProperty.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 | using BindingOperations = Microsoft.UI.Xaml.Data.BindingOperations;
3 |
4 | namespace CSharpMarkup.WinUI
5 | {
6 | public class DependencyProperty where TDependencyObject : DependencyObject
7 | {
8 | static DependencyProperty instance;
9 | // This class is not thread-safe by design - we don't need that so avoid the overhead.
10 | //
11 | // Rationale:
12 | // As long as all markup is constructed on the same (UI) thread, no more than one instance of each
13 | // constructed variation of DependencyProperty will ever be in use at the same time.
14 | //
15 | // E.g. for .TextAlignment() .Left() the DependencyProperty instance usage starts in
16 | // .TextAlignment() and ends after .Left().
17 | // This is synchronous code, so no chance of other threads using a DependencyProperty at the same time.
18 | // So we really only need a single instance during the entire app lifetime.
19 |
20 | // Because all layouts have their child controls built in the layout factory helper,
21 | // and any DependencyProperty on a layout will only be started after the layout factory helper finishes,
22 | // even e.g. a StackPanel that uses a DependencyProperty and that contains
23 | // another StackPanel that uses the same DependencyProperty instance,
24 | // will not cause overlapping use of that DependencyProperty instance.
25 |
26 | // However, if we create chain classes that can be nested - so a chain within a chain e.g. .Color() .Dark() .Blue() -
27 | // then at least each chain nesting level does need a separate static instance (so 2 instances in this example).
28 | // Note that by definition, a chain cannot contain a suhchain with the same TParent, TChild combination;
29 | // that would still be just a single TParent, TChild chain.
30 |
31 | public static DependencyProperty Get(TDependencyObject element, Xaml.DependencyProperty property)
32 | {
33 | if (instance == null) instance = new DependencyProperty();
34 | instance.Target = element;
35 | instance.UI = property;
36 | return instance;
37 | }
38 |
39 | protected DependencyProperty() { }
40 |
41 | public TDependencyObject Target { get; private set; }
42 | public Xaml.DependencyProperty UI { get; private set; }
43 |
44 | internal TDependencyObject Set(TPropertyValue value) { Target.UI.SetValue(UI, value); return Target; }
45 | internal TDependencyObject SetBinding(Xaml.Data.BindingBase binding) { BindingOperations.SetBinding(Target.UI, UI, binding); return Target; }
46 | }
47 | }
48 |
49 | namespace CSharpMarkup.WinUI.GeneratedCodeUtilities // Include this in generated code outside of this assembly to get access to internal methods
50 | {
51 | public static class DependencyPropertyExtensions
52 | {
53 | public static TDependencyObject Set(
54 | this DependencyProperty property, TPropertyValue value
55 | ) where TDependencyObject : DependencyObject
56 | => property.Set(value);
57 |
58 | public static TDependencyObject SetBinding(
59 | this DependencyProperty property, Xaml.Data.BindingBase binding
60 | ) where TDependencyObject : DependencyObject
61 | => property.SetBinding(binding);
62 | }
63 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/Hyperlink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | public static partial class Helpers
6 | {
7 | public static Hyperlink Hyperlink(Uri uri, params InlineCollectionItem[] content) => Hyperlink(content).NavigateUri(uri);
8 | }
9 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/InlineCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | public static partial class Helpers
6 | {
7 | public static void Add(this Microsoft.UI.Xaml.Documents.InlineCollection inlines, InlineCollectionItem item)
8 | {
9 | switch (item.TypeIndex)
10 | {
11 | case 1: inlines.Add(Run(item.T1Value)); break;
12 | case 2: inlines.Add(item.T2Value); break;
13 | case 3: inlines.Add(InlineUIContainer(item.T3Value)); break;
14 | }
15 | }
16 | }
17 |
18 | /// Allows to specify either a , a or a
19 | public class InlineCollectionItem : OneOf
20 | {
21 | public static implicit operator InlineCollectionItem(string value) => new InlineCollectionItem(value);
22 | public static implicit operator InlineCollectionItem(Inline value) => new InlineCollectionItem(value.UI);
23 | public static implicit operator InlineCollectionItem(UIElement value) => new InlineCollectionItem(value.UI);
24 |
25 | InlineCollectionItem(string value) : base(value) { }
26 | InlineCollectionItem(Microsoft.UI.Xaml.Documents.Inline value) : base(value) { }
27 | InlineCollectionItem(Microsoft.UI.Xaml.UIElement value) : base(value) { }
28 | }
29 |
30 | /// Allows to specify either a , a or a
31 | public class OneOf
32 | {
33 | readonly object value;
34 |
35 | public int TypeIndex { get; }
36 |
37 | public T1 T1Value => TypeIndex == 1 ? (T1)value : throw new InvalidOperationException();
38 | public T2 T2Value => TypeIndex == 2 ? (T2)value : throw new InvalidOperationException();
39 | public T3 T3Value => TypeIndex == 3 ? (T3)value : throw new InvalidOperationException();
40 |
41 | public OneOf(T1 value) { this.value = value; TypeIndex = 1; }
42 | public OneOf(T2 value) { this.value = value; TypeIndex = 2; }
43 | public OneOf(T3 value) { this.value = value; TypeIndex = 3; }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/ItemsRepeater.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.WinUI;
4 |
5 | public static partial class Helpers
6 | {
7 | public static ItemsRepeater ItemsRepeater(Func itemTemplate) => ItemsRepeater().ItemTemplate(DataTemplate(itemTemplate).UI);
8 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/ListView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | public static partial class Helpers
6 | {
7 | public static ListView ListView(Func itemTemplate) => ListView().ItemTemplate(DataTemplate(itemTemplate));
8 |
9 | public static ListView ListView(Func headerTemplate, Func itemTemplate, Func footerTemplate = null)
10 | {
11 | var listView = ListView();
12 | if (headerTemplate != null) listView.HeaderTemplate(DataTemplate(headerTemplate));
13 | if (itemTemplate != null) listView.ItemTemplate(DataTemplate(itemTemplate));
14 | if (footerTemplate != null) listView.FooterTemplate(DataTemplate(footerTemplate));
15 | return listView;
16 | }
17 |
18 | }
19 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/MarkupExtensions.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 | using Color = Windows.UI.Color;
3 |
4 | namespace CSharpMarkup.WinUI
5 | {
6 | public static class MarkupExtensions
7 | {
8 | public static Color ToColor(this string color) => (Color)Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(Color), color);
9 | }
10 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/Readme.md:
--------------------------------------------------------------------------------
1 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
2 | - Build .NET applications **fully in C#**
3 | - Target browsers and native desktop / mobile
4 |
5 | No XAML / HTML / JavaScript / CSS required
6 |
7 | This release targets WinUI 3 (Windows App SDK) and Uno Platform - including browser webassembly - with C# 13 and .NET 9 or 8.
8 | When only targeting Windows, C# Markup 2 has no dependency on Uno - just the Windows App SDK.
9 |
10 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
11 |
12 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.WinUI.Examples)
13 |
14 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/StackPanel.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | public static partial class Helpers
6 | {
7 | ///Short for:StackPanel().Orientation().Horizontal()
// TODO: see if we can generate this from the attribute
8 | [ShortFor("StackPanel().Orientation().Horizontal()")]
9 | public static StackPanel HStack(params Xaml.UIElement[] children) => StackPanel(children).Orientation().Horizontal();
10 |
11 | ///Short for:StackPanel().Orientation().Vertical()
12 | [ShortFor("StackPanel().Orientation().Vertical()")]
13 | public static StackPanel VStack(params Xaml.UIElement[] children) => StackPanel(children).Orientation().Vertical();
14 |
15 | /// Add children to a Panel
16 | /// This method is only safe when used stand-alone or at the end of a fluent call chain. To enforce this, it does not return the this parameter
17 | public static void Children(this Panel panel, params Xaml.UIElement[] children)
18 | {
19 | foreach (var child in children) panel.UI.Children.Add(child);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/Style.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Xaml = Microsoft.UI.Xaml;
3 |
4 | namespace CSharpMarkup.WinUI
5 | {
6 | public static partial class Helpers
7 | {
8 | // TODO: ? how to let intellisense offer only styles for the type?
9 | // will helper .Style(this T, Style style) interfere with the generated .Style(this T, Style style)?
10 |
11 | public static Style Style(Xaml.DependencyProperty property, UIObject value) where T : DependencyObject
12 | => new Style(property, value);
13 |
14 | public static Style Style(params (Xaml.DependencyProperty property, UIObject value)[] setters) where T : DependencyObject
15 | => new Style(setters);
16 | }
17 |
18 | public static partial class FrameworkElementExtensions
19 | {
20 | /// Set to a type-safe
21 | public static TView Style(this TView view, Style style) where TView : FrameworkElement { view.UI.Style = style; return view; }
22 | }
23 |
24 | public class Style : Style where T : DependencyObject
25 | {
26 | void Initialize() => UI = new Xaml.Style(typeof(T).GetProperty("UI", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).PropertyType);
27 |
28 | public Style() => Initialize();
29 |
30 | public Style(Xaml.DependencyProperty property, UIObject value) { Initialize(); Set(property, value); }
31 |
32 | public Style(params (Xaml.DependencyProperty property, UIObject value)[] setters) { Initialize(); Set(setters); }
33 |
34 | public Style Set(Xaml.DependencyProperty property, UIObject value) => Set((property, value));
35 |
36 | public Style Set(params (Xaml.DependencyProperty property, UIObject value)[] setters)
37 | {
38 | foreach ((var property, var value) in setters)
39 | UI.Setters.Add(new Xaml.Setter(property, value.UI));
40 | return this;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/Thickness.cs:
--------------------------------------------------------------------------------
1 | using Xaml = Microsoft.UI.Xaml;
2 |
3 | namespace CSharpMarkup.WinUI
4 | {
5 | public static partial class Helpers
6 | {
7 | public static Xaml.Thickness Thickness(double uniform) => new Xaml.Thickness { Left = uniform, Top = uniform, Right = uniform, Bottom = uniform };
8 | public static Xaml.Thickness Thickness(double horizontal, double vertical) => new Xaml.Thickness { Left = horizontal, Top = vertical, Right = horizontal, Bottom = vertical };
9 | public static Xaml.Thickness Thickness(double left, double top, double right, double bottom) => new Xaml.Thickness { Left = left, Top = top, Right = right, Bottom = bottom };
10 | public static Xaml.Thickness Thicknesses(double left = 0, double top = 0, double right = 0, double bottom = 0) => new Xaml.Thickness { Left = left, Top = top, Right = right, Bottom = bottom };
11 | }
12 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/VisualStateManager.cs:
--------------------------------------------------------------------------------
1 | #if WINUI
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Runtime.Versioning;
5 | using Xaml = Microsoft.UI.Xaml;
6 |
7 | namespace CSharpMarkup.WinUI
8 | {
9 | public static partial class VisualStateManagerExtensions
10 | {
11 | internal const string UnsupportedErrorMessage = "Using VisualStateManager from C# is not supported by Windows App SDK; use a XAML app resource instead. See https://github.com/VincentH-Net/CSharpForMarkup/issues/22#issuecomment-1706468475";
12 |
13 | [UnsupportedOSPlatform("Windows", UnsupportedErrorMessage)]
14 | public static TTarget VisualStateManager_VisualStateGroups(this TTarget target, IList value) where TTarget : FrameworkElement
15 | => throw new NotImplementedException();
16 |
17 | [UnsupportedOSPlatform("Windows", UnsupportedErrorMessage)]
18 | public static DependencyProperty> VisualStateManager_VisualStateGroups(this TTarget target) where TTarget : FrameworkElement
19 | => throw new NotImplementedException();
20 |
21 | [UnsupportedOSPlatform("Windows", UnsupportedErrorMessage)]
22 | public static TTarget VisualStateManager(this TTarget target
23 |
24 | , IList VisualStateGroups = default
25 |
26 | , Xaml.VisualStateManager CustomVisualStateManager = default
27 |
28 | ) where TTarget : FrameworkElement
29 | => throw new NotImplementedException();
30 | }
31 | }
32 | #endif
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Navigation;
5 | using System.Linq;
6 |
7 | namespace WpfCsMarkupExamples;
8 |
9 | public partial class App : Application
10 | {
11 | NavigationWindow? mainWindow;
12 | SearchPage? searchPage;
13 | FlutterPage? flutterPage;
14 |
15 | public App() => Current = this;
16 |
17 | protected override void OnStartup(StartupEventArgs e)
18 | {
19 | mainWindow = new NavigationWindow
20 | {
21 | SizeToContent = SizeToContent.WidthAndHeight,
22 | Resources = Styles.Implicit.Dictionary
23 | };
24 | NavigateToSearchPage();
25 | mainWindow.Show();
26 | base.OnStartup(e);
27 | }
28 |
29 | SearchViewModel? searchViewModel;
30 | FlutterViewModel? flutterViewModel;
31 |
32 | internal static new App? Current { get; private set; }
33 |
34 | internal static void LaunchUri(Uri uri) => Process.Start("cmd.exe", $"/C \"start msedge {uri}\"");
35 | internal SearchViewModel SearchViewModel => searchViewModel ??= new SearchViewModel().Initialize();
36 | internal FlutterViewModel FlutterViewModel => flutterViewModel ??= new FlutterViewModel();
37 |
38 | internal void NavigateToSearchPage() => Navigate(SearchPage);
39 | internal void NavigateToFlutterPage() => Navigate(FlutterPage);
40 | internal void NavigateBack() => mainWindow?.NavigationService.GoBack();
41 |
42 | #if DEBUG
43 | internal void BuildUI(Type[]? types)
44 | {
45 | if (types is null) return;
46 |
47 | bool buildStyles = types.Any(t => t == typeof(Styles) || t == typeof(Styles.Implicit));
48 | if (buildStyles) { Styles.Implicit.ClearCache(); Styles.ClearCache(); }
49 |
50 | // TODO: same for control templates as for styles - use nice controltemplate example (togglebutton?), then port to WinUI example
51 |
52 | if (mainWindow is not null)
53 | {
54 | if (buildStyles) mainWindow.Resources = Styles.Implicit.Dictionary;
55 | (mainWindow.NavigationService.Content as IBuild)?.Build();
56 | }
57 | }
58 | #endif
59 |
60 | Page SearchPage => searchPage ??= new SearchPage();
61 | Page FlutterPage => flutterPage ??= new FlutterPage();
62 |
63 | void Navigate(Page page) => mainWindow?.NavigationService.Navigate(page);
64 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/CSharpMarkup.Wpf.Examples.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 | enable
7 | true
8 | WpfCsMarkupExamples
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/CSharpMarkup.Wpf.Examples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.31911.260
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMarkup.Wpf.Examples", "CSharpMarkup.Wpf.Examples.csproj", "{1F79362E-3A16-4AE5-8ABD-1FA4169A681C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {1F79362E-3A16-4AE5-8ABD-1FA4169A681C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {1F79362E-3A16-4AE5-8ABD-1FA4169A681C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {1F79362E-3A16-4AE5-8ABD-1FA4169A681C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {1F79362E-3A16-4AE5-8ABD-1FA4169A681C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {A7F35F82-C4E9-4738-ACA9-4DD41392D74E}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/BasePage.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | namespace WpfCsMarkupExamples;
3 |
4 | internal class BasePage : Page
5 | {
6 | public new object Content { get => base.Content; set { base.Content = value is CSharpMarkup.Wpf.DependencyObject d ? d.UI : value; } }
7 | }
8 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace WpfCsMarkupExamples;
4 |
5 | public class BaseViewModel : INotifyPropertyChanged
6 | {
7 | #pragma warning disable CS0067 // Fody generates code that uses PropertyChanged
8 | public event PropertyChangedEventHandler? PropertyChanged;
9 | #pragma warning restore
10 | }
11 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace WpfCsMarkupExamples;
2 |
3 | internal static class Constants
4 | {
5 | public static Uri CsMarkupUri { get; } = new Uri("https://github.com/VincentH-Net/CSharpForMarkup");
6 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using System;
2 | global using System.Collections.Generic;
3 | global using System.Threading;
4 | global using System.Threading.Tasks;
5 | global using static System.Windows.Media.Colors;
6 | global using static WpfCsMarkupExamples.Constants;
7 | global using static WpfCsMarkupExamples.Styles;
8 | global using UI = System.Windows;
9 | global using ICommand = System.Windows.Input.ICommand;
10 | global using Tweet = WpfCsMarkupExamples.SearchViewModel.Tweet;
11 | global using BindingMode = System.Windows.Data.BindingMode;
12 | global using Button_UI = System.Windows.Controls.Button;
13 | global using TextBlock_UI = System.Windows.Controls.TextBlock;
14 | global using TextBox_UI = System.Windows.Controls.TextBox;
15 | global using InlineCollection_UI = System.Windows.Documents.InlineCollection;
16 | global using ListViewItem_UI = System.Windows.Controls.ListViewItem;
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/HotReloadManager.cs:
--------------------------------------------------------------------------------
1 | #if DEBUG
2 | [assembly: System.Reflection.Metadata.MetadataUpdateHandler(typeof(WpfCsMarkupExamples.HotReloadManager))]
3 |
4 | namespace WpfCsMarkupExamples;
5 |
6 | internal static class HotReloadManager
7 | {
8 | public static void ClearCache(Type[]? types) { }
9 |
10 | public static void UpdateApplication(Type[]? types) =>
11 | App.Current?.Dispatcher.Invoke(() => App.Current.BuildUI(types));
12 | }
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/IBuild.cs:
--------------------------------------------------------------------------------
1 | namespace WpfCsMarkupExamples;
2 |
3 | interface IBuild { void Build(); }
4 |
5 | interface IClearCache { void ClearCache(); }
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Core/MarkupExtensions.cs:
--------------------------------------------------------------------------------
1 | using CSharpMarkup.Wpf;
2 | using static CSharpMarkup.Wpf.Helpers;
3 |
4 | namespace WpfCsMarkupExamples;
5 |
6 | internal static class MarkupExtensions
7 | {
8 | // TODO: Generate add-event helpers as member methods on markup type itself so type arguments do not have to be specified manually
9 | public static TextBlock OnDataContextChanged(this TextBlock target, Action onChanged)
10 | => target.OnDataContextChanged(onChanged);
11 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/FlutterPage.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using CSharpMarkup.Wpf;
3 | using static CSharpMarkup.Wpf.Helpers;
4 | namespace WpfCsMarkupExamples;
5 |
6 | partial class FlutterPage
7 | {
8 | public void Build() => Content =
9 |
10 | VStack (
11 | HStack (
12 | Button ("\u1438") .Style (HeaderButton)
13 | .Width (50)
14 | .Bind (vm.BackCommand),
15 |
16 | TextBlock ()
17 | .VCenter ()
18 | .Bind (vm.Title)
19 | ),
20 |
21 | Button(
22 | TextBlock() .Foreground (Black) .Bind (vm.ToggleMoreText)
23 | ) .Template (RoundButton)
24 | .Foreground (Red) .Size (65)
25 | .Bind (vm.ToggleMoreCommand),
26 |
27 | vm.ShowMore ?
28 | TextBlock ("Demonstrate Flutter-like UI building features:\nConditional UI and the Spread() operator") .Center()
29 | : null,
30 |
31 | TextBlock ("Subtitles:"),
32 | Spread (Subtitles),
33 |
34 | TextBlock ("Pairs:"),
35 | Spread (Pairs())
36 |
37 | ) .Background (Black) .TextBlock_Foreground(SolidColorBrush(White));
38 |
39 | ControlTemplate RoundButton = ControlTemplate(typeof(Button), () =>
40 | Grid (
41 | Ellipse()
42 | .Fill (RadialGradientBrush (Silver, Gold))
43 | .Stroke().BindTemplate (b?.Foreground),
44 | ContentPresenter()
45 | .Center()
46 | ));
47 |
48 | IEnumerable Subtitles => vm.Subtitles.Select(subtitle => TextBlock(subtitle) .Margin (0, 5) .UI);
49 |
50 | IEnumerable Pairs() {
51 | for (int i = 1; i <= 5; i++) {
52 | yield return TextBlock($"Field {i}:") .Margins (top: 20);
53 | yield return TextBox(Text: $"Enter value for {i}");
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/FlutterPage.logic.cs:
--------------------------------------------------------------------------------
1 | // IMPORTANT:
2 | // In .cs:
3 | // Include CSharpMarkup namespace usings but no UI objectmodel usings.
4 | // You *can* also use the UI objectmodel safely in .cs; a good practice then is to
5 | // define a "global using TypeName_UI = .TypeName" alias in GlobalUsings.cs
6 |
7 | // In .logic.cs:
8 | // DO NOT include CSharpMarkup namespace usings and DO NOT use CSharpMarkup objects.
9 | // Markup object instances are not safe to use outside of a markup expression (due to performance features).
10 | // That is why Assign and Invoke pass the UI object to the logic, not the markup object.
11 | using System.ComponentModel;
12 | using System.Windows.Controls;
13 |
14 | namespace WpfCsMarkupExamples;
15 |
16 | internal sealed partial class FlutterPage : BasePage, IBuild
17 | {
18 | readonly FlutterViewModel vm;
19 | static Button b;
20 |
21 | public FlutterPage()
22 | {
23 | DataContext = vm = App.Current!.FlutterViewModel;
24 | Build();
25 |
26 | vm.PropertyChanged += Vm_PropertyChanged; // This is MVVM, but other update models can be hooked up here as well
27 | }
28 |
29 | void Vm_PropertyChanged(object? _, PropertyChangedEventArgs e)
30 | {
31 | if (e.PropertyName == nameof(vm.ShowMore)) Build();
32 | }
33 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/FlutterViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace WpfCsMarkupExamples;
2 |
3 | public class FlutterViewModel : BaseViewModel
4 | {
5 | ICommand? toggleMoreCommand, backCommand;
6 |
7 | List? subTitles;
8 |
9 | public string Title { get; set; } = "Flutter-Like UI markup";
10 | public bool ShowMore { get; set; } = true;
11 | public string ToggleMoreText => ShowMore ? "Show less" : "Show more";
12 | public List Subtitles => subTitles ??= new List() { "Subtitle 1", "Subtitle 2", "Subtitle 3" };
13 |
14 | public ICommand ToggleMoreCommand => toggleMoreCommand ??= new RelayCommand(ToggleMore);
15 | public ICommand BackCommand => backCommand ??= new RelayCommand(Back);
16 |
17 | void ToggleMore() { ShowMore = !ShowMore; }
18 | void Back() => App.Current?.NavigateBack();
19 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/SearchPage.cs:
--------------------------------------------------------------------------------
1 | using CSharpMarkup.Wpf;
2 | using static CSharpMarkup.Wpf.Helpers;
3 | namespace WpfCsMarkupExamples;
4 |
5 | partial class SearchPage
6 | {
7 | public void Build() => Content =
8 |
9 | VStack (
10 | Header .Assign (out header),
11 | SearchResults,
12 | Footer
13 | ) .Background (Black);
14 |
15 | StackPanel Header => HStack (
16 | Button ("\u22EF") .Style (HeaderButton)
17 | .Width (50)
18 | .Bind (vm.GoToOtherCommand),
19 |
20 | TextBox() .Foreground (White)
21 | .VCenter () .Width (350)
22 | .Bind (vm.SearchText, BindingMode.TwoWay),
23 |
24 | Button("\U0001F50D") .Style (HeaderButton)
25 | .Width (50)
26 | .Bind (vm.SearchCommand)
27 | );
28 |
29 | enum TweetRow { Title, Body, Actions }
30 | enum TweetColumn { AuthorImage, Content }
31 |
32 | ListView SearchResults => ListView(() =>
33 | Border ( Grid (
34 | Rows (
35 | (TweetRow.Title , Auto),
36 | (TweetRow.Body , Auto),
37 | (TweetRow.Actions, Auto)
38 | ),
39 |
40 | Columns (
41 | (TweetColumn.AuthorImage, 70),
42 | (TweetColumn.Content , Star)
43 | ),
44 |
45 | RoundImage (53)
46 | .Grid (TweetRow.Title, TweetRow.Actions, TweetColumn.AuthorImage) .HCenter() .Top() .Margins (left: 10, top: 4),
47 |
48 | TextBlock ().TextTrimming().CharacterEllipsis() .FontSize (16)
49 | .Grid (TweetRow.Title, TweetColumn.Content) .Margins (right: 10)
50 | .Bind (tweet.Header),
51 |
52 | TextBlock ()
53 | .FontSize (15) .TextWrapping().Wrap()
54 | .Grid (TweetRow.Body, TweetColumn.Content) .Margins (top: 6, right: 10, bottom: 6)
55 | .OnDataContextChanged (Format),
56 |
57 | LikeButton ()
58 | .Grid (TweetRow.Actions, TweetColumn.Content) .Left () .Top ()
59 | .BindCommand (vm.LikeCommand, vm)
60 |
61 | )) .MaxWidth(500) .BorderThicknesses (top: 0.5) .BorderBrush (Gray) .Padding (0, 6)
62 |
63 | ) .Background ("#171F2A")
64 | .Bind (vm.SearchResults);
65 |
66 | Ellipse RoundImage(double size) => Ellipse() .Size (size) .Fill (ImageBrush().Bind (tweet.AuthorImage, convert: (string uri) => UriImage(uri)));
67 |
68 | void Format(TextBlock_UI textBlock, Tweet tweet)
69 | {
70 | textBlock.Inlines.Clear();
71 |
72 | tweet?.Body?.ForEach(fragment => textBlock.Inlines.Add(
73 | fragment.IsMatch ?
74 | Link (fragment.Text!, SearchViewModel.LinkUri(fragment.Text!)) .FontSize (15) :
75 | Run (fragment.Text)
76 | ));
77 | }
78 |
79 | Button LikeButton() => Button (
80 | TextBlock()
81 | .Foreground (Red) .FontSize (20)
82 | .Bind(tweet.IsLikedByMe, convert: (bool like) => like ? "\u2764" : "\u2661")
83 | ) .HorizontalContentAlignment().Center() .VerticalContentAlignment().Center() .Margin (0) .Size (32) .Padding (0);
84 |
85 | TextBlock Footer => TextBlock ("See ", Link ("C# Markup on GitHub", CsMarkupUri), " for more information")
86 | .FontSize (14)
87 | .HCenter()
88 | .Margins (bottom: 6);
89 |
90 | Hyperlink Link(string text, Uri uri) => Hyperlink(text)
91 | .Foreground (CornflowerBlue)
92 | .Invoke(l => l.Click += (_, _) => App.LaunchUri(uri));
93 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/SearchPage.logic.cs:
--------------------------------------------------------------------------------
1 | // IMPORTANT:
2 | // In .cs:
3 | // Include CSharpMarkup namespace usings but no UI objectmodel usings.
4 | // You *can* also use the UI objectmodel safely in .cs; a good practice then is to
5 | // define a "global using TypeName_UI = .TypeName" alias in GlobalUsings.cs
6 |
7 | // In .logic.cs:
8 | // DO NOT include CSharpMarkup namespace usings and DO NOT use CSharpMarkup objects.
9 | // Markup object instances are not safe to use outside of a markup expression (due to performance features).
10 | // That is why Assign and Invoke pass the UI object to the logic, not the markup object.
11 | using System.Windows.Controls;
12 | using System.Windows.Media.Imaging;
13 | namespace WpfCsMarkupExamples;
14 |
15 | internal sealed partial class SearchPage : BasePage, IBuild
16 | {
17 | static SearchViewModel.Tweet tweet = new();
18 | readonly SearchViewModel vm;
19 | StackPanel? header;
20 |
21 | public SearchPage()
22 | {
23 | this.Initialized += OnInitialized;
24 | DataContext = vm = App.Current!.SearchViewModel;
25 | Build();
26 | }
27 |
28 | protected override void OnInitialized(EventArgs e)
29 | {
30 | base.OnInitialized(e);
31 | }
32 |
33 | void OnInitialized(object? sender, EventArgs e)
34 | {
35 |
36 | }
37 |
38 | static BitmapImage UriImage(string uri)
39 | {
40 | BitmapImage bitmap = new BitmapImage();
41 | bitmap.BeginInit();
42 | bitmap.UriSource = new Uri(uri, UriKind.Absolute);
43 | bitmap.EndInit();
44 | return bitmap;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/Styles.cs:
--------------------------------------------------------------------------------
1 | using CSharpMarkup.Wpf;
2 | using System.Diagnostics;
3 | using static CSharpMarkup.Wpf.Helpers;
4 | namespace WpfCsMarkupExamples;
5 |
6 | public static class Styles
7 | {
8 | static Style