Browse Source

Merge branch 'master' into fixes/8869-show-windowstate

pull/9221/head
Steven Kirk 4 years ago
committed by GitHub
parent
commit
3a550fac30
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .ncrunch/Avalonia.Web.Blazor.v3.ncrunchproject
  2. 5
      .ncrunch/Avalonia.Web.v3.ncrunchproject
  3. 6
      .ncrunch/Avalonia.Win32.net6.0.v3.ncrunchproject
  4. 6
      .ncrunch/Avalonia.Win32.netstandard2.0.v3.ncrunchproject
  5. 5
      .ncrunch/ControlCatalog.Blazor.Web.v3.ncrunchproject
  6. 5
      .ncrunch/MobileSandbox.Android.v3.ncrunchproject
  7. 5
      .ncrunch/MobileSandbox.Desktop.v3.ncrunchproject
  8. 5
      .ncrunch/MobileSandbox.iOS.v3.ncrunchproject
  9. 5
      .ncrunch/MobileSandbox.net6.0.v3.ncrunchproject
  10. 5
      .ncrunch/MobileSandbox.netstandard2.0.v3.ncrunchproject
  11. 5
      .ncrunch/_build.v3.ncrunchproject
  12. 60
      Avalonia.Desktop.slnf
  13. 2
      Avalonia.sln
  14. 5
      Directory.Build.targets
  15. 38
      Documentation/build.md
  16. 10
      azure-pipelines-integrationtests.yml
  17. 12
      azure-pipelines.yml
  18. 1
      build/BuildTargets.targets
  19. 2
      build/SharedVersion.props
  20. 2
      global.json
  21. 4
      native/Avalonia.Native/src/OSX/AvnWindow.mm
  22. 4
      native/Avalonia.Native/src/OSX/Screens.mm
  23. 4
      native/Avalonia.Native/src/OSX/WindowImpl.mm
  24. 11
      native/Avalonia.Native/src/OSX/app.mm
  25. 2
      native/Avalonia.Native/src/OSX/common.h
  26. 41
      native/Avalonia.Native/src/OSX/main.mm
  27. 13
      native/Avalonia.Native/src/OSX/menu.h
  28. 26
      native/Avalonia.Native/src/OSX/menu.mm
  29. 5
      native/Avalonia.Native/src/OSX/rendertarget.mm
  30. 19
      nukebuild/Build.cs
  31. 6
      nukebuild/_build.csproj
  32. 4
      packages/Avalonia/AvaloniaBuildTasks.targets
  33. 2
      readme.md
  34. 6
      samples/BindingDemo/MainWindow.xaml
  35. 6
      samples/BindingDemo/TestItemView.xaml
  36. 8
      samples/ControlCatalog.Blazor.Web/Properties/launchSettings.json
  37. 2
      samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj
  38. 5
      samples/ControlCatalog.Web/ControlCatalog.Web.csproj
  39. 1
      samples/ControlCatalog.Web/Roots.xml
  40. 1
      samples/ControlCatalog/App.xaml
  41. 15
      samples/ControlCatalog/ControlCatalog.csproj
  42. 11
      samples/ControlCatalog/DecoratedWindow.xaml
  43. 17
      samples/ControlCatalog/MainView.xaml
  44. 11
      samples/ControlCatalog/MainWindow.xaml
  45. 12
      samples/ControlCatalog/MainWindow.xaml.cs
  46. 20
      samples/ControlCatalog/Models/StateData.cs
  47. 6
      samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml
  48. 20
      samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs
  49. 1
      samples/ControlCatalog/Pages/BorderPage.xaml
  50. 2
      samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml
  51. 2
      samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml
  52. 25
      samples/ControlCatalog/Pages/ColorPickerPage.xaml
  53. 1
      samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs
  54. 8
      samples/ControlCatalog/Pages/ComboBoxPage.xaml
  55. 4
      samples/ControlCatalog/Pages/CompositionPage.axaml
  56. 6
      samples/ControlCatalog/Pages/ContextFlyoutPage.xaml
  57. 6
      samples/ControlCatalog/Pages/ContextMenuPage.xaml
  58. 6
      samples/ControlCatalog/Pages/CursorPage.xaml
  59. 30
      samples/ControlCatalog/Pages/DataGridPage.xaml
  60. 2
      samples/ControlCatalog/Pages/DateTimePickerPage.xaml
  61. 21
      samples/ControlCatalog/Pages/ExpanderPage.xaml
  62. 8
      samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
  63. 4
      samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
  64. 4
      samples/ControlCatalog/Pages/LabelsPage.axaml
  65. 4
      samples/ControlCatalog/Pages/ListBoxPage.xaml
  66. 8
      samples/ControlCatalog/Pages/MenuPage.xaml
  67. 4
      samples/ControlCatalog/Pages/NotificationsPage.xaml
  68. 15
      samples/ControlCatalog/Pages/NotificationsPage.xaml.cs
  69. 11
      samples/ControlCatalog/Pages/NumericUpDownPage.xaml
  70. 3
      samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs
  71. 2
      samples/ControlCatalog/Pages/OpenGlPage.xaml
  72. 53
      samples/ControlCatalog/Pages/PlatformInfoPage.xaml
  73. 20
      samples/ControlCatalog/Pages/PlatformInfoPage.xaml.cs
  74. 2
      samples/ControlCatalog/Pages/ProgressBarPage.xaml
  75. 4
      samples/ControlCatalog/Pages/ScreenPage.cs
  76. 4
      samples/ControlCatalog/Pages/ScrollViewerPage.xaml
  77. 2
      samples/ControlCatalog/Pages/SliderPage.xaml
  78. 6
      samples/ControlCatalog/Pages/SplitViewPage.xaml
  79. 10
      samples/ControlCatalog/Pages/TabControlPage.xaml
  80. 32
      samples/ControlCatalog/Pages/TabControlPage.xaml.cs
  81. 10
      samples/ControlCatalog/Pages/TabStripPage.xaml
  82. 40
      samples/ControlCatalog/Pages/TabStripPage.xaml.cs
  83. 4
      samples/ControlCatalog/Pages/TextBlockPage.xaml
  84. 2
      samples/ControlCatalog/Pages/TextBoxPage.xaml
  85. 3
      samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml
  86. 4
      samples/ControlCatalog/Pages/TreeViewPage.xaml
  87. 2
      samples/ControlCatalog/Pages/ViewboxPage.xaml
  88. 4
      samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml
  89. 20
      samples/ControlCatalog/ViewModels/CursorPageViewModel.cs
  90. 44
      samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs
  91. 32
      samples/ControlCatalog/ViewModels/MainWindowViewModel.cs
  92. 29
      samples/ControlCatalog/ViewModels/NotificationViewModel.cs
  93. 54
      samples/ControlCatalog/ViewModels/PlatformInformationViewModel.cs
  94. 26
      samples/ControlCatalog/ViewModels/TabControlPageViewModel.cs
  95. 4
      samples/ControlCatalog/Views/CustomNotificationView.xaml
  96. 2
      samples/IntegrationTestApp/IntegrationTestApp.csproj
  97. 21
      samples/IntegrationTestApp/MainWindow.axaml
  98. 34
      samples/IntegrationTestApp/MainWindow.axaml.cs
  99. 1
      samples/IntegrationTestApp/ShowWindowTest.axaml
  100. 1
      samples/MobileSandbox/App.xaml

5
.ncrunch/Avalonia.Web.Blazor.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/Avalonia.Web.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

6
.ncrunch/Avalonia.Win32.net6.0.v3.ncrunchproject

@ -1,7 +1,3 @@
<ProjectConfiguration> <ProjectConfiguration>
<Settings> <Settings />
<AdditionalFilesToIncludeForProject>
<Value>..\..\tools\MicroComGenerator\bin\Debug\net6.0\**.*</Value>
</AdditionalFilesToIncludeForProject>
</Settings>
</ProjectConfiguration> </ProjectConfiguration>

6
.ncrunch/Avalonia.Win32.netstandard2.0.v3.ncrunchproject

@ -1,7 +1,3 @@
<ProjectConfiguration> <ProjectConfiguration>
<Settings> <Settings />
<AdditionalFilesToIncludeForProject>
<Value>..\..\tools\MicroComGenerator\bin\Debug\net6.0\**.*</Value>
</AdditionalFilesToIncludeForProject>
</Settings>
</ProjectConfiguration> </ProjectConfiguration>

5
.ncrunch/ControlCatalog.Blazor.Web.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/MobileSandbox.Android.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/MobileSandbox.Desktop.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/MobileSandbox.iOS.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/MobileSandbox.net6.0.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/MobileSandbox.netstandard2.0.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/_build.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

60
Avalonia.Desktop.slnf

@ -0,0 +1,60 @@
{
"solution": {
"path": "Avalonia.sln",
"projects": [
"packages\\Avalonia\\Avalonia.csproj",
"samples\\ControlCatalog.NetCore\\ControlCatalog.NetCore.csproj",
"samples\\ControlCatalog\\ControlCatalog.csproj",
"samples\\IntegrationTestApp\\IntegrationTestApp.csproj",
"samples\\MiniMvvm\\MiniMvvm.csproj",
"samples\\SampleControls\\ControlSamples.csproj",
"samples\\Sandbox\\Sandbox.csproj",
"src\\Avalonia.Base\\Avalonia.Base.csproj",
"src\\Avalonia.Build.Tasks\\Avalonia.Build.Tasks.csproj",
"src\\Avalonia.Controls.ColorPicker\\Avalonia.Controls.ColorPicker.csproj",
"src\\Avalonia.Controls.DataGrid\\Avalonia.Controls.DataGrid.csproj",
"src\\Avalonia.Controls\\Avalonia.Controls.csproj",
"src\\Avalonia.DesignerSupport\\Avalonia.DesignerSupport.csproj",
"src\\Avalonia.Desktop\\Avalonia.Desktop.csproj",
"src\\Avalonia.Diagnostics\\Avalonia.Diagnostics.csproj",
"src\\Avalonia.Dialogs\\Avalonia.Dialogs.csproj",
"src\\Avalonia.FreeDesktop\\Avalonia.FreeDesktop.csproj",
"src\\Avalonia.Headless.Vnc\\Avalonia.Headless.Vnc.csproj",
"src\\Avalonia.Headless\\Avalonia.Headless.csproj",
"src\\Avalonia.MicroCom\\Avalonia.MicroCom.csproj",
"src\\Avalonia.Native\\Avalonia.Native.csproj",
"src\\Avalonia.OpenGL\\Avalonia.OpenGL.csproj",
"src\\Avalonia.ReactiveUI\\Avalonia.ReactiveUI.csproj",
"src\\Avalonia.Remote.Protocol\\Avalonia.Remote.Protocol.csproj",
"src\\Avalonia.Themes.Fluent\\Avalonia.Themes.Fluent.csproj",
"src\\Avalonia.Themes.Simple\\Avalonia.Themes.Simple.csproj",
"src\\Avalonia.X11\\Avalonia.X11.csproj",
"src\\Linux\\Avalonia.LinuxFramebuffer\\Avalonia.LinuxFramebuffer.csproj",
"src\\Markup\\Avalonia.Markup.Xaml.Loader\\Avalonia.Markup.Xaml.Loader.csproj",
"src\\Markup\\Avalonia.Markup.Xaml\\Avalonia.Markup.Xaml.csproj",
"src\\Markup\\Avalonia.Markup\\Avalonia.Markup.csproj",
"src\\Skia\\Avalonia.Skia\\Avalonia.Skia.csproj",
"src\\Windows\\Avalonia.Direct2D1\\Avalonia.Direct2D1.csproj",
"src\\Windows\\Avalonia.Win32.Interop\\Avalonia.Win32.Interop.csproj",
"src\\Windows\\Avalonia.Win32\\Avalonia.Win32.csproj",
"src\\tools\\DevAnalyzers\\DevAnalyzers.csproj",
"src\\tools\\DevGenerators\\DevGenerators.csproj",
"tests\\Avalonia.Base.UnitTests\\Avalonia.Base.UnitTests.csproj",
"tests\\Avalonia.Benchmarks\\Avalonia.Benchmarks.csproj",
"tests\\Avalonia.Controls.DataGrid.UnitTests\\Avalonia.Controls.DataGrid.UnitTests.csproj",
"tests\\Avalonia.Controls.UnitTests\\Avalonia.Controls.UnitTests.csproj",
"tests\\Avalonia.DesignerSupport.TestApp\\Avalonia.DesignerSupport.TestApp.csproj",
"tests\\Avalonia.DesignerSupport.Tests\\Avalonia.DesignerSupport.Tests.csproj",
"tests\\Avalonia.Direct2D1.RenderTests\\Avalonia.Direct2D1.RenderTests.csproj",
"tests\\Avalonia.Direct2D1.UnitTests\\Avalonia.Direct2D1.UnitTests.csproj",
"tests\\Avalonia.IntegrationTests.Appium\\Avalonia.IntegrationTests.Appium.csproj",
"tests\\Avalonia.LeakTests\\Avalonia.LeakTests.csproj",
"tests\\Avalonia.Markup.UnitTests\\Avalonia.Markup.UnitTests.csproj",
"tests\\Avalonia.Markup.Xaml.UnitTests\\Avalonia.Markup.Xaml.UnitTests.csproj",
"tests\\Avalonia.ReactiveUI.UnitTests\\Avalonia.ReactiveUI.UnitTests.csproj",
"tests\\Avalonia.Skia.RenderTests\\Avalonia.Skia.RenderTests.csproj",
"tests\\Avalonia.Skia.UnitTests\\Avalonia.Skia.UnitTests.csproj",
"tests\\Avalonia.UnitTests\\Avalonia.UnitTests.csproj"
]
}
}

2
Avalonia.sln

@ -41,6 +41,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{A689DE
src\Shared\IsExternalInit.cs = src\Shared\IsExternalInit.cs src\Shared\IsExternalInit.cs = src\Shared\IsExternalInit.cs
src\Shared\ModuleInitializer.cs = src\Shared\ModuleInitializer.cs src\Shared\ModuleInitializer.cs = src\Shared\ModuleInitializer.cs
src\Shared\SourceGeneratorAttributes.cs = src\Shared\SourceGeneratorAttributes.cs src\Shared\SourceGeneratorAttributes.cs = src\Shared\SourceGeneratorAttributes.cs
src\Avalonia.Base\Compatibility\StringCompatibilityExtensions.cs = src\Avalonia.Base\Compatibility\StringCompatibilityExtensions.cs
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI", "src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj", "{6417B24E-49C2-4985-8DB2-3AB9D898EC91}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI", "src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj", "{6417B24E-49C2-4985-8DB2-3AB9D898EC91}"
@ -521,6 +522,7 @@ Global
{3B8519C1-2F51-4F12-A348-120AB91D4532}.Release|Any CPU.Build.0 = Release|Any CPU {3B8519C1-2F51-4F12-A348-120AB91D4532}.Release|Any CPU.Build.0 = Release|Any CPU
{C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.Build.0 = Debug|Any CPU {C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{C90FE60B-B01E-4F35-91D6-379D6966030F}.Release|Any CPU.ActiveCfg = Release|Any CPU {C90FE60B-B01E-4F35-91D6-379D6966030F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C90FE60B-B01E-4F35-91D6-379D6966030F}.Release|Any CPU.Build.0 = Release|Any CPU {C90FE60B-B01E-4F35-91D6-379D6966030F}.Release|Any CPU.Build.0 = Release|Any CPU
{FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

5
Directory.Build.targets

@ -0,0 +1,5 @@
<Project>
<PropertyGroup Condition="$(NETCoreSdkVersion.StartsWith('7.0'))">
<DefineConstants>$(DefineConstants);NET7SDK</DefineConstants>
</PropertyGroup>
</Project>

38
Documentation/build.md

@ -1,8 +1,8 @@
# Windows # Windows
Avalonia requires at least Visual Studio 2022 and dotnet 6 SDK 6.0.100 to build on all platforms. Avalonia requires at least Visual Studio 2022 and dotnet 7-rc2 SDK 7.0.100-rc.2 to build on all platforms.
### Clone the Avalonia repository ## Clone the Avalonia repository
``` ```
git clone https://github.com/AvaloniaUI/Avalonia.git git clone https://github.com/AvaloniaUI/Avalonia.git
@ -10,15 +10,30 @@ cd Avalonia
git submodule update --init git submodule update --init
``` ```
### Install the required version of the .NET Core SDK ## Install the required version of the .NET Core SDK
Go to https://dotnet.microsoft.com/download/visual-studio-sdks and install the latest version of the .NET Core SDK compatible with Avalonia UI. Make sure to download the SDK (not just the "runtime") package. The version compatible is indicated within the [global.json](https://github.com/AvaloniaUI/Avalonia/blob/master/global.json) file. Note that Avalonia UI does not always use the latest version and is hardcoded to use the last version known to be compatible (SDK releases may break the builds from time-to-time). Go to https://dotnet.microsoft.com/download/visual-studio-sdks and install the latest version of the .NET Core SDK compatible with Avalonia UI. Make sure to download the SDK (not just the "runtime") package. The version compatible is indicated within the [global.json](https://github.com/AvaloniaUI/Avalonia/blob/master/global.json) file. Note that Avalonia UI does not always use the latest version and is hardcoded to use the last version known to be compatible (SDK releases may break the builds from time-to-time).
### Open in Visual Studio ## Build and Run Avalonia
Open the `Avalonia.sln` solution in Visual Studio 2022 or newer. The free Visual Studio Community edition works fine. Build and run the `Samples\ControlCatalog.Desktop` or `ControlCatalog.NetCore` project to see the sample application. ```
cd samples\ControlCatalog.NetCore
dotnet restore
dotnet run
```
## Opening in Visual Studio
### Troubleshooting If you want to open Avalonia in Visual Studio you have two options:
- Avalonia.sln: This contains the whole of Avalonia in including desktop, mobile and web. You must have a number of dotnet workloads installed in order to build everything in this solution
- Avalonia.Desktop.slnf: This solution filter opens only the parts of Avalonia required to run on desktop. This requires no extra workloads to be installed.
Avalonia requires Visual Studio 2022 or newer. The free Visual Studio Community edition works fine.
Build and run `ControlCatalog.NetCore` project to see the sample application.
### Visual Studio Troubleshooting
* **Error CS0006: Avalonia.DesktopRuntime.dll could not be found** * **Error CS0006: Avalonia.DesktopRuntime.dll could not be found**
@ -35,16 +50,15 @@ It's *not* possible to build the *whole* project on Linux/macOS. You can only bu
MonoDevelop, Xamarin Studio and Visual Studio for Mac aren't capable of properly opening our solution. You can use Rider (at least 2017.2 EAP) or VSCode instead. They will fail to load most of platform specific projects, but you don't need them to run on .NET Core. MonoDevelop, Xamarin Studio and Visual Studio for Mac aren't capable of properly opening our solution. You can use Rider (at least 2017.2 EAP) or VSCode instead. They will fail to load most of platform specific projects, but you don't need them to run on .NET Core.
### Install the latest version of the .NET Core SDK ## Install the latest version of the .NET Core SDK
Go to https://www.microsoft.com/net/core and follow the instructions for your OS. Make sure to download the SDK (not just the "runtime") package. Go to https://www.microsoft.com/net/core and follow the instructions for your OS. Make sure to download the SDK (not just the "runtime") package.
### Additional requirements for macOS ## Additional requirements for macOS
The build process needs [Xcode](https://developer.apple.com/xcode/) to build the native library. Following the install instructions at the [Xcode](https://developer.apple.com/xcode/) website to properly install. The build process needs [Xcode](https://developer.apple.com/xcode/) to build the native library. Following the install instructions at the [Xcode](https://developer.apple.com/xcode/) website to properly install.
## Clone the Avalonia repository
### Clone the Avalonia repository
``` ```
git clone https://github.com/AvaloniaUI/Avalonia.git git clone https://github.com/AvaloniaUI/Avalonia.git
@ -52,7 +66,7 @@ cd Avalonia
git submodule update --init --recursive git submodule update --init --recursive
``` ```
### Build native libraries (macOS only) ## Build native libraries (macOS only)
On macOS it is necessary to build and manually install the respective native libraries using [Xcode](https://developer.apple.com/xcode/). Execute the build script in the root project with the `CompileNative` task. It will build the headers, build the libraries, and place them in the appropriate place to allow .NET to find them at compilation and run time. On macOS it is necessary to build and manually install the respective native libraries using [Xcode](https://developer.apple.com/xcode/). Execute the build script in the root project with the `CompileNative` task. It will build the headers, build the libraries, and place them in the appropriate place to allow .NET to find them at compilation and run time.
@ -60,7 +74,7 @@ On macOS it is necessary to build and manually install the respective native lib
./build.sh CompileNative ./build.sh CompileNative
``` ```
### Build and Run Avalonia ## Build and Run Avalonia
``` ```
cd samples/ControlCatalog.NetCore cd samples/ControlCatalog.NetCore

10
azure-pipelines-integrationtests.yml

@ -18,9 +18,9 @@ jobs:
version: 6.0.401 version: 6.0.401
- task: UseDotNet@2 - task: UseDotNet@2
displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' displayName: 'Use .NET Core SDK 7.0.100'
inputs: inputs:
version: 7.0.100-rc.2.22477.23 version: 7.0.100
- script: system_profiler SPDisplaysDataType |grep Resolution - script: system_profiler SPDisplaysDataType |grep Resolution
@ -32,7 +32,7 @@ jobs:
rm -rf $(osascript -e "POSIX path of (path to application id \"net.avaloniaui.avalonia.integrationtestapp\")") rm -rf $(osascript -e "POSIX path of (path to application id \"net.avaloniaui.avalonia.integrationtestapp\")")
pkill IntegrationTestApp pkill IntegrationTestApp
./samples/IntegrationTestApp/bundle.sh ./samples/IntegrationTestApp/bundle.sh
open -n ./samples/IntegrationTestApp/bin/Debug/net6.0/osx-arm64/publish/IntegrationTestApp.app open -n ./samples/IntegrationTestApp/bin/Debug/net7.0/osx-arm64/publish/IntegrationTestApp.app
pkill IntegrationTestApp pkill IntegrationTestApp
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
@ -56,9 +56,9 @@ jobs:
version: 6.0.401 version: 6.0.401
- task: UseDotNet@2 - task: UseDotNet@2
displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' displayName: 'Use .NET Core SDK 7.0.100'
inputs: inputs:
version: 7.0.100-rc.2.22477.23 version: 7.0.100
- task: Windows Application Driver@0 - task: Windows Application Driver@0
inputs: inputs:

12
azure-pipelines.yml

@ -35,9 +35,9 @@ jobs:
version: 6.0.401 version: 6.0.401
- task: UseDotNet@2 - task: UseDotNet@2
displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' displayName: 'Use .NET Core SDK 7.0'
inputs: inputs:
version: 7.0.100-rc.2.22477.23 version: 7.0.100
- task: CmdLine@2 - task: CmdLine@2
displayName: 'Install Workloads' displayName: 'Install Workloads'
@ -72,9 +72,9 @@ jobs:
version: 6.0.401 version: 6.0.401
- task: UseDotNet@2 - task: UseDotNet@2
displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' displayName: 'Use .NET Core SDK 7.0.100'
inputs: inputs:
version: 7.0.100-rc.2.22477.23 version: 7.0.100
- task: CmdLine@2 - task: CmdLine@2
displayName: 'Install Workloads' displayName: 'Install Workloads'
@ -143,9 +143,9 @@ jobs:
version: 6.0.401 version: 6.0.401
- task: UseDotNet@2 - task: UseDotNet@2
displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' displayName: 'Use .NET Core SDK 7.0.100'
inputs: inputs:
version: 7.0.100-rc.2.22477.23 version: 7.0.100
- task: CmdLine@2 - task: CmdLine@2
displayName: 'Install Workloads' displayName: 'Install Workloads'

1
build/BuildTargets.targets

@ -3,6 +3,7 @@
<AvaloniaBuildTasksLocation>$(MSBuildThisFileDirectory)\..\src\Avalonia.Build.Tasks\bin\$(Configuration)\netstandard2.0\Avalonia.Build.Tasks.dll</AvaloniaBuildTasksLocation> <AvaloniaBuildTasksLocation>$(MSBuildThisFileDirectory)\..\src\Avalonia.Build.Tasks\bin\$(Configuration)\netstandard2.0\Avalonia.Build.Tasks.dll</AvaloniaBuildTasksLocation>
<AvaloniaUseExternalMSBuild>true</AvaloniaUseExternalMSBuild> <AvaloniaUseExternalMSBuild>true</AvaloniaUseExternalMSBuild>
<AvaloniaXamlIlVerifyIl>true</AvaloniaXamlIlVerifyIl> <AvaloniaXamlIlVerifyIl>true</AvaloniaXamlIlVerifyIl>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)\..\packages\Avalonia\AvaloniaBuildTasks.props"/> <Import Project="$(MSBuildThisFileDirectory)\..\packages\Avalonia\AvaloniaBuildTasks.props"/>
<Import Project="$(MSBuildThisFileDirectory)\..\packages\Avalonia\AvaloniaBuildTasks.targets"/> <Import Project="$(MSBuildThisFileDirectory)\..\packages\Avalonia\AvaloniaBuildTasks.targets"/>

2
build/SharedVersion.props

@ -8,7 +8,7 @@
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl> <RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<LangVersion>latest</LangVersion> <LangVersion>preview</LangVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Icon.png</PackageIcon> <PackageIcon>Icon.png</PackageIcon>
<PackageDescription>Avalonia is a cross-platform UI framework for .NET providing a flexible styling system and supporting a wide range of Operating Systems such as Windows, Linux, macOS and with experimental support for Android, iOS and WebAssembly.</PackageDescription> <PackageDescription>Avalonia is a cross-platform UI framework for .NET providing a flexible styling system and supporting a wide range of Operating Systems such as Windows, Linux, macOS and with experimental support for Android, iOS and WebAssembly.</PackageDescription>

2
global.json

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "7.0.100-rc.2.22477.23", "version": "7.0.100",
"rollForward": "latestFeature" "rollForward": "latestFeature"
}, },
"msbuild-sdks": { "msbuild-sdks": {

4
native/Avalonia.Native/src/OSX/AvnWindow.mm

@ -385,7 +385,7 @@
return true; return true;
} }
-(void)resignKeyWindow -(void)windowDidResignKey:(NSNotification *)notification
{ {
if(_parent) if(_parent)
_parent->BaseEvents->Deactivated(); _parent->BaseEvents->Deactivated();
@ -393,8 +393,6 @@
[self showAppMenuOnly]; [self showAppMenuOnly];
[self invalidateShadow]; [self invalidateShadow];
[super resignKeyWindow];
} }
- (void)windowDidMove:(NSNotification *_Nonnull)notification - (void)windowDidMove:(NSNotification *_Nonnull)notification

4
native/Avalonia.Native/src/OSX/Screens.mm

@ -41,9 +41,9 @@ public:
ret->WorkingArea.X = [screen visibleFrame].origin.x; ret->WorkingArea.X = [screen visibleFrame].origin.x;
ret->WorkingArea.Y = ConvertPointY(ToAvnPoint([screen visibleFrame].origin)).Y - ret->WorkingArea.Height; ret->WorkingArea.Y = ConvertPointY(ToAvnPoint([screen visibleFrame].origin)).Y - ret->WorkingArea.Height;
ret->PixelDensity = [screen backingScaleFactor]; ret->Scaling = [screen backingScaleFactor];
ret->Primary = index == 0; ret->IsPrimary = index == 0;
return S_OK; return S_OK;
} }

4
native/Avalonia.Native/src/OSX/WindowImpl.mm

@ -63,7 +63,7 @@ HRESULT WindowImpl::Show(bool activate, bool isDialog) {
START_COM_CALL; START_COM_CALL;
@autoreleasepool { @autoreleasepool {
_isDialog = isDialog; _isDialog = isDialog || _parent != nullptr;
WindowBaseImpl::Show(activate, isDialog); WindowBaseImpl::Show(activate, isDialog);
@ -96,6 +96,8 @@ HRESULT WindowImpl::SetParent(IAvnWindow *parent) {
auto cparent = dynamic_cast<WindowImpl *>(parent); auto cparent = dynamic_cast<WindowImpl *>(parent);
_parent = cparent; _parent = cparent;
_isDialog = _parent != nullptr;
if(_parent != nullptr && Window != nullptr){ if(_parent != nullptr && Window != nullptr){
// If one tries to show a child window with a minimized parent window, then the parent window will be // If one tries to show a child window with a minimized parent window, then the parent window will be

11
native/Avalonia.Native/src/OSX/app.mm

@ -95,11 +95,14 @@ ComPtr<IAvnApplicationEvents> _events;
} }
@end @end
extern void InitializeAvnApp(IAvnApplicationEvents* events) extern void InitializeAvnApp(IAvnApplicationEvents* events, bool disableAppDelegate)
{ {
NSApplication* app = [AvnApplication sharedApplication]; if(!disableAppDelegate)
id delegate = [[AvnAppDelegate alloc] initWithEvents:events]; {
[app setDelegate:delegate]; NSApplication* app = [AvnApplication sharedApplication];
id delegate = [[AvnAppDelegate alloc] initWithEvents:events];
[app setDelegate:delegate];
}
} }
HRESULT AvnApplicationCommands::HideApp() HRESULT AvnApplicationCommands::HideApp()

2
native/Avalonia.Native/src/OSX/common.h

@ -32,7 +32,7 @@ extern void SetServicesMenu (IAvnMenu* menu);
extern IAvnMenu* GetAppMenu (); extern IAvnMenu* GetAppMenu ();
extern NSMenuItem* GetAppMenuItem (); extern NSMenuItem* GetAppMenuItem ();
extern void InitializeAvnApp(IAvnApplicationEvents* events); extern void InitializeAvnApp(IAvnApplicationEvents* events, bool disableAppDelegate);
extern NSApplicationActivationPolicy AvnDesiredActivationPolicy; extern NSApplicationActivationPolicy AvnDesiredActivationPolicy;
extern NSPoint ToNSPoint (AvnPoint p); extern NSPoint ToNSPoint (AvnPoint p);
extern NSRect ToNSRect (AvnRect r); extern NSRect ToNSRect (AvnRect r);

41
native/Avalonia.Native/src/OSX/main.mm

@ -3,6 +3,8 @@
#include "common.h" #include "common.h"
static NSString* s_appTitle = @"Avalonia"; static NSString* s_appTitle = @"Avalonia";
static int disableSetProcessName = 0;
static bool disableAppDelegate = false;
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
@ -111,11 +113,17 @@ public:
@autoreleasepool @autoreleasepool
{ {
auto appTitle = [NSString stringWithUTF8String: utf8String]; auto appTitle = [NSString stringWithUTF8String: utf8String];
if (disableSetProcessName == 0)
[[NSProcessInfo processInfo] setProcessName:appTitle]; {
[[NSProcessInfo processInfo] setProcessName:appTitle];
SetProcessName(appTitle); SetProcessName(appTitle);
}
if (disableSetProcessName == 1)
{
auto rootMenu = [NSApp mainMenu];
[rootMenu setTitle:appTitle];
}
return S_OK; return S_OK;
} }
@ -133,6 +141,27 @@ public:
} }
} }
virtual HRESULT SetDisableSetProcessName(int disable) override
{
START_COM_CALL;
@autoreleasepool
{
disableSetProcessName = disable;
return S_OK;
}
}
virtual HRESULT SetDisableAppDelegate(int disable) override
{
START_COM_CALL;
@autoreleasepool {
disableAppDelegate = disable;
return S_OK;
}
}
}; };
/// See "Using POSIX Threads in a Cocoa Application" section here: /// See "Using POSIX Threads in a Cocoa Application" section here:
@ -175,7 +204,7 @@ public:
@autoreleasepool{ @autoreleasepool{
[[ThreadingInitializer new] do]; [[ThreadingInitializer new] do];
} }
InitializeAvnApp(events); InitializeAvnApp(events, disableAppDelegate);
return S_OK; return S_OK;
}; };

13
native/Avalonia.Native/src/OSX/menu.h

@ -59,11 +59,20 @@ public:
void RaiseOnClicked(); void RaiseOnClicked();
}; };
class AvnAppMenu;
@interface AvnMenuDelegate : NSObject<NSMenuDelegate>
- (id) initWithParent: (AvnAppMenu*) parent;
- (void) parentDestroyed;
@end
class AvnAppMenu : public ComSingleObject<IAvnMenu, &IID_IAvnMenu> class AvnAppMenu : public ComSingleObject<IAvnMenu, &IID_IAvnMenu>
{ {
private: private:
AvnMenu* _native; AvnMenu* _native;
ComPtr<IAvnMenuEvents> _baseEvents; ComPtr<IAvnMenuEvents> _baseEvents;
AvnMenuDelegate* _delegate;
public: public:
FORWARD_IUNKNOWN() FORWARD_IUNKNOWN()
@ -83,12 +92,10 @@ public:
virtual HRESULT SetTitle (char* utf8String) override; virtual HRESULT SetTitle (char* utf8String) override;
virtual HRESULT Clear () override; virtual HRESULT Clear () override;
virtual ~AvnAppMenu() override;
}; };
@interface AvnMenuDelegate : NSObject<NSMenuDelegate>
- (id) initWithParent: (AvnAppMenu*) parent;
@end
#endif #endif

26
native/Avalonia.Native/src/OSX/menu.mm

@ -292,8 +292,13 @@ void AvnAppMenuItem::RaiseOnClicked()
AvnAppMenu::AvnAppMenu(IAvnMenuEvents* events) AvnAppMenu::AvnAppMenu(IAvnMenuEvents* events)
{ {
_baseEvents = events; _baseEvents = events;
id del = [[AvnMenuDelegate alloc] initWithParent: this]; _delegate = [[AvnMenuDelegate alloc] initWithParent: this];
_native = [[AvnMenu alloc] initWithDelegate: del]; _native = [[AvnMenu alloc] initWithDelegate: _delegate];
}
AvnAppMenu::~AvnAppMenu()
{
[_delegate parentDestroyed];
} }
@ -394,7 +399,7 @@ HRESULT AvnAppMenu::Clear()
@implementation AvnMenuDelegate @implementation AvnMenuDelegate
{ {
ComPtr<AvnAppMenu> _parent; AvnAppMenu* _parent;
} }
- (id) initWithParent:(AvnAppMenu *)parent - (id) initWithParent:(AvnAppMenu *)parent
{ {
@ -402,6 +407,12 @@ HRESULT AvnAppMenu::Clear()
_parent = parent; _parent = parent;
return self; return self;
} }
- (void) parentDestroyed
{
_parent = nullptr;
}
- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel - (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel
{ {
if(shouldCancel) if(shouldCancel)
@ -416,17 +427,20 @@ HRESULT AvnAppMenu::Clear()
- (void)menuNeedsUpdate:(NSMenu *)menu - (void)menuNeedsUpdate:(NSMenu *)menu
{ {
_parent->RaiseNeedsUpdate(); if(_parent)
_parent->RaiseNeedsUpdate();
} }
- (void)menuWillOpen:(NSMenu *)menu - (void)menuWillOpen:(NSMenu *)menu
{ {
_parent->RaiseOpening(); if(_parent)
_parent->RaiseOpening();
} }
- (void)menuDidClose:(NSMenu *)menu - (void)menuDidClose:(NSMenu *)menu
{ {
_parent->RaiseClosed(); if(_parent)
_parent->RaiseClosed();
} }
@end @end

5
native/Avalonia.Native/src/OSX/rendertarget.mm

@ -183,8 +183,11 @@ static IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(IOSurfaceRenderTarget* ta
[_layer setContents: (__bridge IOSurface*) surface->surface]; [_layer setContents: (__bridge IOSurface*) surface->surface];
} }
[CATransaction commit]; [CATransaction commit];
[CATransaction flush];
} }
// This can trigger event processing on the main thread
// which might need to lock the renderer
// which can cause a deadlock. So flush call is outside of the lock
[CATransaction flush];
} }
else else
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{

19
nukebuild/Build.cs

@ -145,8 +145,25 @@ partial class Build : NukeBuild
{ {
Information($"Running tests from {projectName}"); Information($"Running tests from {projectName}");
var project = Solution.GetProject(projectName).NotNull("project != null"); var project = Solution.GetProject(projectName).NotNull("project != null");
// Nuke and MSBuild tools have build-in helpers to get target frameworks from the project.
// Unfortunately, it gets broken with every second SDK update, so we had to do it manually.
var fileXml = XDocument.Parse(File.ReadAllText(project.Path));
var targetFrameworks = fileXml.Descendants("TargetFrameworks")
.FirstOrDefault()?.Value.Split(';').Select(f => f.Trim());
if (targetFrameworks is null)
{
var targetFramework = fileXml.Descendants("TargetFramework").FirstOrDefault()?.Value;
if (targetFramework is not null)
{
targetFrameworks = new[] { targetFramework };
}
}
if (targetFrameworks is null)
{
throw new InvalidOperationException("No target frameworks were found in the test project");
}
foreach (var fw in project.GetTargetFrameworks()) foreach (var fw in targetFrameworks)
{ {
if (fw.StartsWith("net4") if (fw.StartsWith("net4")
&& RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)

6
nukebuild/_build.csproj

@ -13,11 +13,11 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.2.1" /> <PackageReference Include="Nuke.Common" Version="6.2.1" />
<PackageReference Include="vswhere" Version="2.6.7" Condition=" '$(OS)' == 'Windows_NT' " /> <PackageReference Include="vswhere" Version="2.6.7" Condition=" '$(OS)' == 'Windows_NT' " />
<PackageReference Include="MicroCom.CodeGenerator" Version="0.10.4" /> <PackageReference Include="MicroCom.CodeGenerator" Version="0.11.0" />
<!-- Keep in sync with Avalonia.Build.Tasks --> <!-- Keep in sync with Avalonia.Build.Tasks -->
<PackageReference Include="Mono.Cecil" Version="0.11.4" /> <PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="SourceLink" Version="1.1.0" GeneratePathProperty="true" /> <PackageReference Include="SourceLink" Version="1.1.0" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.3.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.Build.Framework" Version="17.3.2" PrivateAssets="All" />
<PackageReference Include="xunit.runner.console" Version="2.4.2"> <PackageReference Include="xunit.runner.console" Version="2.4.2">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

4
packages/Avalonia/AvaloniaBuildTasks.targets

@ -4,6 +4,7 @@
<_AvaloniaUseExternalMSBuild Condition="'$(_AvaloniaForceInternalMSBuild)' == 'true'">false</_AvaloniaUseExternalMSBuild> <_AvaloniaUseExternalMSBuild Condition="'$(_AvaloniaForceInternalMSBuild)' == 'true'">false</_AvaloniaUseExternalMSBuild>
<AvaloniaXamlReportImportance Condition="'$(AvaloniaXamlReportImportance)' == ''">low</AvaloniaXamlReportImportance> <AvaloniaXamlReportImportance Condition="'$(AvaloniaXamlReportImportance)' == ''">low</AvaloniaXamlReportImportance>
<_AvaloniaSkipXamlCompilation Condition="'$(_AvaloniaSkipXamlCompilation)' == ''">false</_AvaloniaSkipXamlCompilation> <_AvaloniaSkipXamlCompilation Condition="'$(_AvaloniaSkipXamlCompilation)' == ''">false</_AvaloniaSkipXamlCompilation>
<AvaloniaUseCompiledBindingsByDefault Condition="'$(AvaloniaUseCompiledBindingsByDefault)' == ''">false</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup> </PropertyGroup>
<!-- Unfortunately we have to update default items in .targets since custom nuget props are improted before Microsoft.NET.Sdk.DefaultItems.props --> <!-- Unfortunately we have to update default items in .targets since custom nuget props are improted before Microsoft.NET.Sdk.DefaultItems.props -->
@ -43,7 +44,7 @@
<PropertyGroup> <PropertyGroup>
<BuildAvaloniaResourcesDependsOn>$(BuildAvaloniaResourcesDependsOn);AddAvaloniaResources;ResolveReferences;_GenerateAvaloniaResourcesDependencyCache</BuildAvaloniaResourcesDependsOn> <BuildAvaloniaResourcesDependsOn>$(BuildAvaloniaResourcesDependsOn);AddAvaloniaResources;ResolveReferences;_GenerateAvaloniaResourcesDependencyCache</BuildAvaloniaResourcesDependsOn>
</PropertyGroup> </PropertyGroup>
<Target Name="_GenerateAvaloniaResourcesDependencyCache" BeforeTargets="GenerateAvaloniaResources"> <Target Name="_GenerateAvaloniaResourcesDependencyCache" BeforeTargets="GenerateAvaloniaResources">
<ItemGroup> <ItemGroup>
<CustomAdditionalGenerateAvaloniaResourcesInputs Include="$(IntermediateOutputPath)/Avalonia/Resources.Inputs.cache" /> <CustomAdditionalGenerateAvaloniaResourcesInputs Include="$(IntermediateOutputPath)/Avalonia/Resources.Inputs.cache" />
@ -106,6 +107,7 @@
DelaySign="$(DelaySign)" DelaySign="$(DelaySign)"
SkipXamlCompilation="$(_AvaloniaSkipXamlCompilation)" SkipXamlCompilation="$(_AvaloniaSkipXamlCompilation)"
DebuggerLaunch="$(AvaloniaXamlIlDebuggerLaunch)" DebuggerLaunch="$(AvaloniaXamlIlDebuggerLaunch)"
DefaultCompileBindings="$(AvaloniaUseCompiledBindingsByDefault)"
/> />
<Exec <Exec
Condition="'$(_AvaloniaUseExternalMSBuild)' == 'true'" Condition="'$(_AvaloniaUseExternalMSBuild)' == 'true'"

2
readme.md

@ -104,7 +104,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
## Commercial Support ## Commercial Support
We have a range of [support plans available](https://avaloniaui.net/support.html) for those looking to partner with the creators of Avalonia, enabling access to the best support at every step of the development process. We have a range of [support plans available](https://avaloniaui.net/support) for those looking to partner with the creators of Avalonia, enabling access to the best support at every step of the development process.
*Please note that donations are not considered payment for commercial support agreements. Please contact us to discuss your needs first. [team@avaloniaui.net](mailto://team@avaloniaui.net)* *Please note that donations are not considered payment for commercial support agreements. Please contact us to discuss your needs first. [team@avaloniaui.net](mailto://team@avaloniaui.net)*
## .NET Foundation ## .NET Foundation

6
samples/BindingDemo/MainWindow.xaml

@ -1,8 +1,8 @@
<Window xmlns="https://github.com/avaloniaui" <Window xmlns="https://github.com/avaloniaui"
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
x:Class="BindingDemo.MainWindow" x:Class="BindingDemo.MainWindow"
xmlns:vm="clr-namespace:BindingDemo.ViewModels" xmlns:vm="using:BindingDemo.ViewModels"
xmlns:local="clr-namespace:BindingDemo" xmlns:local="using:BindingDemo"
Title="AvaloniaUI Bindings Test" Title="AvaloniaUI Bindings Test"
Width="800" Width="800"
Height="600" Height="600"
@ -81,7 +81,7 @@
<TextBlock FontSize="16" Text="Multiple"/> <TextBlock FontSize="16" Text="Multiple"/>
<ListBox Items="{Binding Items}" SelectionMode="Multiple" Selection="{Binding Selection}"/> <ListBox Items="{Binding Items}" SelectionMode="Multiple" Selection="{Binding Selection}"/>
</StackPanel> </StackPanel>
<ContentControl Content="{Binding SelectedItems[0]}"> <ContentControl Content="{ReflectionBinding Selection.SelectedItems[0]}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>
<DataTemplate DataType="vm:TestItem"> <DataTemplate DataType="vm:TestItem">
<local:TestItemView></local:TestItemView> <local:TestItemView></local:TestItemView>

6
samples/BindingDemo/TestItemView.xaml

@ -1,8 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
x:Class="BindingDemo.TestItemView"> xmlns:viewModels="using:BindingDemo.ViewModels"
x:Class="BindingDemo.TestItemView"
x:DataType="viewModels:TestItem">
<StackPanel> <StackPanel>
<TextBlock Classes="h1" Text="{Binding StringValue}"/> <TextBlock Classes="h1" Text="{Binding StringValue}"/>
<TextBox Text="{Binding Detail}" AcceptsReturn="True"/> <TextBox Text="{Binding Detail}" AcceptsReturn="True"/>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

8
samples/ControlCatalog.Blazor.Web/Properties/launchSettings.json

@ -8,14 +8,6 @@
} }
}, },
"profiles": { "profiles": {
"ControlCatalog.Web - IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ControlCatalog.Web": { "ControlCatalog.Web": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": "true", "dotnetRunMessages": "true",

2
samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj

@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RuntimeFrameworkVersion>6.0.9</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>6.0.8</RuntimeFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RunNativeAotCompilation)' == 'true'"> <PropertyGroup Condition="'$(RunNativeAotCompilation)' == 'true'">

5
samples/ControlCatalog.Web/ControlCatalog.Web.csproj

@ -16,9 +16,8 @@
<TrimMode>full</TrimMode> <TrimMode>full</TrimMode>
<WasmBuildNative>true</WasmBuildNative> <WasmBuildNative>true</WasmBuildNative>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>true</InvariantGlobalization>
<WasmEnableSIMD>true</WasmEnableSIMD> <EmccCompileOptimizationFlag>-O2</EmccCompileOptimizationFlag>
<EmccCompileOptimizationFlag>-O3</EmccCompileOptimizationFlag> <EmccLinkOptimizationFlag>-O2</EmccLinkOptimizationFlag>
<EmccLinkOptimizationFlag>-O3</EmccLinkOptimizationFlag>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

1
samples/ControlCatalog.Web/Roots.xml

@ -3,4 +3,5 @@
<assembly fullname="ControlCatalog.Web" preserve="All" /> <assembly fullname="ControlCatalog.Web" preserve="All" />
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" /> <assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
<assembly fullname="Avalonia.Themes.Simple" preserve="All" /> <assembly fullname="Avalonia.Themes.Simple" preserve="All" />
<assembly fullname="Avalonia.Controls.ColorPicker" preserve="All" />
</linker> </linker>

1
samples/ControlCatalog/App.xaml

@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:ControlCatalog.ViewModels" xmlns:vm="using:ControlCatalog.ViewModels"
x:DataType="vm:ApplicationViewModel" x:DataType="vm:ApplicationViewModel"
x:CompileBindings="True"
Name="Avalonia ControlCatalog" Name="Avalonia ControlCatalog"
x:Class="ControlCatalog.App"> x:Class="ControlCatalog.App">
<Application.Resources> <Application.Resources>

15
samples/ControlCatalog/ControlCatalog.csproj

@ -14,9 +14,6 @@
<AvaloniaResource Include="Assets\*" /> <AvaloniaResource Include="Assets\*" />
<AvaloniaResource Include="Assets\Fonts\*" /> <AvaloniaResource Include="Assets\Fonts\*" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="Pages\NativeEmbedPage.xaml" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Assets\Fonts\SourceSansPro-Bold.ttf" /> <EmbeddedResource Include="Assets\Fonts\SourceSansPro-Bold.ttf" />
<EmbeddedResource Include="Assets\Fonts\SourceSansPro-BoldItalic.ttf" /> <EmbeddedResource Include="Assets\Fonts\SourceSansPro-BoldItalic.ttf" />
@ -35,17 +32,5 @@
<ProjectReference Include="..\SampleControls\ControlSamples.csproj" /> <ProjectReference Include="..\SampleControls\ControlSamples.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<AvaloniaResource Update="Pages\NativeEmbedPage.xaml">
<Generator>MSBuild:Compile</Generator>
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<Compile Update="Pages\NativeEmbedPage.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="..\..\build\BuildTargets.targets" /> <Import Project="..\..\build\BuildTargets.targets" />
</Project> </Project>

11
samples/ControlCatalog/DecoratedWindow.xaml

@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.DecoratedWindow" x:Class="ControlCatalog.DecoratedWindow"
Title="Avalonia Control Gallery" Title="Avalonia Control Gallery"
xmlns:local="clr-namespace:ControlCatalog" SystemDecorations="None" Name="Window"> SystemDecorations="None" Name="Window">
<NativeMenu.Menu> <NativeMenu.Menu>
<NativeMenu> <NativeMenu>
<NativeMenuItem Header="Decorated"> <NativeMenuItem Header="Decorated">
@ -43,8 +43,13 @@
<StackPanel> <StackPanel>
<TextBlock>Hello world!</TextBlock> <TextBlock>Hello world!</TextBlock>
<CheckBox IsChecked="{Binding ElementName=Window, Path=HasSystemDecorations}">Decorated</CheckBox> <ComboBox SelectedItem="{Binding ElementName=Window, Path=SystemDecorations}">
<ComboBox.Items>
<SystemDecorations>None</SystemDecorations>
<SystemDecorations>BorderOnly</SystemDecorations>
<SystemDecorations>Full</SystemDecorations>
</ComboBox.Items>
</ComboBox>
<CheckBox IsChecked="{Binding ElementName=Window, Path=CanResize}">CanResize</CheckBox> <CheckBox IsChecked="{Binding ElementName=Window, Path=CanResize}">CanResize</CheckBox>
</StackPanel> </StackPanel>
</Border> </Border>

17
samples/ControlCatalog/MainView.xaml

@ -1,9 +1,11 @@
<UserControl x:Class="ControlCatalog.MainView" <UserControl x:Class="ControlCatalog.MainView"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:ControlSamples;assembly=ControlSamples" xmlns:controls="using:ControlSamples"
xmlns:models="clr-namespace:ControlCatalog.Models" xmlns:models="using:ControlCatalog.Models"
xmlns:pages="clr-namespace:ControlCatalog.Pages"> xmlns:pages="using:ControlCatalog.Pages"
xmlns:viewModels="using:ControlCatalog.ViewModels"
x:DataType="viewModels:MainWindowViewModel">
<Grid> <Grid>
<Grid.Styles> <Grid.Styles>
<Style Selector="TextBlock.h2"> <Style Selector="TextBlock.h2">
@ -12,8 +14,8 @@
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
</Style> </Style>
</Grid.Styles> </Grid.Styles>
<controls:HamburgerMenu Name="Sidebar"> <controls:HamburgerMenu Name="Sidebar">
<TabItem Header="Composition"> <TabItem Header="Composition">
<pages:CompositionPage/> <pages:CompositionPage/>
</TabItem> </TabItem>
<TabItem Header="Acrylic"> <TabItem Header="Acrylic">
@ -118,6 +120,9 @@
<TabItem Header="OpenGL"> <TabItem Header="OpenGL">
<pages:OpenGlPage /> <pages:OpenGlPage />
</TabItem> </TabItem>
<TabItem Header="Platform Information">
<pages:PlatformInfoPage />
</TabItem>
<TabItem Header="Pointers"> <TabItem Header="Pointers">
<pages:PointersPage /> <pages:PointersPage />
</TabItem> </TabItem>
@ -130,7 +135,7 @@
<TabItem Header="RelativePanel"> <TabItem Header="RelativePanel">
<pages:RelativePanelPage /> <pages:RelativePanelPage />
</TabItem> </TabItem>
<TabItem Header="ScrollViewer"> <TabItem Header="ScrollViewer">
<pages:ScrollViewerPage /> <pages:ScrollViewerPage />
</TabItem> </TabItem>
<TabItem Header="Slider"> <TabItem Header="Slider">

11
samples/ControlCatalog/MainWindow.xaml

@ -1,19 +1,20 @@
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300" <Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300"
Width="1024" Height="800" Width="1024" Height="800"
xmlns:pages="clr-namespace:ControlCatalog.Pages" xmlns:pages="using:ControlCatalog.Pages"
Title="Avalonia Control Gallery" Title="Avalonia Control Gallery"
Icon="/Assets/test_icon.ico" Icon="/Assets/test_icon.ico"
xmlns:local="clr-namespace:ControlCatalog" xmlns:local="using:ControlCatalog"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:ControlCatalog.ViewModels" xmlns:vm="clr-namespace:ControlCatalog.ViewModels;assembly=ControlCatalog"
xmlns:v="clr-namespace:ControlCatalog.Views" xmlns:v="using:ControlCatalog.Views"
ExtendClientAreaToDecorationsHint="{Binding ExtendClientAreaEnabled}" ExtendClientAreaToDecorationsHint="{Binding ExtendClientAreaEnabled}"
ExtendClientAreaChromeHints="{Binding ChromeHints}" ExtendClientAreaChromeHints="{Binding ChromeHints}"
ExtendClientAreaTitleBarHeightHint="{Binding TitleBarHeight}" ExtendClientAreaTitleBarHeightHint="{Binding TitleBarHeight}"
TransparencyLevelHint="{Binding TransparencyLevel}" TransparencyLevelHint="{Binding TransparencyLevel}"
x:Name="MainWindow" x:Name="MainWindow"
Background="Transparent" Background="Transparent"
x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}"> x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}"
x:DataType="vm:MainWindowViewModel">
<NativeMenu.Menu> <NativeMenu.Menu>
<NativeMenu> <NativeMenu>
<NativeMenuItem Header="File"> <NativeMenuItem Header="File">

12
samples/ControlCatalog/MainWindow.xaml.cs

@ -11,23 +11,13 @@ namespace ControlCatalog
{ {
public class MainWindow : Window public class MainWindow : Window
{ {
private WindowNotificationManager _notificationArea;
private NativeMenu? _recentMenu; private NativeMenu? _recentMenu;
public MainWindow() public MainWindow()
{ {
this.InitializeComponent(); this.InitializeComponent();
//Renderer.DrawFps = true; DataContext = new MainWindowViewModel();
//Renderer.DrawDirtyRects = Renderer.DrawFps = true;
_notificationArea = new WindowNotificationManager(this)
{
Position = NotificationPosition.TopRight,
MaxItems = 3
};
DataContext = new MainWindowViewModel(_notificationArea);
_recentMenu = ((NativeMenu.GetMenu(this)?.Items[0] as NativeMenuItem)?.Menu?.Items[2] as NativeMenuItem)?.Menu; _recentMenu = ((NativeMenu.GetMenu(this)?.Items[0] as NativeMenuItem)?.Menu?.Items[2] as NativeMenuItem)?.Menu;
} }

20
samples/ControlCatalog/Models/StateData.cs

@ -0,0 +1,20 @@
namespace ControlCatalog.Models;
public class StateData
{
public string Name { get; private set; }
public string Abbreviation { get; private set; }
public string Capital { get; private set; }
public StateData(string name, string abbreviatoin, string capital)
{
Name = name;
Abbreviation = abbreviatoin;
Capital = capital;
}
public override string ToString()
{
return Name;
}
}

6
samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml

@ -2,8 +2,8 @@
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sys="using:System"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:models="using:ControlCatalog.Models"
d:DesignHeight="600" d:DesignHeight="600"
d:DesignWidth="400"> d:DesignWidth="400">
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"
@ -45,7 +45,7 @@
<StackPanel> <StackPanel>
<TextBlock Text="ValueMemberBinding" /> <TextBlock Text="ValueMemberBinding" />
<AutoCompleteBox ValueMemberBinding="{Binding Capital}" /> <AutoCompleteBox ValueMemberBinding="{Binding Capital, x:DataType=models:StateData}" />
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="Multi-Binding" /> <TextBlock Text="Multi-Binding" />

20
samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs

@ -8,30 +8,12 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Data.Converters; using Avalonia.Data.Converters;
using Avalonia.Data; using Avalonia.Data;
using ControlCatalog.Models;
namespace ControlCatalog.Pages namespace ControlCatalog.Pages
{ {
public class AutoCompleteBoxPage : UserControl public class AutoCompleteBoxPage : UserControl
{ {
public class StateData
{
public string Name { get; private set; }
public string Abbreviation { get; private set; }
public string Capital { get; private set; }
public StateData(string name, string abbreviatoin, string capital)
{
Name = name;
Abbreviation = abbreviatoin;
Capital = capital;
}
public override string ToString()
{
return Name;
}
}
private StateData[] BuildAllStates() private StateData[] BuildAllStates()
{ {
return new StateData[] return new StateData[]

1
samples/ControlCatalog/Pages/BorderPage.xaml

@ -1,7 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="800" d:DesignHeight="800"
d:DesignWidth="400" d:DesignWidth="400"
x:Class="ControlCatalog.Pages.BorderPage"> x:Class="ControlCatalog.Pages.BorderPage">

2
samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml

@ -1,7 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.ButtonSpinnerPage" x:Class="ControlCatalog.Pages.ButtonSpinnerPage"
xmlns:sys="clr-namespace:System;assembly=netstandard"> xmlns:sys="using:System">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">The ButtonSpinner control allows you to add button spinners to any element and then respond to the Spin event to manipulate that element.</TextBlock> <TextBlock Classes="h2">The ButtonSpinner control allows you to add button spinners to any element and then respond to the Spin event to manipulate that element.</TextBlock>

2
samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml

@ -1,6 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:ControlCatalog.ViewModels" xmlns:vm="using:ControlCatalog.ViewModels"
x:DataType="vm:MainWindowViewModel" x:DataType="vm:MainWindowViewModel"
x:Class="ControlCatalog.Pages.CalendarDatePickerPage"> x:Class="ControlCatalog.Pages.CalendarDatePickerPage">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">

25
samples/ControlCatalog/Pages/ColorPickerPage.xaml

@ -2,9 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Avalonia.Controls;assembly=Avalonia.Controls.ColorPicker" xmlns:controls="using:Avalonia.Controls"
xmlns:primitives="clr-namespace:Avalonia.Controls.Primitives;assembly=Avalonia.Controls"
xmlns:pc="clr-namespace:Avalonia.Controls.Primitives.Converters;assembly=Avalonia.Controls.ColorPicker"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignWidth="800" d:DesignWidth="800"
d:DesignHeight="450" d:DesignHeight="450"
@ -24,18 +22,19 @@
HsvColor="hsv(120, 1, 1)" HsvColor="hsv(120, 1, 1)"
Margin="0,50,0,0"> Margin="0,50,0,0">
<ColorPicker.Palette> <ColorPicker.Palette>
<controls:FlatColorPalette /> <controls:FlatHalfColorPalette />
</ColorPicker.Palette> </ColorPicker.Palette>
</ColorPicker> </ColorPicker>
<Grid Grid.Column="2" <Grid Grid.Column="2"
Grid.Row="0" Grid.Row="0"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto"> RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<ColorSpectrum x:Name="ColorSpectrum1" <ColorSpectrum x:Name="ColorSpectrum1"
Grid.Row="0" Grid.Row="0"
Color="Red" Color="Red"
CornerRadius="10" CornerRadius="10"
Height="256" Height="256"
Width="256" /> Width="256" />
<!-- HSV Sliders -->
<ColorSlider Grid.Row="1" <ColorSlider Grid.Row="1"
Margin="0,10,0,0" Margin="0,10,0,0"
ColorComponent="Component1" ColorComponent="Component1"
@ -53,7 +52,21 @@
ColorComponent="Alpha" ColorComponent="Alpha"
ColorModel="Hsva" ColorModel="Hsva"
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" /> HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />
<ColorPreviewer Grid.Row="5" <!-- RGB Sliders -->
<!--<ColorSlider Grid.Row="5"
Margin="0,10,0,0"
ColorComponent="Component1"
ColorModel="Rgba"
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />
<ColorSlider Grid.Row="6"
ColorComponent="Component2"
ColorModel="Rgba"
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />
<ColorSlider Grid.Row="7"
ColorComponent="Component3"
ColorModel="Rgba"
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />-->
<ColorPreviewer Grid.Row="8"
IsAccentColorsVisible="False" IsAccentColorsVisible="False"
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" /> HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />
</Grid> </Grid>

1
samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs

@ -20,6 +20,7 @@ namespace ControlCatalog.Pages
Color = Colors.Blue, Color = Colors.Blue,
Margin = new Thickness(0, 50, 0, 0), Margin = new Thickness(0, 50, 0, 0),
HorizontalAlignment = HorizontalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center,
Palette = new MaterialHalfColorPalette(),
}; };
Grid.SetColumn(colorPicker, 2); Grid.SetColumn(colorPicker, 2);
Grid.SetRow(colorPicker, 1); Grid.SetRow(colorPicker, 1);

8
samples/ControlCatalog/Pages/ComboBoxPage.xaml

@ -3,7 +3,9 @@
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:col="using:System.Collections" xmlns:col="using:System.Collections"
xmlns:sys="using:System"> xmlns:sys="using:System"
xmlns:viewModels="using:ControlCatalog.ViewModels"
x:DataType="viewModels:ComboBoxPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">A drop-down list.</TextBlock> <TextBlock Classes="h2">A drop-down list.</TextBlock>
@ -39,7 +41,7 @@
</col:ArrayList> </col:ArrayList>
</ComboBox.Items> </ComboBox.Items>
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate x:DataType="sys:String">
<Panel> <Panel>
<TextBlock Text="{Binding}" /> <TextBlock Text="{Binding}" />
<TextBlock IsVisible="{Binding Converter={x:Static ObjectConverters.IsNull}}" Text="Null object" /> <TextBlock IsVisible="{Binding Converter={x:Static ObjectConverters.IsNull}}" Text="Null object" />
@ -71,7 +73,7 @@
SelectedIndex="0" SelectedIndex="0"
WrapSelection="{Binding WrapSelection}"> WrapSelection="{Binding WrapSelection}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate x:DataType="FontFamily">
<TextBlock FontFamily="{Binding}" Text="{Binding Name}" /> <TextBlock FontFamily="{Binding}" Text="{Binding Name}" />
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>

4
samples/ControlCatalog/Pages/CompositionPage.axaml

@ -1,6 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pages="clr-namespace:ControlCatalog.Pages" xmlns:pages="using:ControlCatalog.Pages"
x:Class="ControlCatalog.Pages.CompositionPage"> x:Class="ControlCatalog.Pages.CompositionPage">
<StackPanel> <StackPanel>
<TextBlock Classes="h1">Implicit animations</TextBlock> <TextBlock Classes="h1">Implicit animations</TextBlock>
@ -42,4 +42,4 @@
</StackPanel> </StackPanel>
</UserControl> </UserControl>

6
samples/ControlCatalog/Pages/ContextFlyoutPage.xaml

@ -3,9 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="using:ControlCatalog.ViewModels"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d"
x:DataType="viewModels:ContextPageViewModel">
<UserControl.Styles> <UserControl.Styles>
<Style Selector="FlyoutPresenter.NoPadding"> <Style Selector="FlyoutPresenter.NoPadding">
<Setter Property="Padding" Value="0" /> <Setter Property="Padding" Value="0" />
@ -57,7 +59,7 @@
</Border> </Border>
<Border Classes="context-target"> <Border Classes="context-target">
<Border.Styles> <Border.Styles>
<Style Selector="MenuFlyoutPresenter MenuItem"> <Style Selector="MenuFlyoutPresenter MenuItem" x:DataType="viewModels:MenuItemViewModel">
<Setter Property="Header" Value="{Binding Header}"/> <Setter Property="Header" Value="{Binding Header}"/>
<Setter Property="Items" Value="{Binding Items}"/> <Setter Property="Items" Value="{Binding Items}"/>
<Setter Property="Command" Value="{Binding Command}"/> <Setter Property="Command" Value="{Binding Command}"/>

6
samples/ControlCatalog/Pages/ContextMenuPage.xaml

@ -1,6 +1,8 @@
<UserControl x:Class="ControlCatalog.Pages.ContextMenuPage" <UserControl x:Class="ControlCatalog.Pages.ContextMenuPage"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModels="using:ControlCatalog.ViewModels"
x:DataType="viewModels:ContextPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">A right click menu that can be applied to any control.</TextBlock> <TextBlock Classes="h2">A right click menu that can be applied to any control.</TextBlock>
@ -47,7 +49,7 @@
</Border> </Border>
<Border> <Border>
<Border.Styles> <Border.Styles>
<Style Selector="ContextMenu MenuItem"> <Style Selector="ContextMenu MenuItem" x:DataType="viewModels:MenuItemViewModel">
<Setter Property="Header" Value="{Binding Header}"/> <Setter Property="Header" Value="{Binding Header}"/>
<Setter Property="Items" Value="{Binding Items}"/> <Setter Property="Items" Value="{Binding Items}"/>
<Setter Property="Command" Value="{Binding Command}"/> <Setter Property="Command" Value="{Binding Command}"/>

6
samples/ControlCatalog/Pages/CursorPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.CursorPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.CursorPage"
x:DataType="viewModels:CursorPageViewModel">
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,*"> <Grid ColumnDefinitions="*,*" RowDefinitions="Auto,*">
<StackPanel Grid.ColumnSpan="2" Orientation="Vertical" Spacing="4"> <StackPanel Grid.ColumnSpan="2" Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">Defines a cursor (mouse pointer)</TextBlock> <TextBlock Classes="h2">Defines a cursor (mouse pointer)</TextBlock>
@ -9,7 +11,7 @@
<ListBox Grid.Row="1" Items="{Binding StandardCursors}" Margin="0 8 8 8"> <ListBox Grid.Row="1" Items="{Binding StandardCursors}" Margin="0 8 8 8">
<ListBox.Styles> <ListBox.Styles>
<Style Selector="ListBoxItem"> <Style Selector="ListBoxItem">
<Setter Property="Cursor" Value="{Binding Cursor}"/> <Setter Property="Cursor" Value="{Binding Cursor}" x:DataType="viewModels:StandardCursorModel"/>
</Style> </Style>
</ListBox.Styles> </ListBox.Styles>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>

30
samples/ControlCatalog/Pages/DataGridPage.xaml

@ -4,13 +4,13 @@
x:Class="ControlCatalog.Pages.DataGridPage"> x:Class="ControlCatalog.Pages.DataGridPage">
<UserControl.Resources> <UserControl.Resources>
<local:GDPValueConverter x:Key="GDPConverter" /> <local:GDPValueConverter x:Key="GDPConverter" />
<DataTemplate x:Key="Demo.DataTemplates.CountryHeader"> <DataTemplate x:Key="Demo.DataTemplates.CountryHeader" x:DataType="local:Country">
<StackPanel Orientation="Horizontal" Spacing="5"> <StackPanel Orientation="Horizontal" Spacing="5">
<PathIcon Height="12" Data="M 255 116 A 1 1 0 0 0 254 117 L 254 130 A 1 1 0 0 0 255 131 A 1 1 0 0 0 256 130 L 256 123.87109 C 256.1125 123.90694 256.2187 123.94195 256.33984 123.97852 C 257.18636 124.23404 258.19155 124.5 259 124.5 C 259.80845 124.5 260.52133 124.2168 261.17773 123.9668 C 261.83414 123.7168 262.43408 123.5 263 123.5 C 263.56592 123.5 264.5612 123.73404 265.37109 123.97852 C 266.18098 124.22299 266.82227 124.4668 266.82227 124.4668 A 0.50005 0.50005 0 0 0 267.5 124 L 267.5 118 A 0.50005 0.50005 0 0 0 267.17773 117.5332 C 267.17773 117.5332 266.50667 117.27701 265.66016 117.02148 C 264.81364 116.76596 263.80845 116.5 263 116.5 C 262.19155 116.5 261.47867 116.7832 260.82227 117.0332 C 260.16586 117.2832 259.56592 117.5 259 117.5 C 258.43408 117.5 257.4388 117.26596 256.62891 117.02148 C 256.39123 116.94974 256.17716 116.87994 255.98047 116.81445 A 1 1 0 0 0 255 116 z M 263 117.5 C 263.56592 117.5 264.5612 117.73404 265.37109 117.97852 C 266.00097 118.16865 266.29646 118.28239 266.5 118.35742 L 266.5 120.29297 C 266.25708 120.21012 265.97978 120.11797 265.66016 120.02148 C 264.81364 119.76596 263.80845 119.5 263 119.5 C 262.19155 119.5 261.47867 119.7832 260.82227 120.0332 C 260.16586 120.2832 259.56592 120.5 259 120.5 C 258.43408 120.5 257.4388 120.26596 256.62891 120.02148 C 256.39971 119.9523 256.19148 119.88388 256 119.82031 L 256 117.87109 C 256.1125 117.90694 256.2187 117.94195 256.33984 117.97852 C 257.18636 118.23404 258.19155 118.5 259 118.5 C 259.80845 118.5 260.52133 118.2168 261.17773 117.9668 C 261.83414 117.7168 262.43408 117.5 263 117.5 z M 263 120.5 C 263.56592 120.5 264.5612 120.73404 265.37109 120.97852 C 265.8714 121.12954 266.2398 121.25641 266.5 121.34961 L 266.5 123.30469 C 266.22286 123.20649 266.12863 123.1629 265.66016 123.02148 C 264.81364 122.76596 263.80845 122.5 263 122.5 C 262.19155 122.5 261.47867 122.7832 260.82227 123.0332 C 260.16586 123.2832 259.56592 123.5 259 123.5 C 258.43408 123.5 257.4388 123.26596 256.62891 123.02148 C 256.39971 122.9523 256.19148 122.88388 256 122.82031 L 256 120.87109 C 256.1125 120.90694 256.2187 120.94195 256.33984 120.97852 C 257.18636 121.23404 258.19155 121.5 259 121.5 C 259.80845 121.5 260.52133 121.2168 261.17773 120.9668 C 261.83414 120.7168 262.43408 120.5 263 120.5 z" /> <PathIcon Height="12" Data="M 255 116 A 1 1 0 0 0 254 117 L 254 130 A 1 1 0 0 0 255 131 A 1 1 0 0 0 256 130 L 256 123.87109 C 256.1125 123.90694 256.2187 123.94195 256.33984 123.97852 C 257.18636 124.23404 258.19155 124.5 259 124.5 C 259.80845 124.5 260.52133 124.2168 261.17773 123.9668 C 261.83414 123.7168 262.43408 123.5 263 123.5 C 263.56592 123.5 264.5612 123.73404 265.37109 123.97852 C 266.18098 124.22299 266.82227 124.4668 266.82227 124.4668 A 0.50005 0.50005 0 0 0 267.5 124 L 267.5 118 A 0.50005 0.50005 0 0 0 267.17773 117.5332 C 267.17773 117.5332 266.50667 117.27701 265.66016 117.02148 C 264.81364 116.76596 263.80845 116.5 263 116.5 C 262.19155 116.5 261.47867 116.7832 260.82227 117.0332 C 260.16586 117.2832 259.56592 117.5 259 117.5 C 258.43408 117.5 257.4388 117.26596 256.62891 117.02148 C 256.39123 116.94974 256.17716 116.87994 255.98047 116.81445 A 1 1 0 0 0 255 116 z M 263 117.5 C 263.56592 117.5 264.5612 117.73404 265.37109 117.97852 C 266.00097 118.16865 266.29646 118.28239 266.5 118.35742 L 266.5 120.29297 C 266.25708 120.21012 265.97978 120.11797 265.66016 120.02148 C 264.81364 119.76596 263.80845 119.5 263 119.5 C 262.19155 119.5 261.47867 119.7832 260.82227 120.0332 C 260.16586 120.2832 259.56592 120.5 259 120.5 C 258.43408 120.5 257.4388 120.26596 256.62891 120.02148 C 256.39971 119.9523 256.19148 119.88388 256 119.82031 L 256 117.87109 C 256.1125 117.90694 256.2187 117.94195 256.33984 117.97852 C 257.18636 118.23404 258.19155 118.5 259 118.5 C 259.80845 118.5 260.52133 118.2168 261.17773 117.9668 C 261.83414 117.7168 262.43408 117.5 263 117.5 z M 263 120.5 C 263.56592 120.5 264.5612 120.73404 265.37109 120.97852 C 265.8714 121.12954 266.2398 121.25641 266.5 121.34961 L 266.5 123.30469 C 266.22286 123.20649 266.12863 123.1629 265.66016 123.02148 C 264.81364 122.76596 263.80845 122.5 263 122.5 C 262.19155 122.5 261.47867 122.7832 260.82227 123.0332 C 260.16586 123.2832 259.56592 123.5 259 123.5 C 258.43408 123.5 257.4388 123.26596 256.62891 123.02148 C 256.39971 122.9523 256.19148 122.88388 256 122.82031 L 256 120.87109 C 256.1125 120.90694 256.2187 120.94195 256.33984 120.97852 C 257.18636 121.23404 258.19155 121.5 259 121.5 C 259.80845 121.5 260.52133 121.2168 261.17773 120.9668 C 261.83414 120.7168 262.43408 120.5 263 120.5 z" />
<TextBlock Text="{Binding}"/> <TextBlock Text="{Binding}"/>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
<ControlTheme x:Key="GdpCell" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> <ControlTheme x:Key="GdpCell" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}" x:DataType="local:Country">
<Setter Property="Background" Value="{Binding Path=GDP, Mode=OneWay, Converter={StaticResource GDPConverter}}" /> <Setter Property="Background" Value="{Binding Path=GDP, Mode=OneWay, Converter={StaticResource GDPConverter}}" />
</ControlTheme> </ControlTheme>
</UserControl.Resources> </UserControl.Resources>
@ -49,15 +49,15 @@
AlternatingRowBackground="#1fff"> AlternatingRowBackground="#1fff">
<DataGrid.Columns> <DataGrid.Columns>
<!-- Using HeaderTemplate --> <!-- Using HeaderTemplate -->
<DataGridTextColumn Header="Country" HeaderTemplate="{StaticResource Demo.DataTemplates.CountryHeader}" Binding="{Binding Name}" Width="6*" /> <DataGridTextColumn Header="Country" HeaderTemplate="{StaticResource Demo.DataTemplates.CountryHeader}" Binding="{Binding Name}" Width="6*" x:DataType="local:Country" />
<!-- CompiledBinding example of usage. -->
<DataGridTextColumn Header="Region" Binding="{CompiledBinding Region}" Width="4*" x:DataType="local:Country" /> <DataGridTextColumn Header="Region" Binding="{CompiledBinding Region}" Width="4*" x:DataType="local:Country" />
<DataGridTextColumn Header="Population" Binding="{Binding Population}" Width="3*" /> <DataGridTextColumn Header="Population" Binding="{Binding Population}" Width="3*" x:DataType="local:Country" />
<DataGridTextColumn Header="Area" Binding="{Binding Area}" Width="3*" /> <DataGridTextColumn Header="Area" Binding="{Binding Area}" Width="3*" x:DataType="local:Country" />
<DataGridTextColumn Header="GDP" Binding="{Binding GDP}" Width="3*" <DataGridTextColumn Header="GDP" Binding="{Binding GDP}" Width="3*"
CellTheme="{StaticResource GdpCell}" CellTheme="{StaticResource GdpCell}"
MinWidth="200" MinWidth="200"
IsVisible="{Binding #ShowGDP.IsChecked}"/> IsVisible="{Binding #ShowGDP.IsChecked}"
x:DataType="local:Country" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</DockPanel> </DockPanel>
@ -65,11 +65,11 @@
<TabItem Header="Grouping"> <TabItem Header="Grouping">
<DataGrid Name="dataGridGrouping" Margin="12"> <DataGrid Name="dataGridGrouping" Margin="12">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="Country" Binding="{Binding Name}" Width="6*" /> <DataGridTextColumn Header="Country" Binding="{Binding Name}" Width="6*" x:DataType="local:Country" />
<DataGridTextColumn Header="Region" Binding="{Binding Region}" Width="4*" /> <DataGridTextColumn Header="Region" Binding="{Binding Region}" Width="4*" x:DataType="local:Country" />
<DataGridTextColumn DisplayIndex="3" Header="Population" Binding="{Binding Population}" Width="3*" /> <DataGridTextColumn DisplayIndex="3" Header="Population" Binding="{Binding Population}" Width="3*" x:DataType="local:Country" />
<DataGridTextColumn DisplayIndex="2" Header="Area" Binding="{Binding Area}" Width="3*" /> <DataGridTextColumn DisplayIndex="2" Header="Area" Binding="{Binding Area}" Width="3*" x:DataType="local:Country" />
<DataGridTextColumn Header="GDP" Binding="{Binding GDP}" Width="3*" /> <DataGridTextColumn Header="GDP" Binding="{Binding GDP}" Width="3*" x:DataType="local:Country" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</TabItem> </TabItem>
@ -77,9 +77,9 @@
<Grid RowDefinitions="*,Auto"> <Grid RowDefinitions="*,Auto">
<DataGrid Name="dataGridEdit" Margin="12" Grid.Row="0"> <DataGrid Name="dataGridEdit" Margin="12" Grid.Row="0">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" Width="2*" FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}" /> <DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" Width="2*" FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}" x:DataType="local:Person" />
<DataGridTextColumn Header="Last" Binding="{Binding LastName}" Width="2*" FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}" /> <DataGridTextColumn Header="Last" Binding="{Binding LastName}" Width="2*" FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}" x:DataType="local:Person" />
<DataGridCheckBoxColumn Header="Is Banned" Binding="{Binding IsBanned}" Width="*" IsThreeState="{Binding #IsThreeStateCheckBox.IsChecked, Mode=OneWay}" /> <DataGridCheckBoxColumn Header="Is Banned" Binding="{Binding IsBanned}" Width="*" IsThreeState="{Binding #IsThreeStateCheckBox.IsChecked, Mode=OneWay}" x:DataType="local:Person" />
<DataGridTemplateColumn Header="Age" > <DataGridTemplateColumn Header="Age" >
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="local:Person"> <DataTemplate DataType="local:Person">

2
samples/ControlCatalog/Pages/DateTimePickerPage.xaml

@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="using:System"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ControlCatalog.Pages.DateTimePickerPage"> x:Class="ControlCatalog.Pages.DateTimePickerPage">
<StackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Stretch"> <StackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Stretch">

21
samples/ControlCatalog/Pages/ExpanderPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.ExpanderPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.ExpanderPage"
x:DataType="viewModels:ExpanderPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">Expands to show nested content</TextBlock> <TextBlock Classes="h2">Expands to show nested content</TextBlock>
@ -32,6 +34,23 @@
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander ExpandDirection="Down"
CornerRadius="{Binding CornerRadius}">
<Expander.Header>
<Button Content="Control in Header" />
</Expander.Header>
<StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
<Expander Header="Disabled"
IsEnabled="False"
ExpandDirection="Down"
CornerRadius="{Binding CornerRadius}">
<StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
<CheckBox IsChecked="{Binding Rounded}">Rounded</CheckBox> <CheckBox IsChecked="{Binding Rounded}">Rounded</CheckBox>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

8
samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.ItemsRepeaterPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.ItemsRepeaterPage"
x:DataType="viewModels:ItemsRepeaterPageViewModel">
<UserControl.Styles> <UserControl.Styles>
<Style Selector="ItemsRepeater TextBlock.oddTemplate"> <Style Selector="ItemsRepeater TextBlock.oddTemplate">
<Setter Property="Background" Value="Yellow" /> <Setter Property="Background" Value="Yellow" />
@ -21,12 +23,12 @@
</UserControl.Styles> </UserControl.Styles>
<UserControl.Resources> <UserControl.Resources>
<RecyclePool x:Key="RecyclePool" /> <RecyclePool x:Key="RecyclePool" />
<DataTemplate x:Key="odd"> <DataTemplate x:Key="odd" x:DataType="viewModels:ItemsRepeaterPageViewModelItem">
<TextBlock Classes="oddTemplate" <TextBlock Classes="oddTemplate"
Height="{Binding Height}" Height="{Binding Height}"
Text="{Binding Text}"/> Text="{Binding Text}"/>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="even"> <DataTemplate x:Key="even" x:DataType="viewModels:ItemsRepeaterPageViewModelItem">
<TextBlock Classes="evenTemplate" <TextBlock Classes="evenTemplate"
Height="{Binding Height}" Height="{Binding Height}"
Text="{Binding Text}"/> Text="{Binding Text}"/>

4
samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs

@ -44,7 +44,7 @@ namespace ControlCatalog.Pages
public void OnSelectTemplateKey(object sender, SelectTemplateEventArgs e) public void OnSelectTemplateKey(object sender, SelectTemplateEventArgs e)
{ {
if (e.DataContext is ItemsRepeaterPageViewModel.Item item) if (e.DataContext is ItemsRepeaterPageViewModelItem item)
{ {
e.TemplateKey = (item.Index % 2 == 0) ? "even" : "odd"; e.TemplateKey = (item.Index % 2 == 0) ? "even" : "odd";
} }
@ -125,7 +125,7 @@ namespace ControlCatalog.Pages
private void RepeaterClick(object? sender, PointerPressedEventArgs e) private void RepeaterClick(object? sender, PointerPressedEventArgs e)
{ {
if ((e.Source as TextBlock)?.DataContext is ItemsRepeaterPageViewModel.Item item) if ((e.Source as TextBlock)?.DataContext is ItemsRepeaterPageViewModelItem item)
{ {
_viewModel.SelectedItem = item; _viewModel.SelectedItem = item;
_selectedIndex = _viewModel.Items.IndexOf(item); _selectedIndex = _viewModel.Items.IndexOf(item);

4
samples/ControlCatalog/Pages/LabelsPage.axaml

@ -2,9 +2,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:ControlCatalog.Models"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="250" mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="250"
x:Class="ControlCatalog.Pages.LabelsPage" x:Class="ControlCatalog.Pages.LabelsPage"
x:Name="_labelsPage"> x:Name="_labelsPage"
x:DataType="models:Person">
<UserControl.Styles> <UserControl.Styles>
<Style Selector="Label"> <Style Selector="Label">
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>

4
samples/ControlCatalog/Pages/ListBoxPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.ListBoxPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.ListBoxPage"
x:DataType="viewModels:ListBoxPageViewModel">
<DockPanel> <DockPanel>
<DockPanel.Styles> <DockPanel.Styles>
<Style Selector="ListBox ListBoxItem:nth-child(5n+3)"> <Style Selector="ListBox ListBoxItem:nth-child(5n+3)">

8
samples/ControlCatalog/Pages/MenuPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.MenuPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.MenuPage"
x:DataType="viewModels:MenuPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">Exported menu fallback</TextBlock> <TextBlock Classes="h2">Exported menu fallback</TextBlock>
<TextBlock>(Should be only visible on platforms without desktop-global menu bar)</TextBlock> <TextBlock>(Should be only visible on platforms without desktop-global menu bar)</TextBlock>
@ -45,7 +47,7 @@
<TextBlock Classes="h3" Margin="4 8">Dyanamically generated</TextBlock> <TextBlock Classes="h3" Margin="4 8">Dyanamically generated</TextBlock>
<Menu Items="{Binding MenuItems}"> <Menu Items="{Binding MenuItems}">
<Menu.Styles> <Menu.Styles>
<Style Selector="MenuItem"> <Style Selector="MenuItem" x:DataType="viewModels:MenuItemViewModel">
<Setter Property="Header" Value="{Binding Header}"/> <Setter Property="Header" Value="{Binding Header}"/>
<Setter Property="Items" Value="{Binding Items}"/> <Setter Property="Items" Value="{Binding Items}"/>
<Setter Property="Command" Value="{Binding Command}"/> <Setter Property="Command" Value="{Binding Command}"/>
@ -68,7 +70,7 @@
<Separator/> <Separator/>
<MenuItem Header="_Recent" Items="{Binding RecentItems}"> <MenuItem Header="_Recent" Items="{Binding RecentItems}">
<MenuItem.Styles> <MenuItem.Styles>
<Style Selector="MenuItem"> <Style Selector="MenuItem" x:DataType="viewModels:MenuItemViewModel">
<Setter Property="Header" Value="{Binding Header}"/> <Setter Property="Header" Value="{Binding Header}"/>
</Style> </Style>
</MenuItem.Styles> </MenuItem.Styles>

4
samples/ControlCatalog/Pages/NotificationsPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.NotificationsPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.NotificationsPage"
x:DataType="viewModels:NotificationViewModel">
<StackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Left"> <StackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Left">
<Button Content="Show Standard Managed Notification" Command="{Binding ShowManagedNotificationCommand}" /> <Button Content="Show Standard Managed Notification" Command="{Binding ShowManagedNotificationCommand}" />
<Button Content="Show Custom Managed Notification" Command="{Binding ShowCustomManagedNotificationCommand}" /> <Button Content="Show Custom Managed Notification" Command="{Binding ShowCustomManagedNotificationCommand}" />

15
samples/ControlCatalog/Pages/NotificationsPage.xaml.cs

@ -1,18 +1,33 @@
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using ControlCatalog.ViewModels;
namespace ControlCatalog.Pages namespace ControlCatalog.Pages
{ {
public class NotificationsPage : UserControl public class NotificationsPage : UserControl
{ {
private NotificationViewModel _viewModel;
public NotificationsPage() public NotificationsPage()
{ {
this.InitializeComponent(); this.InitializeComponent();
_viewModel = new NotificationViewModel();
DataContext = _viewModel;
} }
private void InitializeComponent() private void InitializeComponent()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
_viewModel.NotificationManager = new Avalonia.Controls.Notifications.WindowNotificationManager(VisualRoot as TopLevel);
}
} }
} }

11
samples/ControlCatalog/Pages/NumericUpDownPage.xaml

@ -1,8 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="using:System"
xmlns:converter="clr-namespace:ControlCatalog.Converter" xmlns:converter="using:ControlCatalog.Converter"
x:Class="ControlCatalog.Pages.NumericUpDownPage"> xmlns:pages="using:ControlCatalog.Pages"
x:Class="ControlCatalog.Pages.NumericUpDownPage"
x:DataType="pages:NumbersPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4" <StackPanel Orientation="Vertical" Spacing="4"
MaxWidth="800"> MaxWidth="800">
<TextBlock Margin="2" Classes="h2" TextWrapping="Wrap">Numeric up-down control provides a TextBox with button spinners that allow incrementing and decrementing numeric values by using the spinner buttons, keyboard up/down arrows, or mouse wheel.</TextBlock> <TextBlock Margin="2" Classes="h2" TextWrapping="Wrap">Numeric up-down control provides a TextBox with button spinners that allow incrementing and decrementing numeric values by using the spinner buttons, keyboard up/down arrows, or mouse wheel.</TextBlock>
@ -43,7 +45,7 @@
VerticalAlignment="Center" Margin="2"/> VerticalAlignment="Center" Margin="2"/>
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="2">CultureInfo:</TextBlock> <TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="2">CultureInfo:</TextBlock>
<ComboBox Grid.Row="2" Grid.Column="1" Items="{Binding Cultures}" SelectedItem="{Binding #upDown.CultureInfo}" <ComboBox x:Name="CultureSelector" Grid.Row="2" Grid.Column="1" Items="{Binding Cultures}"
VerticalAlignment="Center" Margin="2"/> VerticalAlignment="Center" Margin="2"/>
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">Watermark:</TextBlock> <TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">Watermark:</TextBlock>
@ -77,6 +79,7 @@
<StackPanel Orientation="Vertical" Margin="10"> <StackPanel Orientation="Vertical" Margin="10">
<Label Target="upDown" FontSize="14" FontWeight="Bold" VerticalAlignment="Center">Usage of decimal NumericUpDown:</Label> <Label Target="upDown" FontSize="14" FontWeight="Bold" VerticalAlignment="Center">Usage of decimal NumericUpDown:</Label>
<NumericUpDown Name="upDown" Minimum="0" Maximum="10" Increment="0.5" <NumericUpDown Name="upDown" Minimum="0" Maximum="10" Increment="0.5"
NumberFormat="{Binding #CultureSelector.SelectedItem, Converter={x:Static pages:NumericUpDownPage.CultureConverter}}"
VerticalAlignment="Center" Value="{Binding DecimalValue}" VerticalAlignment="Center" Value="{Binding DecimalValue}"
Watermark="Enter text" FormatString="{Binding SelectedFormat.Value}"/> Watermark="Enter text" FormatString="{Binding SelectedFormat.Value}"/>
</StackPanel> </StackPanel>

3
samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using MiniMvvm; using MiniMvvm;
@ -22,6 +23,8 @@ namespace ControlCatalog.Pages
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
public static IValueConverter CultureConverter =
new FuncValueConverter<CultureInfo, NumberFormatInfo>(c => (c ?? CultureInfo.CurrentCulture).NumberFormat);
} }
public class NumbersPageViewModel : ViewModelBase public class NumbersPageViewModel : ViewModelBase

2
samples/ControlCatalog/Pages/OpenGlPage.xaml

@ -1,7 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.OpenGlPage" x:Class="ControlCatalog.Pages.OpenGlPage"
xmlns:pages="clr-namespace:ControlCatalog.Pages"> xmlns:pages="using:ControlCatalog.Pages">
<Grid> <Grid>
<pages:OpenGlPageControl x:Name="GL"/> <pages:OpenGlPageControl x:Name="GL"/>
<StackPanel> <StackPanel>

53
samples/ControlCatalog/Pages/PlatformInfoPage.xaml

@ -0,0 +1,53 @@
<UserControl x:Class="ControlCatalog.Pages.PlatformInfoPage"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="using:ControlCatalog.ViewModels"
d:DesignHeight="800"
d:DesignWidth="400"
mc:Ignorable="d"
x:DataType="viewModels:PlatformInformationViewModel">
<StackPanel Spacing="20">
<TextBlock Text="{Binding PlatformInfo}" />
<StackPanel TextElement.Foreground="White">
<StackPanel Orientation="Horizontal">
<Border Height="100" Width="100" Background="{OnFormFactor Gray, Desktop=Green}">
<TextBlock Text="Desktop" />
</Border>
<Border Height="100" Width="100" Background="{OnFormFactor Gray, Mobile=Green}">
<TextBlock Text="Mobile" />
</Border>
</StackPanel>
<WrapPanel>
<Border Height="100" Width="100" Background="{OnPlatform Gray, Windows=Green}">
<TextBlock Text="Windows" />
</Border>
<Border Height="100" Width="100" Background="{OnPlatform Gray, macOS=Green}">
<TextBlock Text="macOS" />
</Border>
<Border Height="100" Width="100" Background="{OnPlatform Gray, Linux=Green}">
<TextBlock Text="Linux" />
</Border>
<Border Height="100" Width="100" Background="{OnPlatform Gray, Browser=Green}">
<TextBlock Text="Browser" />
</Border>
<Border Height="100" Width="100" Background="{OnPlatform Gray, iOS=Green}">
<TextBlock Text="iOS" />
</Border>
<Border Height="100" Width="100" Background="{OnPlatform Gray, Android=Green}">
<TextBlock Text="Android" />
</Border>
<Border Height="100" Width="100">
<Border.Background>
<OnPlatform Default="Gray" >
<On Options="macOS, Linux, Windows" Content="Green" />
</OnPlatform>
</Border.Background>
<TextBlock Text="Win, Lin or Mac" />
</Border>
</WrapPanel>
</StackPanel>
</StackPanel>
</UserControl>

20
samples/ControlCatalog/Pages/PlatformInfoPage.xaml.cs

@ -0,0 +1,20 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using ControlCatalog.ViewModels;
namespace ControlCatalog.Pages
{
public class PlatformInfoPage : UserControl
{
public PlatformInfoPage()
{
this.InitializeComponent();
DataContext = new PlatformInformationViewModel();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

2
samples/ControlCatalog/Pages/ProgressBarPage.xaml

@ -31,7 +31,7 @@
<StackPanel Spacing="10"> <StackPanel Spacing="10">
<ProgressBar VerticalAlignment="Center" IsIndeterminate="True" <ProgressBar VerticalAlignment="Center" IsIndeterminate="True"
Minimum="{Binding #minimum.Value}" Maximum="{Binding #maximum.value}"/> Minimum="{Binding #minimum.Value}" Maximum="{Binding #maximum.Value}"/>
<ProgressBar VerticalAlignment="Center" Value="5" Maximum="10" /> <ProgressBar VerticalAlignment="Center" Value="5" Maximum="10" />
<ProgressBar VerticalAlignment="Center" Value="50" /> <ProgressBar VerticalAlignment="Center" Value="50" />
<ProgressBar VerticalAlignment="Center" Value="50" Minimum="25" Maximum="75" /> <ProgressBar VerticalAlignment="Center" Value="50" Minimum="25" Maximum="75" />

4
samples/ControlCatalog/Pages/ScreenPage.cs

@ -62,10 +62,10 @@ namespace ControlCatalog.Pages
CreateFormattedText($"WorkArea: {screen.WorkingArea.Width}:{screen.WorkingArea.Height}"); CreateFormattedText($"WorkArea: {screen.WorkingArea.Width}:{screen.WorkingArea.Height}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 20)); context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 20));
formattedText = CreateFormattedText($"Scaling: {screen.PixelDensity * 100}%"); formattedText = CreateFormattedText($"Scaling: {screen.Scaling * 100}%");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 40)); context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 40));
formattedText = CreateFormattedText($"Primary: {screen.Primary}"); formattedText = CreateFormattedText($"IsPrimary: {screen.IsPrimary}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 60)); context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 60));
formattedText = formattedText =

4
samples/ControlCatalog/Pages/ScrollViewerPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.ScrollViewerPage"> xmlns:pages="using:ControlCatalog.Pages"
x:Class="ControlCatalog.Pages.ScrollViewerPage"
x:DataType="pages:ScrollViewerPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">Allows for horizontal and vertical content scrolling.</TextBlock> <TextBlock Classes="h2">Allows for horizontal and vertical content scrolling.</TextBlock>

2
samples/ControlCatalog/Pages/SliderPage.xaml

@ -1,6 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="using:System"
x:Class="ControlCatalog.Pages.SliderPage"> x:Class="ControlCatalog.Pages.SliderPage">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">A control that lets the user select from a range of values by moving a Thumb control along a Track.</TextBlock> <TextBlock Classes="h2">A control that lets the user select from a range of values by moving a Thumb control along a Track.</TextBlock>

6
samples/ControlCatalog/Pages/SplitViewPage.xaml

@ -2,8 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="using:ControlCatalog.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ControlCatalog.Pages.SplitViewPage"> x:Class="ControlCatalog.Pages.SplitViewPage"
x:DataType="viewModels:SplitViewPageViewModel">
<Border> <Border>
@ -51,7 +53,7 @@
<!--{Binding SelectedItem.Tag, ElementName=PaneBackgroundSelector}--> <!--{Binding SelectedItem.Tag, ElementName=PaneBackgroundSelector}-->
<SplitView Name="SplitView" <SplitView Name="SplitView"
PanePlacement="{Binding PanePlacement}" PanePlacement="{Binding PanePlacement}"
PaneBackground="{Binding SelectedItem.Tag, ElementName=PaneBackgroundSelector}" PaneBackground="{Binding ((Control)SelectedItem).Tag, ElementName=PaneBackgroundSelector, FallbackValue={x:Null}}"
OpenPaneLength="{Binding Value, ElementName=OpenPaneLengthSlider}" OpenPaneLength="{Binding Value, ElementName=OpenPaneLengthSlider}"
CompactPaneLength="{Binding Value, ElementName=CompactPaneLengthSlider}" CompactPaneLength="{Binding Value, ElementName=CompactPaneLengthSlider}"
DisplayMode="{Binding CurrentDisplayMode}"> DisplayMode="{Binding CurrentDisplayMode}">

10
samples/ControlCatalog/Pages/TabControlPage.xaml

@ -1,7 +1,9 @@
<UserControl <UserControl
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.TabControlPage" x:Class="ControlCatalog.Pages.TabControlPage"
xmlns="https://github.com/avaloniaui"> xmlns="https://github.com/avaloniaui"
xmlns:viewModels="using:ControlCatalog.ViewModels"
x:DataType="viewModels:TabControlPageViewModel">
<DockPanel> <DockPanel>
<TextBlock <TextBlock
DockPanel.Dock="Top" DockPanel.Dock="Top"
@ -53,14 +55,14 @@
Margin="0 16" Margin="0 16"
TabStripPlacement="{Binding TabPlacement}"> TabStripPlacement="{Binding TabPlacement}">
<TabControl.ItemTemplate> <TabControl.ItemTemplate>
<DataTemplate> <DataTemplate x:DataType="viewModels:TabControlPageViewModelItem">
<TextBlock <TextBlock
Text="{Binding Header}"> Text="{Binding Header}">
</TextBlock> </TextBlock>
</DataTemplate> </DataTemplate>
</TabControl.ItemTemplate> </TabControl.ItemTemplate>
<TabControl.ContentTemplate> <TabControl.ContentTemplate>
<DataTemplate> <DataTemplate x:DataType="viewModels:TabControlPageViewModelItem">
<StackPanel Orientation="Vertical" Spacing="8"> <StackPanel Orientation="Vertical" Spacing="8">
<TextBlock Text="{Binding Text}"/> <TextBlock Text="{Binding Text}"/>
<Image Source="{Binding Image}" Width="300"/> <Image Source="{Binding Image}" Width="300"/>
@ -68,7 +70,7 @@
</DataTemplate> </DataTemplate>
</TabControl.ContentTemplate> </TabControl.ContentTemplate>
<TabControl.Styles> <TabControl.Styles>
<Style Selector="TabItem"> <Style Selector="TabItem" x:DataType="viewModels:TabControlPageViewModelItem">
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/> <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
</Style> </Style>
</TabControl.Styles> </TabControl.Styles>

32
samples/ControlCatalog/Pages/TabControlPage.xaml.cs

@ -5,8 +5,7 @@ using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging; using Avalonia.Media.Imaging;
using Avalonia.Platform; using Avalonia.Platform;
using ControlCatalog.ViewModels;
using MiniMvvm;
namespace ControlCatalog.Pages namespace ControlCatalog.Pages
{ {
@ -18,23 +17,23 @@ namespace ControlCatalog.Pages
{ {
InitializeComponent(); InitializeComponent();
DataContext = new PageViewModel DataContext = new TabControlPageViewModel
{ {
Tabs = new[] Tabs = new[]
{ {
new TabItemViewModel new TabControlPageViewModelItem
{ {
Header = "Arch", Header = "Arch",
Text = "This is the first templated tab page.", Text = "This is the first templated tab page.",
Image = LoadBitmap("avares://ControlCatalog/Assets/delicate-arch-896885_640.jpg"), Image = LoadBitmap("avares://ControlCatalog/Assets/delicate-arch-896885_640.jpg"),
}, },
new TabItemViewModel new TabControlPageViewModelItem
{ {
Header = "Leaf", Header = "Leaf",
Text = "This is the second templated tab page.", Text = "This is the second templated tab page.",
Image = LoadBitmap("avares://ControlCatalog/Assets/maple-leaf-888807_640.jpg"), Image = LoadBitmap("avares://ControlCatalog/Assets/maple-leaf-888807_640.jpg"),
}, },
new TabItemViewModel new TabControlPageViewModelItem
{ {
Header = "Disabled", Header = "Disabled",
Text = "You should not see this.", Text = "You should not see this.",
@ -55,26 +54,5 @@ namespace ControlCatalog.Pages
var assets = AvaloniaLocator.Current!.GetService<IAssetLoader>()!; var assets = AvaloniaLocator.Current!.GetService<IAssetLoader>()!;
return new Bitmap(assets.Open(new Uri(uri))); return new Bitmap(assets.Open(new Uri(uri)));
} }
private class PageViewModel : ViewModelBase
{
private Dock _tabPlacement;
public TabItemViewModel[]? Tabs { get; set; }
public Dock TabPlacement
{
get { return _tabPlacement; }
set { this.RaiseAndSetIfChanged(ref _tabPlacement, value); }
}
}
private class TabItemViewModel
{
public string? Header { get; set; }
public string? Text { get; set; }
public IBitmap? Image { get; set; }
public bool IsEnabled { get; set; } = true;
}
} }
} }

10
samples/ControlCatalog/Pages/TabStripPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <UserControl xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.TabStripPage" x:Class="ControlCatalog.Pages.TabStripPage"
xmlns="https://github.com/avaloniaui"> xmlns="https://github.com/avaloniaui"
xmlns:viewModels="using:ControlCatalog.ViewModels"
x:DataType="viewModels:TabControlPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">A control which displays a selectable strip of tabs</TextBlock> <TextBlock Classes="h2">A control which displays a selectable strip of tabs</TextBlock>
@ -16,14 +18,14 @@
<Separator Margin="0 16"/> <Separator Margin="0 16"/>
<TextBlock Classes="h1">Dynamically generated</TextBlock> <TextBlock Classes="h1">Dynamically generated</TextBlock>
<TabStrip Items="{Binding}"> <TabStrip Items="{Binding Tabs}">
<TabStrip.Styles> <TabStrip.Styles>
<Style Selector="TabStripItem"> <Style Selector="TabStripItem" x:DataType="viewModels:TabControlPageViewModelItem">
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/> <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
</Style> </Style>
</TabStrip.Styles> </TabStrip.Styles>
<TabStrip.ItemTemplate> <TabStrip.ItemTemplate>
<DataTemplate> <DataTemplate x:DataType="viewModels:TabControlPageViewModelItem">
<TextBlock Text="{Binding Header}"/> <TextBlock Text="{Binding Header}"/>
</DataTemplate> </DataTemplate>
</TabStrip.ItemTemplate> </TabStrip.ItemTemplate>

40
samples/ControlCatalog/Pages/TabStripPage.xaml.cs

@ -1,9 +1,6 @@
using System;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging; using ControlCatalog.ViewModels;
using Avalonia.Platform;
namespace ControlCatalog.Pages namespace ControlCatalog.Pages
{ {
@ -13,21 +10,24 @@ namespace ControlCatalog.Pages
{ {
InitializeComponent(); InitializeComponent();
DataContext = new[] DataContext = new TabControlPageViewModel
{ {
new TabStripItemViewModel Tabs = new []
{ {
Header = "Item 1", new TabControlPageViewModelItem()
}, {
new TabStripItemViewModel Header = "Item 1",
{ },
Header = "Item 2", new TabControlPageViewModelItem
}, {
new TabStripItemViewModel Header = "Item 2",
{ },
Header = "Disabled", new TabControlPageViewModelItem
IsEnabled = false, {
}, Header = "Disabled",
IsEnabled = false,
},
}
}; };
} }
@ -35,11 +35,5 @@ namespace ControlCatalog.Pages
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
private class TabStripItemViewModel
{
public string? Header { get; set; }
public bool IsEnabled { get; set; } = true;
}
} }
} }

4
samples/ControlCatalog/Pages/TextBlockPage.xaml

@ -118,7 +118,7 @@
</StackPanel> </StackPanel>
</Border> </Border>
<Border> <Border>
<RichTextBlock SelectionBrush="LightBlue" IsTextSelectionEnabled="True" Margin="10" TextWrapping="Wrap"> <SelectableTextBlock SelectionBrush="LightBlue" Margin="10" TextWrapping="Wrap">
This <Span FontWeight="Bold">is</Span> a This <Span FontWeight="Bold">is</Span> a
<Span Background="Silver" Foreground="Maroon">TextBlock</Span> <Span Background="Silver" Foreground="Maroon">TextBlock</Span>
with <Span TextDecorations="Underline">several</Span> with <Span TextDecorations="Underline">several</Span>
@ -126,7 +126,7 @@
<Span Foreground="Blue"> <Span Foreground="Blue">
using a <Bold>variety</Bold> of <Italic>styles</Italic> using a <Bold>variety</Bold> of <Italic>styles</Italic>
</Span>. </Span>.
</RichTextBlock> </SelectableTextBlock>
</Border> </Border>
</WrapPanel> </WrapPanel>
</StackPanel> </StackPanel>

2
samples/ControlCatalog/Pages/TextBoxPage.xaml

@ -1,7 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.TextBoxPage" x:Class="ControlCatalog.Pages.TextBoxPage"
xmlns:sys="clr-namespace:System;assembly=netstandard"> xmlns:sys="using:System">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<Label Classes="h2">A control into which the user can input text</Label> <Label Classes="h2">A control into which the user can input text</Label>

3
samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml

@ -3,11 +3,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:ControlCatalog.ViewModels" xmlns:vm="using:ControlCatalog.ViewModels"
xmlns:converter="clr-namespace:ControlCatalog.Converter" xmlns:converter="using:ControlCatalog.Converter"
xmlns:system="using:System" xmlns:system="using:System"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="vm:TransitioningContentControlPageViewModel" x:DataType="vm:TransitioningContentControlPageViewModel"
x:CompileBindings="True"
x:Class="ControlCatalog.Pages.TransitioningContentControlPage"> x:Class="ControlCatalog.Pages.TransitioningContentControlPage">
<UserControl.DataContext> <UserControl.DataContext>

4
samples/ControlCatalog/Pages/TreeViewPage.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.TreeViewPage"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Pages.TreeViewPage"
x:DataType="viewModels:TreeViewPageViewModel">
<StackPanel Orientation="Vertical" Spacing="4"> <StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h2">Displays a hierachical tree of data.</TextBlock> <TextBlock Classes="h2">Displays a hierachical tree of data.</TextBlock>

2
samples/ControlCatalog/Pages/ViewboxPage.xaml

@ -1,6 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:collections="clr-namespace:System.Collections;assembly=netstandard" xmlns:collections="using:System.Collections"
x:Class="ControlCatalog.Pages.ViewboxPage"> x:Class="ControlCatalog.Pages.ViewboxPage">
<Grid RowDefinitions="Auto,*,*"> <Grid RowDefinitions="Auto,*,*">

4
samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml

@ -2,8 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="using:ControlCatalog.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ControlCatalog.Pages.WindowCustomizationsPage"> x:Class="ControlCatalog.Pages.WindowCustomizationsPage"
x:DataType="viewModels:MainWindowViewModel">
<StackPanel Spacing="10" Margin="25"> <StackPanel Spacing="10" Margin="25">
<CheckBox Content="Extend Client Area to Decorations" IsChecked="{Binding ExtendClientAreaEnabled}" /> <CheckBox Content="Extend Client Area to Decorations" IsChecked="{Binding ExtendClientAreaEnabled}" />
<CheckBox Content="Title Bar" IsChecked="{Binding SystemTitleBarEnabled}" /> <CheckBox Content="Title Bar" IsChecked="{Binding SystemTitleBarEnabled}" />

20
samples/ControlCatalog/ViewModels/CursorPageViewModel.cs

@ -27,18 +27,18 @@ namespace ControlCatalog.ViewModels
public IEnumerable<StandardCursorModel> StandardCursors { get; } public IEnumerable<StandardCursorModel> StandardCursors { get; }
public Cursor CustomCursor { get; } public Cursor CustomCursor { get; }
}
public class StandardCursorModel
public class StandardCursorModel
{
public StandardCursorModel(StandardCursorType type)
{ {
public StandardCursorModel(StandardCursorType type) Type = type;
{ Cursor = new Cursor(type);
Type = type; }
Cursor = new Cursor(type);
}
public StandardCursorType Type { get; } public StandardCursorType Type { get; }
public Cursor Cursor { get; } public Cursor Cursor { get; }
}
} }
} }

44
samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs

@ -10,25 +10,25 @@ namespace ControlCatalog.ViewModels
{ {
private int _newItemIndex = 1; private int _newItemIndex = 1;
private int _newGenerationIndex = 0; private int _newGenerationIndex = 0;
private ObservableCollection<Item> _items; private ObservableCollection<ItemsRepeaterPageViewModelItem> _items;
public ItemsRepeaterPageViewModel() public ItemsRepeaterPageViewModel()
{ {
_items = CreateItems(); _items = CreateItems();
} }
public ObservableCollection<Item> Items public ObservableCollection<ItemsRepeaterPageViewModelItem> Items
{ {
get => _items; get => _items;
set => this.RaiseAndSetIfChanged(ref _items, value); set => this.RaiseAndSetIfChanged(ref _items, value);
} }
public Item? SelectedItem { get; set; } public ItemsRepeaterPageViewModelItem? SelectedItem { get; set; }
public void AddItem() public void AddItem()
{ {
var index = SelectedItem != null ? Items.IndexOf(SelectedItem) : -1; var index = SelectedItem != null ? Items.IndexOf(SelectedItem) : -1;
Items.Insert(index + 1, new Item(index + 1, $"New Item {_newItemIndex++}")); Items.Insert(index + 1, new ItemsRepeaterPageViewModelItem(index + 1, $"New Item {_newItemIndex++}"));
} }
public void RemoveItem() public void RemoveItem()
@ -59,33 +59,33 @@ namespace ControlCatalog.ViewModels
Items = CreateItems(); Items = CreateItems();
} }
private ObservableCollection<Item> CreateItems() private ObservableCollection<ItemsRepeaterPageViewModelItem> CreateItems()
{ {
var suffix = _newGenerationIndex == 0 ? string.Empty : $"[{_newGenerationIndex.ToString()}]"; var suffix = _newGenerationIndex == 0 ? string.Empty : $"[{_newGenerationIndex.ToString()}]";
_newGenerationIndex++; _newGenerationIndex++;
return new ObservableCollection<Item>( return new ObservableCollection<ItemsRepeaterPageViewModelItem>(
Enumerable.Range(1, 100000).Select(i => new Item(i, $"Item {i.ToString()} {suffix}"))); Enumerable.Range(1, 100000).Select(i => new ItemsRepeaterPageViewModelItem(i, $"Item {i.ToString()} {suffix}")));
} }
}
public class ItemsRepeaterPageViewModelItem : ViewModelBase
{
private double _height = double.NaN;
public class Item : ViewModelBase public ItemsRepeaterPageViewModelItem(int index, string text)
{ {
private double _height = double.NaN; Index = index;
Text = text;
public Item(int index, string text) }
{ public int Index { get; }
Index = index; public string Text { get; }
Text = text;
}
public int Index { get; }
public string Text { get; }
public double Height public double Height
{ {
get => _height; get => _height;
set => this.RaiseAndSetIfChanged(ref _height, value); set => this.RaiseAndSetIfChanged(ref _height, value);
}
} }
} }
} }

32
samples/ControlCatalog/ViewModels/MainWindowViewModel.cs

@ -24,25 +24,8 @@ namespace ControlCatalog.ViewModels
private bool _preferSystemChromeEnabled; private bool _preferSystemChromeEnabled;
private double _titleBarHeight; private double _titleBarHeight;
public MainWindowViewModel(IManagedNotificationManager notificationManager) public MainWindowViewModel()
{ {
_notificationManager = notificationManager;
ShowCustomManagedNotificationCommand = MiniCommand.Create(() =>
{
NotificationManager.Show(new NotificationViewModel(NotificationManager) { Title = "Hey There!", Message = "Did you know that Avalonia now supports Custom In-Window Notifications?" });
});
ShowManagedNotificationCommand = MiniCommand.Create(() =>
{
NotificationManager.Show(new Avalonia.Controls.Notifications.Notification("Welcome", "Avalonia now supports Notifications.", NotificationType.Information));
});
ShowNativeNotificationCommand = MiniCommand.Create(() =>
{
NotificationManager.Show(new Avalonia.Controls.Notifications.Notification("Error", "Native Notifications are not quite ready. Coming soon.", NotificationType.Error));
});
AboutCommand = MiniCommand.CreateFromTask(async () => AboutCommand = MiniCommand.CreateFromTask(async () =>
{ {
var dialog = new AboutAvaloniaDialog(); var dialog = new AboutAvaloniaDialog();
@ -52,7 +35,6 @@ namespace ControlCatalog.ViewModels
await dialog.ShowDialog(mainWindow); await dialog.ShowDialog(mainWindow);
} }
}); });
ExitCommand = MiniCommand.Create(() => ExitCommand = MiniCommand.Create(() =>
{ {
(App.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.Shutdown(); (App.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.Shutdown();
@ -143,24 +125,12 @@ namespace ControlCatalog.ViewModels
set { this.RaiseAndSetIfChanged(ref _windowStates, value); } set { this.RaiseAndSetIfChanged(ref _windowStates, value); }
} }
public IManagedNotificationManager NotificationManager
{
get { return _notificationManager; }
set { this.RaiseAndSetIfChanged(ref _notificationManager, value); }
}
public bool IsMenuItemChecked public bool IsMenuItemChecked
{ {
get { return _isMenuItemChecked; } get { return _isMenuItemChecked; }
set { this.RaiseAndSetIfChanged(ref _isMenuItemChecked, value); } set { this.RaiseAndSetIfChanged(ref _isMenuItemChecked, value); }
} }
public MiniCommand ShowCustomManagedNotificationCommand { get; }
public MiniCommand ShowManagedNotificationCommand { get; }
public MiniCommand ShowNativeNotificationCommand { get; }
public MiniCommand AboutCommand { get; } public MiniCommand AboutCommand { get; }
public MiniCommand ExitCommand { get; } public MiniCommand ExitCommand { get; }

29
samples/ControlCatalog/ViewModels/NotificationViewModel.cs

@ -6,16 +6,33 @@ namespace ControlCatalog.ViewModels
{ {
public class NotificationViewModel public class NotificationViewModel
{ {
public NotificationViewModel(INotificationManager manager) public WindowNotificationManager? NotificationManager { get; set; }
public NotificationViewModel()
{ {
ShowCustomManagedNotificationCommand = MiniCommand.Create(() =>
{
NotificationManager?.Show(new NotificationViewModel() { Title = "Hey There!", Message = "Did you know that Avalonia now supports Custom In-Window Notifications?" , NotificationManager = NotificationManager});
});
ShowManagedNotificationCommand = MiniCommand.Create(() =>
{
NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Welcome", "Avalonia now supports Notifications.", NotificationType.Information));
});
ShowNativeNotificationCommand = MiniCommand.Create(() =>
{
NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Error", "Native Notifications are not quite ready. Coming soon.", NotificationType.Error));
});
YesCommand = MiniCommand.Create(() => YesCommand = MiniCommand.Create(() =>
{ {
manager.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today.")); NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today."));
}); });
NoCommand = MiniCommand.Create(() => NoCommand = MiniCommand.Create(() =>
{ {
manager.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today. To find out more visit...")); NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today. To find out more visit..."));
}); });
} }
@ -26,5 +43,11 @@ namespace ControlCatalog.ViewModels
public MiniCommand NoCommand { get; } public MiniCommand NoCommand { get; }
public MiniCommand ShowCustomManagedNotificationCommand { get; }
public MiniCommand ShowManagedNotificationCommand { get; }
public MiniCommand ShowNativeNotificationCommand { get; }
} }
} }

54
samples/ControlCatalog/ViewModels/PlatformInformationViewModel.cs

@ -0,0 +1,54 @@
using Avalonia;
using Avalonia.Platform;
using MiniMvvm;
namespace ControlCatalog.ViewModels;
#nullable enable
public class PlatformInformationViewModel : ViewModelBase
{
public PlatformInformationViewModel()
{
var runtimeInfo = AvaloniaLocator.Current.GetService<IRuntimePlatform>()?.GetRuntimeInfo();
if (runtimeInfo is { } info)
{
if (info.IsBrowser)
{
if (info.IsDesktop)
{
PlatformInfo = "Platform: Desktop (browser)";
}
else if (info.IsMobile)
{
PlatformInfo = "Platform: Mobile (browser)";
}
else
{
PlatformInfo = "Platform: Unknown (browser) - please report";
}
}
else
{
if (info.IsDesktop)
{
PlatformInfo = "Platform: Desktop (native)";
}
else if (info.IsMobile)
{
PlatformInfo = "Platform: Mobile (native)";
}
else
{
PlatformInfo = "Platform: Unknown (native) - please report";
}
}
}
else
{
}
}
public string PlatformInfo { get; }
}

26
samples/ControlCatalog/ViewModels/TabControlPageViewModel.cs

@ -0,0 +1,26 @@
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using MiniMvvm;
namespace ControlCatalog.ViewModels;
public class TabControlPageViewModel : ViewModelBase
{
private Dock _tabPlacement;
public TabControlPageViewModelItem[]? Tabs { get; set; }
public Dock TabPlacement
{
get { return _tabPlacement; }
set { this.RaiseAndSetIfChanged(ref _tabPlacement, value); }
}
}
public class TabControlPageViewModelItem
{
public string? Header { get; set; }
public string? Text { get; set; }
public IBitmap? Image { get; set; }
public bool IsEnabled { get; set; } = true;
}

4
samples/ControlCatalog/Views/CustomNotificationView.xaml

@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui" <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Views.CustomNotificationView"> xmlns:viewModels="using:ControlCatalog.ViewModels"
x:Class="ControlCatalog.Views.CustomNotificationView"
x:DataType="viewModels:NotificationViewModel">
<Border Padding="12" MinHeight="20" Background="DodgerBlue"> <Border Padding="12" MinHeight="20" Background="DodgerBlue">
<Grid ColumnDefinitions="Auto,*"> <Grid ColumnDefinitions="Auto,*">
<Panel Margin="0,0,12,0" Width="25" Height="25" VerticalAlignment="Top"> <Panel Margin="0,0,12,0" Width="25" Height="25" VerticalAlignment="Top">

2
samples/IntegrationTestApp/IntegrationTestApp.csproj

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

21
samples/IntegrationTestApp/MainWindow.axaml

@ -2,10 +2,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:integrationTestApp="using:IntegrationTestApp"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IntegrationTestApp.MainWindow" x:Class="IntegrationTestApp.MainWindow"
Name="MainWindow" Name="MainWindow"
Title="IntegrationTestApp"> Title="IntegrationTestApp"
x:DataType="integrationTestApp:MainWindow">
<NativeMenu.Menu> <NativeMenu.Menu>
<NativeMenu> <NativeMenu>
<NativeMenuItem Header="File"> <NativeMenuItem Header="File">
@ -69,6 +71,23 @@
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="Gestures">
<DockPanel>
<DockPanel DockPanel.Dock="Top">
<Button Name="ResetGestures" DockPanel.Dock="Right">Reset</Button>
<TextBlock Name="LastGesture" />
</DockPanel>
<Panel>
<Border Name="GestureBorder" Background="Blue"
AutomationProperties.AccessibilityView="Content"
AutomationProperties.ControlTypeOverride="Image"/>
<Border Name="GestureBorder2" Background="Green" IsVisible="False"
AutomationProperties.AccessibilityView="Content"
AutomationProperties.ControlTypeOverride="Image"/>
</Panel>
</DockPanel>
</TabItem>
<TabItem Header="ListBox"> <TabItem Header="ListBox">
<DockPanel> <DockPanel>
<StackPanel DockPanel.Dock="Bottom"> <StackPanel DockPanel.Dock="Bottom">

34
samples/IntegrationTestApp/MainWindow.axaml.cs

@ -4,6 +4,7 @@ using Avalonia;
using Avalonia.Automation; using Avalonia.Automation;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.VisualTree; using Avalonia.VisualTree;
@ -17,6 +18,7 @@ namespace IntegrationTestApp
{ {
InitializeComponent(); InitializeComponent();
InitializeViewMenu(); InitializeViewMenu();
InitializeGesturesTab();
this.AttachDevTools(); this.AttachDevTools();
AddHandler(Button.ClickEvent, OnButtonClick); AddHandler(Button.ClickEvent, OnButtonClick);
ListBoxItems = Enumerable.Range(0, 100).Select(x => "Item " + x).ToList(); ListBoxItems = Enumerable.Range(0, 100).Select(x => "Item " + x).ToList();
@ -122,6 +124,38 @@ namespace IntegrationTestApp
} }
} }
private void InitializeGesturesTab()
{
var gestureBorder = this.GetControl<Border>("GestureBorder");
var gestureBorder2 = this.GetControl<Border>("GestureBorder2");
var lastGesture = this.GetControl<TextBlock>("LastGesture");
var resetGestures = this.GetControl<Button>("ResetGestures");
gestureBorder.Tapped += (s, e) => lastGesture.Text = "Tapped";
gestureBorder.DoubleTapped += (s, e) =>
{
lastGesture.Text = "DoubleTapped";
// Testing #8733
gestureBorder.IsVisible = false;
gestureBorder2.IsVisible = true;
};
gestureBorder2.DoubleTapped += (s, e) =>
{
lastGesture.Text = "DoubleTapped2";
};
Gestures.AddRightTappedHandler(gestureBorder, (s, e) => lastGesture.Text = "RightTapped");
resetGestures.Click += (s, e) =>
{
lastGesture.Text = string.Empty;
gestureBorder.IsVisible = true;
gestureBorder2.IsVisible = false;
};
}
private void MenuClicked(object? sender, RoutedEventArgs e) private void MenuClicked(object? sender, RoutedEventArgs e)
{ {
var clickedMenuItemTextBlock = this.Get<TextBlock>("ClickedMenuItem"); var clickedMenuItemTextBlock = this.Get<TextBlock>("ClickedMenuItem");

1
samples/IntegrationTestApp/ShowWindowTest.axaml

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="IntegrationTestApp.ShowWindowTest" x:Class="IntegrationTestApp.ShowWindowTest"
Name="SecondaryWindow" Name="SecondaryWindow"
x:DataType="Window"
Title="Show Window Test"> Title="Show Window Test">
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> <Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Label Grid.Column="0" Grid.Row="1">Client Size</Label> <Label Grid.Column="0" Grid.Row="1">Client Size</Label>

1
samples/MobileSandbox/App.xaml

@ -1,6 +1,5 @@
<Application xmlns="https://github.com/avaloniaui" <Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True"
Name="Mobile Sandbox" Name="Mobile Sandbox"
x:Class="MobileSandbox.App"> x:Class="MobileSandbox.App">
<Application.Styles> <Application.Styles>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save