├── .github
└── FUNDING.yml
├── src
├── CSharpMarkup.WinUI.Examples
│ ├── Directory.Build.targets
│ ├── .vscode
│ │ ├── extensions.json
│ │ ├── settings.json
│ │ └── tasks.json
│ ├── WinUICsMarkupExamples
│ │ ├── Platforms
│ │ │ ├── WebAssembly
│ │ │ │ ├── WasmScripts
│ │ │ │ │ └── AppManifest.js
│ │ │ │ ├── Program.cs
│ │ │ │ ├── LinkerConfig.xml
│ │ │ │ ├── manifest.webmanifest
│ │ │ │ ├── wwwroot
│ │ │ │ │ └── staticwebapp.config.json
│ │ │ │ └── WasmCSS
│ │ │ │ │ └── Fonts.css
│ │ │ ├── Android
│ │ │ │ ├── environment.conf
│ │ │ │ ├── Resources
│ │ │ │ │ ├── values
│ │ │ │ │ │ ├── Strings.xml
│ │ │ │ │ │ └── Styles.xml
│ │ │ │ │ └── AboutResources.txt
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── MainActivity.Android.cs
│ │ │ │ ├── Main.Android.cs
│ │ │ │ └── Assets
│ │ │ │ │ └── AboutAssets.txt
│ │ │ ├── iOS
│ │ │ │ ├── Entitlements.plist
│ │ │ │ ├── Main.iOS.cs
│ │ │ │ ├── PrivacyInfo.xcprivacy
│ │ │ │ ├── Info.plist
│ │ │ │ └── Media.xcassets
│ │ │ │ │ └── LaunchImages.launchimage
│ │ │ │ │ └── Contents.json
│ │ │ └── Desktop
│ │ │ │ └── Program.cs
│ │ ├── Models
│ │ │ └── AppConfig.cs
│ │ ├── appsettings.development.json
│ │ ├── ReadMe.md
│ │ ├── appsettings.json
│ │ ├── Assets
│ │ │ ├── Images
│ │ │ │ ├── search.svg
│ │ │ │ └── forward.svg
│ │ │ ├── SharedAssets.md
│ │ │ └── Icons
│ │ │ │ └── icon.svg
│ │ ├── GlobalUsings.cs
│ │ ├── Properties
│ │ │ ├── PublishProfiles
│ │ │ │ ├── win-x64.pubxml
│ │ │ │ ├── win-arm64.pubxml
│ │ │ │ └── win-x86.pubxml
│ │ │ └── launchSettings.json
│ │ ├── Package.appxmanifest
│ │ ├── app.manifest
│ │ ├── Styles
│ │ │ ├── Example.xaml
│ │ │ └── ColorPaletteOverride.json
│ │ ├── App.xaml
│ │ └── WinUICsMarkupExamples.csproj
│ ├── WinUICsMarkupExamples.Presentation
│ │ ├── Core
│ │ │ ├── BaseViewModel.cs
│ │ │ ├── Constants.cs
│ │ │ ├── BasePage.cs
│ │ │ ├── BaseUserControl.cs
│ │ │ ├── BasePage.logic.cs
│ │ │ ├── MarkupExtensions.cs
│ │ │ └── GlobalUsings.cs
│ │ ├── .filenesting.json
│ │ ├── Example
│ │ │ ├── LiveCharts2Page.logic.cs
│ │ │ ├── MapsuiViewModel.cs
│ │ │ ├── ScottPlotViewModel.cs
│ │ │ ├── Shell.logic.cs
│ │ │ ├── SearchPage.logic.cs
│ │ │ ├── ShellViewModel.cs
│ │ │ ├── ScottPlotPage.logic.cs
│ │ │ ├── FlutterPage.logic.cs
│ │ │ ├── Shell.cs
│ │ │ ├── FlutterViewModel.cs
│ │ │ ├── MapsuiPage.cs
│ │ │ ├── ScottPlotPage.cs
│ │ │ ├── LiveCharts2ViewModel.cs
│ │ │ ├── LiveCharts2Page.cs
│ │ │ ├── MapsuiPage.logic.cs
│ │ │ ├── Routes.cs
│ │ │ └── FlutterPage.cs
│ │ ├── New-View.ps1
│ │ ├── WinUICsMarkupExamples.Presentation.csproj
│ │ └── Readme.md
│ ├── global.json
│ ├── .run
│ │ └── Readme.md
│ ├── Directory.Build.props
│ ├── .vsconfig
│ └── Directory.Packages.props
├── CSharpMarkup.WinUI
│ ├── global.json
│ ├── ItemsRepeater.cs
│ ├── Hyperlink.cs
│ ├── MarkupExtensions.cs
│ ├── CompileTests
│ │ ├── TestModel.cs
│ │ └── TestPage.logic.cs
│ ├── CommandBarElement.cs
│ ├── Readme.md
│ ├── ListView.cs
│ ├── Attributes.cs
│ ├── Thickness.cs
│ ├── StackPanel.cs
│ ├── CSharpMarkup.WinUI.sln
│ ├── VisualStateManager.cs
│ ├── Style.cs
│ ├── InlineCollection.cs
│ ├── DefaultBindProperties.cs
│ └── Control.cs
├── CSharpMarkup.WinUI.ScottPlot
│ ├── global.json
│ ├── Readme.md
│ └── _Helpers.cs
├── CSharpMarkup.WinUI.Uno.Toolkit
│ ├── global.json
│ ├── Readme.md
│ ├── _Helpers.cs
│ └── NavigationBar.cs
├── CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView
│ ├── global.json
│ ├── Readme.md
│ └── _Helpers.cs
├── CSharpMarkup.Wpf.Examples
│ ├── Core
│ │ ├── IBuild.cs
│ │ ├── Constants.cs
│ │ ├── BasePage.cs
│ │ ├── BaseViewModel.cs
│ │ ├── HotReloadManager.cs
│ │ ├── MarkupExtensions.cs
│ │ └── GlobalUsings.cs
│ ├── FodyWeavers.xml
│ ├── App.xaml
│ ├── NuGet.config
│ ├── CSharpMarkup.Wpf.Examples.csproj
│ ├── AssemblyInfo.cs
│ ├── FlutterViewModel.cs
│ ├── CSharpMarkup.Wpf.Examples.sln
│ ├── FlutterPage.logic.cs
│ ├── SearchPage.logic.cs
│ ├── FlutterPage.cs
│ ├── App.xaml.cs
│ ├── Styles.cs
│ └── SearchPage.cs
├── CSharpMarkup.WinUI.Mapsui
│ ├── global.json
│ ├── Readme.md
│ ├── _Helpers.cs
│ └── Generated
│ │ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_MacCatalyst.cs
│ │ ├── UnoWinUI.NET8_0_iOS.cs
│ │ ├── WinUI.NET8_0_WinAppSdk.cs
│ │ ├── WinUI.NET9_0_WinAppSdk.cs
│ │ ├── UnoWinUI.NET8_0_WasmOrSkia.cs
│ │ └── UnoWinUI.NET9_0_WasmOrSkia.cs
├── CSharpMarkup.WinUI.Uno.Extensions.Navigation
│ ├── global.json
│ ├── Readme.md
│ └── _Helpers.cs
├── CSharpMarkup.WinUI.Uno.Extensions.Reactive
│ ├── global.json
│ ├── Readme.md
│ └── _Helpers.cs
├── CSharpMarkup.WinUI.Uno.Extensions.Navigation.Toolkit
│ ├── global.json
│ ├── Readme.md
│ ├── _Helpers.cs
│ └── Generated
│ │ └── SourceGenerators
│ │ └── SourceGenerators.CsMarkupApiSourceGenerator
│ │ ├── UnoWinUI.NET8_0_ANDROID.cs
│ │ ├── UnoWinUI.NET8_0_MACCATALYST.cs
│ │ ├── UnoWinUI.NET8_0_IOS.cs
│ │ ├── WinUI.NET8_0_WinAppSdk.cs
│ │ └── UnoWinUI.NET8_0_WasmOrSkia.cs
├── CSharpMarkup.Wpf
│ ├── ListView.cs
│ ├── Hyperlink.cs
│ ├── MarkupExtensions.cs
│ ├── Readme.md
│ ├── MenuItem.cs
│ ├── StoryBoard.cs
│ ├── Attributes.cs
│ ├── Thickness.cs
│ ├── StackPanel.cs
│ ├── NameScopes.cs
│ ├── Style.cs
│ ├── InlineCollection.cs
│ ├── DefaultBindProperties.cs
│ ├── DependencyProperty.cs
│ ├── CSharpMarkup.Wpf.csproj
│ └── Spread.cs
├── Directory.Packages.props
└── Directory.Build.targets
├── img
├── bindcommand.png
├── poll202303.png
├── markup-converters.png
├── markup-datatemplate.png
├── markup-page-files.png
├── markup-shorthand-1.png
├── markup-shorthand-2.png
├── markup-style-usage.png
├── mcs-winui3-new-view.png
├── markup-basic-anatomy.png
├── markup-logic-assign-1.png
├── markup-logic-assign-2.png
├── markup-logic-invoke-1.png
├── markup-logic-invoke-2.png
├── bind-default-parameter.png
├── bind-inline-conversion.png
├── in-app-hot-reload-button.png
├── markup-controltemplate.png
├── markup-style-definition.png
├── markup-attached-properties.png
├── markup-binding-expression.png
├── mcs-winui3-app-default-sln.png
├── mcs-winui3-hotreload-menu.png
├── mcs-winui3-new-view-output.png
├── improve-markup-colors-in-vs.png
├── markup-example-flutter-page.png
├── markup-property-enum-values.png
├── markup-style-setter-binding.png
├── mcs-winui3-app-mainpage-debug.png
├── mcs-winui3-hotreload-output.png
├── markup-controltemplate-in-style.png
├── markup-view-defined-properties.png
├── CSharpMarkup2-UnoCSharpMarkup-XAML.png
├── markup-converter-cornerradius-doc.png
├── markup-enums-for-grid-rows-columns.png
├── markup-view-convenience-overload.png
├── mcs-winui3-hotreload-in-app-button.png
├── unoconf-announce-csharp-markup-2.png
├── mcs-winui3-hotreload-rebuild-enabled.png
├── markup-attached-properties-set-multiple.png
├── mcs-winui3-hotreload-in-app-navigation.png
├── visual-studio-dotnet-hot-reload-button.png
├── markup-enums-for-grid-rows-columns-usage.png
├── visual-studio-dotnet-hot-reload-statusbar.png
└── markup-layout-insert-children-conditional-spread.png
├── global.json
├── NuGet.config
├── LICENSE
└── .gitattributes
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: VincentH-Net
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/img/bindcommand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/bindcommand.png
--------------------------------------------------------------------------------
/img/poll202303.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/poll202303.png
--------------------------------------------------------------------------------
/img/markup-converters.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-converters.png
--------------------------------------------------------------------------------
/img/markup-datatemplate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-datatemplate.png
--------------------------------------------------------------------------------
/img/markup-page-files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-page-files.png
--------------------------------------------------------------------------------
/img/markup-shorthand-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-shorthand-1.png
--------------------------------------------------------------------------------
/img/markup-shorthand-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-shorthand-2.png
--------------------------------------------------------------------------------
/img/markup-style-usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-style-usage.png
--------------------------------------------------------------------------------
/img/mcs-winui3-new-view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-new-view.png
--------------------------------------------------------------------------------
/img/markup-basic-anatomy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-basic-anatomy.png
--------------------------------------------------------------------------------
/img/markup-logic-assign-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-logic-assign-1.png
--------------------------------------------------------------------------------
/img/markup-logic-assign-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-logic-assign-2.png
--------------------------------------------------------------------------------
/img/markup-logic-invoke-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-logic-invoke-1.png
--------------------------------------------------------------------------------
/img/markup-logic-invoke-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-logic-invoke-2.png
--------------------------------------------------------------------------------
/img/bind-default-parameter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/bind-default-parameter.png
--------------------------------------------------------------------------------
/img/bind-inline-conversion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/bind-inline-conversion.png
--------------------------------------------------------------------------------
/img/in-app-hot-reload-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/in-app-hot-reload-button.png
--------------------------------------------------------------------------------
/img/markup-controltemplate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-controltemplate.png
--------------------------------------------------------------------------------
/img/markup-style-definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-style-definition.png
--------------------------------------------------------------------------------
/img/markup-attached-properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-attached-properties.png
--------------------------------------------------------------------------------
/img/markup-binding-expression.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-binding-expression.png
--------------------------------------------------------------------------------
/img/mcs-winui3-app-default-sln.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-app-default-sln.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-hotreload-menu.png
--------------------------------------------------------------------------------
/img/mcs-winui3-new-view-output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-new-view-output.png
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "unoplatform.vscode"
4 | ],
5 | }
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/img/improve-markup-colors-in-vs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/improve-markup-colors-in-vs.png
--------------------------------------------------------------------------------
/img/markup-example-flutter-page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-example-flutter-page.png
--------------------------------------------------------------------------------
/img/markup-property-enum-values.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-property-enum-values.png
--------------------------------------------------------------------------------
/img/markup-style-setter-binding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-style-setter-binding.png
--------------------------------------------------------------------------------
/img/mcs-winui3-app-mainpage-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-app-mainpage-debug.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-hotreload-output.png
--------------------------------------------------------------------------------
/img/markup-controltemplate-in-style.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-controltemplate-in-style.png
--------------------------------------------------------------------------------
/img/markup-view-defined-properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-view-defined-properties.png
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.ScottPlot/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Uno.Toolkit/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/img/CSharpMarkup2-UnoCSharpMarkup-XAML.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/CSharpMarkup2-UnoCSharpMarkup-XAML.png
--------------------------------------------------------------------------------
/img/markup-converter-cornerradius-doc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-converter-cornerradius-doc.png
--------------------------------------------------------------------------------
/img/markup-enums-for-grid-rows-columns.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-enums-for-grid-rows-columns.png
--------------------------------------------------------------------------------
/img/markup-view-convenience-overload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-view-convenience-overload.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-in-app-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-hotreload-in-app-button.png
--------------------------------------------------------------------------------
/img/unoconf-announce-csharp-markup-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/unoconf-announce-csharp-markup-2.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-rebuild-enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-hotreload-rebuild-enabled.png
--------------------------------------------------------------------------------
/img/markup-attached-properties-set-multiple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-attached-properties-set-multiple.png
--------------------------------------------------------------------------------
/img/mcs-winui3-hotreload-in-app-navigation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/mcs-winui3-hotreload-in-app-navigation.png
--------------------------------------------------------------------------------
/img/visual-studio-dotnet-hot-reload-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/visual-studio-dotnet-hot-reload-button.png
--------------------------------------------------------------------------------
/img/markup-enums-for-grid-rows-columns-usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-enums-for-grid-rows-columns-usage.png
--------------------------------------------------------------------------------
/img/visual-studio-dotnet-hot-reload-statusbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/visual-studio-dotnet-hot-reload-statusbar.png
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.300",
4 | "rollForward": "latestPatch"
5 | }
6 | }
--------------------------------------------------------------------------------
/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/markup-layout-insert-children-conditional-spread.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VincentH-Net/CSharpForMarkup/HEAD/img/markup-layout-insert-children-conditional-spread.png
--------------------------------------------------------------------------------
/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.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/WasmScripts/AppManifest.js:
--------------------------------------------------------------------------------
1 | var UnoAppManifest = {
2 | displayName: "WinUICsMarkupExamples"
3 | }
4 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Mapsui/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Uno.Sdk": "6.0.130"
4 | },
5 | "sdk": {
6 | "version": "9.0.300",
7 | "rollForward": "latestPatch"
8 | }
9 | }
--------------------------------------------------------------------------------
/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/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/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Uno.Sdk": "6.0.146"
4 | },
5 | "sdk": {
6 | "version": "9.0.300",
7 | "rollForward": "latestPatch"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/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/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.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.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.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.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/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.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.Wpf/ListView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public static partial class Helpers
6 | {
7 | public static ListView ListView(Func itemTemplate) => ListView().ItemTemplate(DataTemplate(itemTemplate));
8 | }
9 | }
--------------------------------------------------------------------------------
/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.Wpf/Hyperlink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.Wpf
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/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.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/Platforms/Android/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World, Click Me!
4 | WinUICsMarkupExamples
5 |
6 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/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/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.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.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.Wpf/MarkupExtensions.cs:
--------------------------------------------------------------------------------
1 | using Color = System.Windows.Media.Color;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public static class MarkupExtensions
6 | {
7 | public static Color ToColor(this string color) => (Color)System.Windows.Media.ColorConverter.ConvertFromString(color);
8 | }
9 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/LiveCharts2Page.logic.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | [UIBindable]
4 | public sealed partial class LiveCharts2Page : BasePage, IBuildUI
5 | {
6 | public LiveCharts2Page() => BuildUI();
7 | }
8 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.Wpf.Examples/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
--------------------------------------------------------------------------------
/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.Presentation/Example/MapsuiViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | public partial class MapsuiViewModel(INavigator navigator) : BaseViewModel
4 | {
5 | [RelayCommand] public async Task Forward() => await navigator.NavigateViewModelAsync(this);
6 | }
7 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/ScottPlotViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace WinUICsMarkupExamples.Presentation.Example;
2 |
3 | public partial class ScottPlotViewModel(INavigator navigator) : BaseViewModel
4 | {
5 | [RelayCommand] public async Task Forward() => await navigator.NavigateViewModelAsync(this);
6 | }
7 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/WebAssembly/LinkerConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/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/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.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.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.Wpf.Examples/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/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.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/Assets/Images/search.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/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/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.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.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/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.Wpf/Readme.md:
--------------------------------------------------------------------------------
1 | Enjoy a Flutter-like UI development experience with .NET Hot Reload and the best .NET UI frameworks
2 |
3 | Build .NET applications **fully in C#**, no XAML required
4 |
5 | This preview targets WPF with C# 10 and .NET 6
6 |
7 | [Docs](https://github.com/VincentH-Net/CSharpForMarkup#readme)
8 |
9 | [Example application](https://github.com/VincentH-Net/CSharpForMarkup/tree/master/src/CSharpMarkup.Wpf.Examples)
10 |
11 | [Release Notes](https://github.com/VincentH-Net/CSharpForMarkup/releases/tag/__CSharpMarkupReleaseTag__)
12 |
--------------------------------------------------------------------------------
/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/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/MenuItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CSharpMarkup.Wpf // MenuItem
8 | {
9 | public static partial class Helpers
10 | {
11 | /// Create a
12 | /// Use named parameter to select this overload, e.g. MenuItem (Header: "First", 1, 2, 3)
13 | public static MenuItem MenuItem(object Header, params UIObject[] Items) => MenuItem(Items).Header(Header);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/ScottPlotPage.logic.cs:
--------------------------------------------------------------------------------
1 | using ScottPlot;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Example;
4 |
5 | [UIBindable]
6 | public sealed partial class ScottPlotPage : BasePage, IBuildUI
7 | {
8 | public ScottPlotPage() => BuildUI();
9 |
10 | void ExampleGraph(UISp.WinUIPlot winUIPlot)
11 | {
12 | var plot = winUIPlot.Plot;
13 | plot.Title("Example Graph");
14 | plot.Add.Signal(Generate.Sin(51));
15 | plot.Add.Signal(Generate.Cos(51));
16 | winUIPlot.Refresh();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Assets/Images/forward.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/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/StoryBoard.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public static partial class StoryboardExtensions
6 | {
7 | /// Set
8 | public static TTarget Storyboard_TargetName(this TTarget target, object? nameExpression = null, [CallerArgumentExpression("nameExpression")] string? nameExpressionString = default) where TTarget : DependencyObject
9 | { System.Windows.Media.Animation.Storyboard.SetTargetName(target.UI, Helpers.NameExpressionToName(nameExpressionString)); return target; }
10 | }
11 | }
--------------------------------------------------------------------------------
/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/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/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.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/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.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/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/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.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/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/Example/MapsuiPage.cs:
--------------------------------------------------------------------------------
1 | using Mui = CSharpMarkup.WinUI.Mapsui.Helpers;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Example;
4 |
5 | partial class MapsuiPage
6 | {
7 | enum Row { Header, Body }
8 |
9 | public void BuildUI() => Content (
10 | Grid (
11 | Rows (
12 | (Row.Header, Auto),
13 | (Row.Body , Star)
14 | ),
15 |
16 | NavigationBar(
17 | TextBlock("Mapsui"),
18 | AppBarButton() .Icon("Images/forward") .Bind(vm?.ForwardCommand)
19 | ) .Grid_Row(Row.Header),
20 |
21 | Mui.MapControl() .Invoke(CenterOnLocation)
22 | .Grid_Row(Row.Body) .HVStretch()
23 | )
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples.Presentation/Example/ScottPlotPage.cs:
--------------------------------------------------------------------------------
1 | using static CSharpMarkup.WinUI.ScottPlot.Helpers;
2 |
3 | namespace WinUICsMarkupExamples.Presentation.Example;
4 |
5 | partial class ScottPlotPage
6 | {
7 | enum Row { Header, Body }
8 |
9 | public void BuildUI() => Content (
10 | Grid (
11 | Rows (
12 | (Row.Header, Auto),
13 | (Row.Body , Star)
14 | ),
15 |
16 | NavigationBar (
17 | TextBlock("ScottPlot"),
18 | AppBarButton() .Icon("Images/forward") .Bind(vm?.ForwardCommand)
19 | ) .Grid_Row(Row.Header),
20 |
21 | WinUIPlot() .Invoke(ExampleGraph)
22 | .Grid_Row(Row.Body) .HVStretch()
23 | )
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/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/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.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.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.Wpf/Attributes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.Wpf
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/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.ScottPlot/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [ScottPlot.WinUI](https://www.nuget.org/packages/ScottPlot.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__-scottplot)
--------------------------------------------------------------------------------
/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.Examples/WinUICsMarkupExamples.Presentation/Example/LiveCharts2ViewModel.cs:
--------------------------------------------------------------------------------
1 | using LiveChartsCore;
2 | using LiveChartsCore.SkiaSharpView;
3 |
4 | namespace WinUICsMarkupExamples.Presentation.Example;
5 |
6 | public partial class LiveCharts2ViewModel(INavigator navigator) : BaseViewModel
7 | {
8 | public ISeries[] SeriesCollection { get; set; } = [
9 | new LineSeries(Fetch())
10 | ];
11 |
12 | static int[] Fetch()
13 | {
14 | var values = new int[100];
15 | var r = new Random();
16 | var t = 0;
17 |
18 | for (var i = 0; i < 100; i++)
19 | {
20 | t += r.Next(-90, 100);
21 | values[i] = t;
22 | }
23 |
24 | return values;
25 | }
26 |
27 | [RelayCommand] public async Task Forward() => await navigator.NavigateViewModelAsync(this);
28 | }
29 |
--------------------------------------------------------------------------------
/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.Mapsui/Readme.md:
--------------------------------------------------------------------------------
1 | [C# Markup 2](https://github.com/VincentH-Net/CSharpForMarkup) API for [Mapsui.Uno.WinUI](https://www.nuget.org/packages/Mapsui.Uno.WinUI/5.0.0-beta.17) 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__-mapsui-beta-17)
--------------------------------------------------------------------------------
/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.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.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.Wpf/Thickness.cs:
--------------------------------------------------------------------------------
1 | using Windows = System.Windows;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public static partial class Helpers
6 | {
7 | public static Windows.Thickness Thickness(double uniform) => new Windows.Thickness { Left = uniform, Top = uniform, Right = uniform, Bottom = uniform };
8 | public static Windows.Thickness Thickness(double horizontal, double vertical) => new Windows.Thickness { Left = horizontal, Top = vertical, Right = horizontal, Bottom = vertical };
9 | public static Windows.Thickness Thickness(double left, double top, double right, double bottom) => new Windows.Thickness { Left = left, Top = top, Right = right, Bottom = bottom };
10 | public static Windows.Thickness Thicknesses(double left = 0, double top = 0, double right = 0, double bottom = 0) => new Windows.Thickness { Left = left, Top = top, Right = right, Bottom = bottom };
11 | }
12 | }
--------------------------------------------------------------------------------
/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.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.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.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.Examples/WinUICsMarkupExamples.Presentation/Example/LiveCharts2Page.cs:
--------------------------------------------------------------------------------
1 | using CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView;
2 | using static CSharpMarkup.WinUI.LiveChartsCore.SkiaSharpView.Helpers;
3 |
4 | namespace WinUICsMarkupExamples.Presentation.Example;
5 |
6 | partial class LiveCharts2Page
7 | {
8 | enum Row { Header, Body }
9 |
10 | public void BuildUI() => Content (
11 | Grid (
12 | Rows (
13 | (Row.Header, Auto),
14 | (Row.Body , Star)
15 | ),
16 |
17 | NavigationBar(
18 | TextBlock("LiveCharts2"),
19 | AppBarButton() .Icon("Images/forward") .Bind(vm?.ForwardCommand)
20 | ) .Grid_Row(Row.Header),
21 |
22 | CartesianChart(ZoomMode: LiveChartsCore.Measure.ZoomAndPanMode.X)
23 | .Series().Bind(vm?.SeriesCollection)
24 | .Grid_Row(Row.Body) .HVStretch()
25 | )
26 | ) .Background(Microsoft.UI.Colors.White);
27 | }
28 |
--------------------------------------------------------------------------------
/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-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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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/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.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.Wpf/StackPanel.cs:
--------------------------------------------------------------------------------
1 | using Windows = System.Windows;
2 |
3 | namespace CSharpMarkup.Wpf
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 Windows.UIElement[] children) => StackPanel(children).Orientation().Horizontal();
10 |
11 | ///Short for:StackPanel().Orientation().Vertical()
12 | [ShortFor("StackPanel().Orientation().Vertical()")]
13 | public static StackPanel VStack(params Windows.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 Windows.UIElement[] children)
18 | {
19 | foreach (var child in children) panel.UI.Children.Add(child);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.Examples/WinUICsMarkupExamples/Platforms/Android/Resources/values/Styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
20 |
21 |
25 |
26 |
--------------------------------------------------------------------------------
/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.WinUI.Mapsui/_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.Mapsui.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.Mapsui
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 | // TODO: e.g. Mapsui...Property,
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::Mapsui.UI.WinUI.MapControl)
32 | };
33 | #endif
34 | }
35 | }
--------------------------------------------------------------------------------
/src/CSharpMarkup.WinUI.ScottPlot/_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.ScottPlot.Helpers)
9 | )]
10 | #endif
11 |
12 | namespace CSharpMarkup.WinUI.ScottPlot
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 | // TODO: e.g. ScottPlot...Property,
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::ScottPlot.WinUI.WinUIPlot)
32 | };
33 | #endif
34 | }
35 | }
--------------------------------------------------------------------------------
/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.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/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/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/Example/MapsuiPage.logic.cs:
--------------------------------------------------------------------------------
1 | using Mapsui;
2 | using Mapsui.Extensions;
3 | using Mapsui.Projections;
4 | using Mapsui.Tiling;
5 | using MuiUI = Mapsui.UI.WinUI;
6 |
7 | namespace WinUICsMarkupExamples.Presentation.Example;
8 |
9 | [UIBindable]
10 | public sealed partial class MapsuiPage : BasePage, IBuildUI
11 | {
12 | public MapsuiPage() => BuildUI();
13 |
14 | void CenterOnLocation(MuiUI.MapControl control)
15 | {
16 | var map = new Map();
17 | map.Layers.Add(OpenStreetMap.CreateTileLayer());
18 |
19 | // Get the lon lat coordinates from somewhere (Mapsui can not help you there)
20 | var centerOfLondonOntario = new MPoint(-81.2497, 42.9837);
21 | // OSM uses spherical mercator coordinates. So transform the lon lat coordinates to spherical mercator
22 | var sphericalMercatorCoordinate = SphericalMercator.FromLonLat(centerOfLondonOntario.X, centerOfLondonOntario.Y).ToMPoint();
23 | // Set the center of the viewport to the coordinate. The UI will refresh automatically
24 | // Additionally you might want to set the resolution, this could depend on your specific purpose
25 | map.Navigator.CenterOnAndZoomTo(sphericalMercatorCoordinate, map.Navigator.Resolutions[9]);
26 |
27 | control.Map = map;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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.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.Examples/WinUICsMarkupExamples/Assets/Icons/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
43 |
--------------------------------------------------------------------------------
/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.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.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.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 | new ViewMap(),
12 | new ViewMap(),
13 | new ViewMap()
14 | );
15 |
16 | routes.Register(
17 | new RouteMap("", View: views.FindByViewModel(),
18 | Nested: new RouteMap[]
19 | {
20 | new RouteMap("Search", View: views.FindByViewModel(), IsDefault:true),
21 | new RouteMap("LiveCharts", View: views.FindByViewModel()),
22 | new RouteMap("ScottPlot", View: views.FindByViewModel()),
23 | new RouteMap("Mapsui", View: views.FindByViewModel()),
24 | new RouteMap("Flutter", View: views.FindByViewModel())
25 | }
26 | )
27 | );
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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/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.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/WinUICsMarkupExamples/Styles/Example.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildThisFileDirectory)NuGet
5 | true
6 | $(BaseIntermediateOutputPath)ReadmeTransform
7 | $(IntermediateReadmeDir)\Readme.md
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/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/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/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/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.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.Wpf/NameScopes.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public static class NameScopeExtensions
6 | {
7 | static System.Collections.Generic.List<(string name, System.Windows.Threading.DispatcherObject scopedElement)> namescopeRegistrations = new(20);
8 |
9 | public static TDispatcherObject xName(this TDispatcherObject dispatcherObject, object? nameExpression = null, [CallerArgumentExpression("nameExpression")] string? nameExpressionString = default) where TDispatcherObject : DispatcherObject
10 | {
11 | namescopeRegistrations.Add((Helpers.NameExpressionToName(nameExpressionString), dispatcherObject.UI));
12 | return dispatcherObject;
13 | }
14 |
15 | public static TFrameworkElement WithNameScope(this TFrameworkElement frameworkElement) where TFrameworkElement : FrameworkElement
16 | {
17 | System.Windows.NameScope.SetNameScope(frameworkElement.UI, new System.Windows.NameScope());
18 |
19 | // Since child elements in C# are created before their parent element (which is the other way around in XAML),
20 | // at this point any calls to xName for this namescope have been executed.
21 | // So we can add all names to the namescope here.
22 | foreach ((var name, var scopedElement) in namescopeRegistrations)
23 | frameworkElement.UI.RegisterName(name, scopedElement);
24 | namescopeRegistrations.Clear();
25 |
26 | return frameworkElement;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/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 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/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.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.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.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/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.Wpf/Style.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using Windows = System.Windows;
4 |
5 | namespace CSharpMarkup.Wpf
6 | {
7 | public static partial class Helpers
8 | {
9 | // TODO: ? how to let intellisense offer only styles for the type?
10 | // will helper .Style(this T, Style style) interfere with the generated .Style(this T, Style style)?
11 |
12 | public static Style Style(Windows.DependencyProperty property, UIObject value) where T : DependencyObject
13 | => new Style(property, value);
14 |
15 | public static Style Style(params (Windows.DependencyProperty property, UIObject value)[] setters) where T : DependencyObject
16 | => new Style(setters);
17 | }
18 |
19 | public static partial class FrameworkElementExtensions
20 | {
21 | /// Set to a type-safe
22 | public static TView Style(this TView view, Style style) where TView : FrameworkElement { view.UI.Style = style; return view; }
23 | }
24 |
25 | public class Style : Style where T : DependencyObject
26 | {
27 | void Initialize() => UI = new Windows.Style(typeof(T).GetProperty("UI", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).PropertyType);
28 |
29 | public Style() => Initialize();
30 |
31 | public Style(Windows.DependencyProperty property, UIObject value) { Initialize(); Set(property, value); }
32 |
33 | public Style(params (Windows.DependencyProperty property, UIObject value)[] setters) { Initialize(); Set(setters); }
34 |
35 | public Style Set(Windows.DependencyProperty property, UIObject value) => Set((property, value));
36 |
37 | public Style Set(params (Windows.DependencyProperty property, UIObject value)[] setters)
38 | {
39 | foreach ((var property, var value) in setters)
40 | UI.Setters.Add(new Windows.Setter(property, value.UI));
41 | return this;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/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.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.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/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.Wpf/InlineCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public static partial class Helpers
6 | {
7 | public static void Add(this System.Windows.Documents.InlineCollection inlines, InlineCollectionItem item)
8 | {
9 | switch (item.TypeIndex)
10 | {
11 | case 1: inlines.Add(item.T1Value); break;
12 | case 2: inlines.Add(item.T2Value); break;
13 | case 3: inlines.Add(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(System.Windows.Documents.Inline value) : base(value) { }
27 | InlineCollectionItem(System.Windows.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.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/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.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 | global using UISp = ScottPlot.WinUI;
38 |
39 | // - Non-view types, e.g. enums, don't need a UI prefix because they are not mirrored as types in the CSharpMarkup namespaces
40 | global using BindingMode = Microsoft.UI.Xaml.Data.BindingMode;
41 | global using Visibility = Microsoft.UI.Xaml.Visibility;
42 |
43 | // Example-specific global usings:
44 | global using static Microsoft.UI.Colors; // Or use an application specific palette class; can have dynamic values for theming
45 | global using Tweet = WinUICsMarkupExamples.Presentation.Example.SearchViewModel.Tweet;
46 |
--------------------------------------------------------------------------------
/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.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.Wpf/DefaultBindProperties.cs:
--------------------------------------------------------------------------------
1 | using Controls = System.Windows.Controls;
2 |
3 | namespace CSharpMarkup.Wpf
4 | {
5 | public interface IDefaultBindProperty // TODO: Generate this automatically if only one possibility
6 | {
7 | System.Windows.DependencyProperty DefaultBindProperty { get; }
8 | }
9 |
10 | 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?
11 | {
12 | System.Windows.DependencyProperty DefaultBindCommandProperty { get; }
13 | System.Windows.DependencyProperty DefaultBindCommandParameterProperty { get; }
14 | }
15 |
16 | //public partial class MenuFlyoutItem : IDefaultBindCommandProperties
17 | //{
18 | // public DependencyProperty DefaultBindCommandProperty => Controls.MenuFlyoutItem.CommandProperty;
19 | // public DependencyProperty DefaultBindCommandParameterProperty => Controls.MenuFlyoutItem.CommandParameterProperty;
20 | //}
21 |
22 | //public partial class SplitButton : IDefaultBindCommandProperties
23 | //{
24 | // public DependencyProperty DefaultBindCommandProperty => Controls.SplitButton.CommandProperty;
25 | // public DependencyProperty DefaultBindCommandParameterProperty => Controls.SplitButton.CommandParameterProperty;
26 | //}
27 |
28 | //public partial class SwipeItem : IDefaultBindCommandProperties
29 | //{
30 | // public DependencyProperty DefaultBindCommandProperty => Controls.SwipeItem.CommandProperty;
31 | // public DependencyProperty DefaultBindCommandParameterProperty => Controls.SwipeItem.CommandParameterProperty;
32 | //}
33 |
34 | //public partial class TabView : IDefaultBindCommandProperties
35 | //{
36 | // public DependencyProperty DefaultBindCommandProperty => Controls.TabView.AddTabButtonCommandProperty;
37 | // public DependencyProperty DefaultBindCommandParameterProperty => Controls.TabView.AddTabButtonCommandParameterProperty;
38 | //}
39 |
40 | public partial class ButtonBase : IDefaultBindCommandProperties
41 | {
42 | public System.Windows.DependencyProperty DefaultBindCommandProperty => Controls.Primitives.ButtonBase.CommandProperty;
43 | public System.Windows.DependencyProperty DefaultBindCommandParameterProperty => Controls.Primitives.ButtonBase.CommandParameterProperty;
44 | }
45 | }
--------------------------------------------------------------------------------
/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