From 6797e695f407ffe3e7566248d86afe921563c02b Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:24:24 +0000 Subject: [PATCH 01/65] upgrade osx vm image, to output arm64 apple m1 compatible avalonia.native dylib. --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ac1944b171..fcf5fc8c6a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,7 @@ jobs: variables: SolutionDir: '$(Build.SourcesDirectory)' pool: - vmImage: 'macOS-10.14' + vmImage: 'macOS-10.15' steps: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 3.1.401' From e907b4f8f8ae2e445bba9c3d881ff7147571867f Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:37:55 +0000 Subject: [PATCH 02/65] use xcode 12. --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fcf5fc8c6a..197b41d1dc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -54,7 +54,7 @@ jobs: sdk: 'macosx10.14' configuration: 'Release' xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' - xcodeVersion: '10' # Options: 8, 9, default, specifyPath + xcodeVersion: '12' # Options: 8, 9, default, specifyPath args: '-derivedDataPath ./' - task: CmdLine@2 From fc6d4953b03232ef3aeea4e23d6e8a123b686d9e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:43:09 +0000 Subject: [PATCH 03/65] sdk 10.15 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 197b41d1dc..8a6e5ddb97 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,7 +51,7 @@ jobs: inputs: actions: 'build' scheme: '' - sdk: 'macosx10.14' + sdk: 'macosx10.15' configuration: 'Release' xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' xcodeVersion: '12' # Options: 8, 9, default, specifyPath From 451d07826cf8fb7b0fc864d1281841f08a8e3a5c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:45:28 +0000 Subject: [PATCH 04/65] dont specify sdk. --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8a6e5ddb97..3c131e8663 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,7 +51,6 @@ jobs: inputs: actions: 'build' scheme: '' - sdk: 'macosx10.15' configuration: 'Release' xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' xcodeVersion: '12' # Options: 8, 9, default, specifyPath From 88fd934fb1ef03f725df3cd9714962ec5318a698 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:48:43 +0000 Subject: [PATCH 05/65] list sdks. --- azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3c131e8663..2f41af8b89 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -46,7 +46,14 @@ jobs: inputs: script: | cd src/tools/MicroComGenerator; dotnet run -i ../../Avalonia.Native/avn.idl --cpp ../../../native/Avalonia.Native/inc/avalonia-native.h + + - task: CmdLine@2 + displayName: 'List SDKs' + inputs: + script: | + xcodebuild -showsdks + - task: Xcode@5 - task: Xcode@5 inputs: actions: 'build' From 7c2de57d395d459954d1ef3d427e05641dc198a4 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:51:18 +0000 Subject: [PATCH 06/65] 11 sdk --- azure-pipelines.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2f41af8b89..63ba47ec46 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -46,18 +46,11 @@ jobs: inputs: script: | cd src/tools/MicroComGenerator; dotnet run -i ../../Avalonia.Native/avn.idl --cpp ../../../native/Avalonia.Native/inc/avalonia-native.h - - - task: CmdLine@2 - displayName: 'List SDKs' - inputs: - script: | - xcodebuild -showsdks - - task: Xcode@5 - task: Xcode@5 inputs: actions: 'build' - scheme: '' + scheme: 'macosx11.0' configuration: 'Release' xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' xcodeVersion: '12' # Options: 8, 9, default, specifyPath From 19e1266993df97494f4e4fa7215699ac8db182dd Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 12 Dec 2020 19:53:46 +0000 Subject: [PATCH 07/65] fix sdk. --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 63ba47ec46..15392278c9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,7 +50,8 @@ jobs: - task: Xcode@5 inputs: actions: 'build' - scheme: 'macosx11.0' + scheme: '' + sdk: 'macosx11.0' configuration: 'Release' xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' xcodeVersion: '12' # Options: 8, 9, default, specifyPath From e7c1c3dbecb85ac86af782677c62db99309bf34a Mon Sep 17 00:00:00 2001 From: Robin Dostal Date: Mon, 14 Dec 2020 18:00:05 +0100 Subject: [PATCH 08/65] More reliable pixendensitydetection under Xorg/Randr Physical dimensions are parsed from the monitors EDID instead of Randr. GuessPixelDensity locks to fixed values, caps at 2 and returns 1 if the supplied dimensions are unreasonable. --- src/Avalonia.X11/X11Atoms.cs | 2 + src/Avalonia.X11/X11Screens.cs | 81 +++++++++++++++++++++++++--------- src/Avalonia.X11/XLib.cs | 7 +++ 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/src/Avalonia.X11/X11Atoms.cs b/src/Avalonia.X11/X11Atoms.cs index 32f1822e51..137757b9cf 100644 --- a/src/Avalonia.X11/X11Atoms.cs +++ b/src/Avalonia.X11/X11Atoms.cs @@ -114,6 +114,8 @@ namespace Avalonia.X11 public readonly IntPtr XA_WM_CLASS = (IntPtr)67; public readonly IntPtr XA_WM_TRANSIENT_FOR = (IntPtr)68; + public readonly IntPtr RR_PROPERTY_RANDR_EDID = (IntPtr)82; + public readonly IntPtr WM_PROTOCOLS; public readonly IntPtr WM_DELETE_WINDOW; public readonly IntPtr WM_TAKE_FOCUS; diff --git a/src/Avalonia.X11/X11Screens.cs b/src/Avalonia.X11/X11Screens.cs index af6d2674b6..df1b2b7312 100644 --- a/src/Avalonia.X11/X11Screens.cs +++ b/src/Avalonia.X11/X11Screens.cs @@ -82,6 +82,39 @@ namespace Avalonia.X11 _cache = null; } + private unsafe Size? GetPhysicalMonitorSizeFromEDID(IntPtr rrOutput) + { + if(rrOutput == IntPtr.Zero) + return null; + var output = Marshal.ReadInt64(rrOutput); + var properties = XRRListOutputProperties(_x11.Display,output, out int propertyCount); + var hasEDID = false; + for(var pc = 0; pc < propertyCount; pc++) + { + if(properties[pc] == _x11.Atoms.RR_PROPERTY_RANDR_EDID) + hasEDID = true; + } + if(!hasEDID) + return null; + XRRGetOutputProperty(_x11.Display, output, _x11.Atoms.RR_PROPERTY_RANDR_EDID, 0, 128, false, false, _x11.Atoms.AnyPropertyType, out int actualType, out int actualFormat, out int nItems, out _, out IntPtr prop); + if(actualType != 19) // XA_INTEGER + return null; + if(actualFormat != 8) + return null; + + var edid = new byte[nItems]; + Marshal.Copy(prop,edid,0,nItems); + XFree(prop); + XFree(new IntPtr(properties)); + if(edid.Length < 22) + return null; + var width = edid[21]; + var height = edid[22]; + if(width == 0 && height == 0) + return null; + return new Size(width * 10, height * 10); + } + public unsafe X11Screen[] Screens { get @@ -97,24 +130,13 @@ namespace Avalonia.X11 var namePtr = XGetAtomName(_x11.Display, mon.Name); var name = Marshal.PtrToStringAnsi(namePtr); XFree(namePtr); - + var bounds = new PixelRect(mon.X, mon.Y, mon.Width, mon.Height); var density = 1d; - if (_settings.NamedScaleFactors?.TryGetValue(name, out density) != true) - { - if (mon.MWidth == 0) - density = 1; - else - density = X11Screen.GuessPixelDensity(mon.Width, mon.MWidth); - } - + var pSize = GetPhysicalMonitorSizeFromEDID(mon.Outputs); + if (_settings.NamedScaleFactors?.TryGetValue(name, out density) != true && pSize != null) + density = X11Screen.GuessPixelDensity(bounds, pSize.Value); density *= _settings.GlobalScaleFactor; - - var bounds = new PixelRect(mon.X, mon.Y, mon.Width, mon.Height); - screens[c] = new X11Screen(bounds, - mon.Primary != 0, - name, - (mon.MWidth == 0 || mon.MHeight == 0) ? (Size?)null : new Size(mon.MWidth, mon.MHeight), - density); + screens[c] = new X11Screen(bounds, mon.Primary != 0, name, pSize, density); } XFree(new IntPtr(monitors)); @@ -163,7 +185,6 @@ namespace Avalonia.X11 } - public int ScreenCount => _impl.Screens.Length; public IReadOnlyList AllScreens => @@ -229,6 +250,7 @@ namespace Avalonia.X11 class X11Screen { private const int FullHDWidth = 1920; + private const int FullHDHeight = 1080; public bool Primary { get; } public string Name { get; set; } public PixelRect Bounds { get; set; } @@ -248,7 +270,7 @@ namespace Avalonia.X11 } else if (pixelDensity == null) { - PixelDensity = GuessPixelDensity(bounds.Width, physicalSize.Value.Width); + PixelDensity = GuessPixelDensity(bounds, physicalSize.Value); } else { @@ -257,7 +279,26 @@ namespace Avalonia.X11 } } - public static double GuessPixelDensity(double pixelWidth, double mmWidth) - => pixelWidth <= FullHDWidth ? 1 : Math.Max(1, Math.Round(pixelWidth / mmWidth * 25.4 / 96)); + public static double GuessPixelDensity(PixelRect pixel, Size physical) + { + var calculatedDensity = 1d; + if(physical.Width > 0) + calculatedDensity = pixel.Width <= FullHDWidth ? 1 : Math.Max(1, pixel.Width / physical.Width * 25.4 / 96); + else if(physical.Height > 0) + calculatedDensity = pixel.Height <= FullHDHeight ? 1 : Math.Max(1, pixel.Height / physical.Height * 25.4 / 96); + + if(calculatedDensity > 3) + return 1; + else + { + var sanePixelDensities = new double[] { 1, 1.25, 1.50, 1.75, 2 }; + foreach(var saneDensity in sanePixelDensities) + { + if(calculatedDensity <= saneDensity + 0.20) + return saneDensity; + } + return sanePixelDensities.Last(); + } + } } } diff --git a/src/Avalonia.X11/XLib.cs b/src/Avalonia.X11/XLib.cs index 85aa4862b7..92308cb7a1 100644 --- a/src/Avalonia.X11/XLib.cs +++ b/src/Avalonia.X11/XLib.cs @@ -500,6 +500,13 @@ namespace Avalonia.X11 [DllImport(libX11Randr)] public static extern XRRMonitorInfo* XRRGetMonitors(IntPtr dpy, IntPtr window, bool get_active, out int nmonitors); + + [DllImport(libX11Randr)] + public static extern IntPtr* XRRListOutputProperties(IntPtr dpy, long output, out int count); + + [DllImport(libX11Randr)] + public static extern int XRRGetOutputProperty(IntPtr dpy, long output, IntPtr atom, long offset, long length, bool _delete, bool pending, IntPtr req_type, out int actual_type, out int actual_format, out int nitems, out long bytes_after, out IntPtr prop); + [DllImport(libX11Randr)] public static extern void XRRSelectInput(IntPtr dpy, IntPtr window, RandrEventMask mask); From e9737d49082e54f16208ac85ae13fe154a8fd145 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 14 Dec 2020 17:05:32 +0000 Subject: [PATCH 09/65] Update readme.md --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 726a634e1a..5a64352da1 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,8 @@ Examples of UIs built with Avalonia ## JetBrains Rider -If you need to develop Avalonia app with JetBrains Rider you can use latest Rider [preview builds](https://www.jetbrains.com/rider/nextversion/). +JetBrains rider now has official support for Avalonia. +https://www.jetbrains.com/rider/whatsnew/?mkt_tok=eyJpIjoiTURBNU1HSmhNV0kwTUdFMiIsInQiOiJtNnU2VEc1TlNLa1ZRVkROYmdZYVpYREJsaU1qdUhmS3dxSzRHczdYWHl0RVlTNDMwSFwvNUs3VENTNVM0bVcyNFdaRmVYZzVWTTF1N3VrQWNGTkJreEhlam1hMlB4UVVWcHBGM1dNOUxoXC95YnRQdGgyUXl1YmZCM3h3d3BVWWdBIn0%3D#avalonia-support ## Bleeding Edge Builds From 54fc32908d3cb97c425c5926827112eb8867297d Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 14 Dec 2020 17:06:44 +0000 Subject: [PATCH 10/65] Update readme.md --- readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 5a64352da1..67c253db81 100644 --- a/readme.md +++ b/readme.md @@ -39,8 +39,7 @@ Examples of UIs built with Avalonia ## JetBrains Rider -JetBrains rider now has official support for Avalonia. -https://www.jetbrains.com/rider/whatsnew/?mkt_tok=eyJpIjoiTURBNU1HSmhNV0kwTUdFMiIsInQiOiJtNnU2VEc1TlNLa1ZRVkROYmdZYVpYREJsaU1qdUhmS3dxSzRHczdYWHl0RVlTNDMwSFwvNUs3VENTNVM0bVcyNFdaRmVYZzVWTTF1N3VrQWNGTkJreEhlam1hMlB4UVVWcHBGM1dNOUxoXC95YnRQdGgyUXl1YmZCM3h3d3BVWWdBIn0%3D#avalonia-support +[JetBrains Rider]((https://www.jetbrains.com/rider/whatsnew/?mkt_tok=eyJpIjoiTURBNU1HSmhNV0kwTUdFMiIsInQiOiJtNnU2VEc1TlNLa1ZRVkROYmdZYVpYREJsaU1qdUhmS3dxSzRHczdYWHl0RVlTNDMwSFwvNUs3VENTNVM0bVcyNFdaRmVYZzVWTTF1N3VrQWNGTkJreEhlam1hMlB4UVVWcHBGM1dNOUxoXC95YnRQdGgyUXl1YmZCM3h3d3BVWWdBIn0%3D#avalonia-support) now has official support for Avalonia. ## Bleeding Edge Builds From 02bdf83bdcd3030d0131d39541b51cc6aa3c9b0f Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 14 Dec 2020 17:07:06 +0000 Subject: [PATCH 11/65] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 67c253db81..b63736f773 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,7 @@ Examples of UIs built with Avalonia ## JetBrains Rider -[JetBrains Rider]((https://www.jetbrains.com/rider/whatsnew/?mkt_tok=eyJpIjoiTURBNU1HSmhNV0kwTUdFMiIsInQiOiJtNnU2VEc1TlNLa1ZRVkROYmdZYVpYREJsaU1qdUhmS3dxSzRHczdYWHl0RVlTNDMwSFwvNUs3VENTNVM0bVcyNFdaRmVYZzVWTTF1N3VrQWNGTkJreEhlam1hMlB4UVVWcHBGM1dNOUxoXC95YnRQdGgyUXl1YmZCM3h3d3BVWWdBIn0%3D#avalonia-support) now has official support for Avalonia. +[JetBrains Rider](https://www.jetbrains.com/rider/whatsnew/?mkt_tok=eyJpIjoiTURBNU1HSmhNV0kwTUdFMiIsInQiOiJtNnU2VEc1TlNLa1ZRVkROYmdZYVpYREJsaU1qdUhmS3dxSzRHczdYWHl0RVlTNDMwSFwvNUs3VENTNVM0bVcyNFdaRmVYZzVWTTF1N3VrQWNGTkJreEhlam1hMlB4UVVWcHBGM1dNOUxoXC95YnRQdGgyUXl1YmZCM3h3d3BVWWdBIn0%3D#avalonia-support) now has official support for Avalonia. ## Bleeding Edge Builds From 6d4dc7fe8daf7e322448d884e458651fa397dd67 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 14 Dec 2020 20:08:25 +0300 Subject: [PATCH 12/65] Update readme.md --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index b63736f773..b5cb38df90 100644 --- a/readme.md +++ b/readme.md @@ -41,6 +41,8 @@ Examples of UIs built with Avalonia [JetBrains Rider](https://www.jetbrains.com/rider/whatsnew/?mkt_tok=eyJpIjoiTURBNU1HSmhNV0kwTUdFMiIsInQiOiJtNnU2VEc1TlNLa1ZRVkROYmdZYVpYREJsaU1qdUhmS3dxSzRHczdYWHl0RVlTNDMwSFwvNUs3VENTNVM0bVcyNFdaRmVYZzVWTTF1N3VrQWNGTkJreEhlam1hMlB4UVVWcHBGM1dNOUxoXC95YnRQdGgyUXl1YmZCM3h3d3BVWWdBIn0%3D#avalonia-support) now has official support for Avalonia. +Code completion, inspections and refactorings are supported out of the box, for XAML previewer add `https://plugins.jetbrains.com/plugins/dev/14839` to plugin repositories and install [AvaloniaRider](https://github.com/ForNeVeR/AvaloniaRider) plugin. + ## Bleeding Edge Builds We also have a [nightly build](https://github.com/AvaloniaUI/Avalonia/wiki/Using-nightly-build-feed) which tracks the current state of master. Although these packages are less stable than the release on NuGet.org, you'll get all the latest features and bugfixes right away and many of our users actually prefer this feed! From 8ae3a9f3580e65a6b00e119c758f5a10f83bb59a Mon Sep 17 00:00:00 2001 From: Max Katz Date: Tue, 15 Dec 2020 23:11:54 -0500 Subject: [PATCH 13/65] Fix DataGridColumn.DisplayIndex initial value handling --- samples/ControlCatalog/Pages/DataGridPage.xaml | 4 ++-- src/Avalonia.Controls.DataGrid/DataGrid.cs | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/samples/ControlCatalog/Pages/DataGridPage.xaml b/samples/ControlCatalog/Pages/DataGridPage.xaml index cacc2204bd..6817d0698e 100644 --- a/samples/ControlCatalog/Pages/DataGridPage.xaml +++ b/samples/ControlCatalog/Pages/DataGridPage.xaml @@ -38,8 +38,8 @@ - - + + diff --git a/src/Avalonia.Controls.DataGrid/DataGrid.cs b/src/Avalonia.Controls.DataGrid/DataGrid.cs index 5bb2763566..e582153f41 100644 --- a/src/Avalonia.Controls.DataGrid/DataGrid.cs +++ b/src/Avalonia.Controls.DataGrid/DataGrid.cs @@ -2285,6 +2285,17 @@ namespace Avalonia.Controls } } + /// + /// Comparator class so we can sort list by the display index + /// + public class DisplayIndexComparer : IComparer + { + int IComparer.Compare(DataGridColumn x, DataGridColumn y) + { + return (x.DisplayIndexWithFiller < y.DisplayIndexWithFiller) ? -1 : 1; + } + } + /// /// Builds the visual tree for the column header when a new template is applied. /// @@ -2309,8 +2320,11 @@ namespace Avalonia.Controls ColumnsInternal.FillerColumn.IsRepresented = false; } _columnHeadersPresenter.OwningGrid = this; - // Columns were added before before our Template was applied, add the ColumnHeaders now - foreach (DataGridColumn column in ColumnsItemsInternal) + + // Columns were added before our Template was applied, add the ColumnHeaders now + List sortedInternal = new List(ColumnsItemsInternal); + sortedInternal.Sort(new DisplayIndexComparer()); + foreach (DataGridColumn column in sortedInternal) { InsertDisplayedColumnHeader(column); } From c2b405b45c15cf102e3ae354a0ca1ef3bccf801c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 16 Dec 2020 09:04:56 +0000 Subject: [PATCH 14/65] Set correct pointerover brush for expander control --- src/Avalonia.Themes.Fluent/Controls/Expander.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Themes.Fluent/Controls/Expander.xaml b/src/Avalonia.Themes.Fluent/Controls/Expander.xaml index 97ca62c493..ad0fd18ea5 100644 --- a/src/Avalonia.Themes.Fluent/Controls/Expander.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/Expander.xaml @@ -108,7 +108,7 @@ diff --git a/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml b/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml index 1c9574f169..508473796c 100644 --- a/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml @@ -97,8 +97,8 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml index 1da48ebd8a..288b3ccee6 100644 --- a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml @@ -1,8 +1,7 @@ - + @@ -48,6 +49,8 @@ Padding="{TemplateBinding Padding}" Watermark="{TemplateBinding Watermark}" IsReadOnly="{TemplateBinding IsReadOnly}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Text="{TemplateBinding Text}" AcceptsReturn="False" TextWrapping="NoWrap" /> From 107b4d83fdc026dcfc3fe692c8ae683341b11126 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sat, 2 Jan 2021 02:50:10 -0500 Subject: [PATCH 38/65] Add HorizontalContentAlignment/VerticalContentAlignment props to CalendarDatePicker --- .../Calendar/CalendarDatePicker.cs | 32 +++++++++++++++++++ .../CalendarDatePicker.xaml | 2 ++ .../Controls/CalendarDatePicker.xaml | 8 +++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs index 7c259f0a09..af3fdbd662 100644 --- a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs +++ b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs @@ -11,6 +11,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Data; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.Layout; namespace Avalonia.Controls { @@ -209,6 +210,18 @@ namespace Avalonia.Controls TextBox.UseFloatingWatermarkProperty.AddOwner(); + /// + /// Defines the property. + /// + public static readonly StyledProperty HorizontalContentAlignmentProperty = + ContentControl.HorizontalContentAlignmentProperty.AddOwner(); + + /// + /// Defines the property. + /// + public static readonly StyledProperty VerticalContentAlignmentProperty = + ContentControl.VerticalContentAlignmentProperty.AddOwner(); + /// /// Gets or sets the date to display. /// @@ -364,6 +377,25 @@ namespace Avalonia.Controls set { SetValue(UseFloatingWatermarkProperty, value); } } + + /// + /// Gets or sets the horizontal alignment of the content within the control. + /// + public HorizontalAlignment HorizontalContentAlignment + { + get => GetValue(HorizontalContentAlignmentProperty); + set => SetValue(HorizontalContentAlignmentProperty, value); + } + + /// + /// Gets or sets the vertical alignment of the content within the control. + /// + public VerticalAlignment VerticalContentAlignment + { + get => GetValue(VerticalContentAlignmentProperty); + set => SetValue(VerticalContentAlignmentProperty, value); + } + /// /// Occurs when the drop-down /// is closed. diff --git a/src/Avalonia.Themes.Default/CalendarDatePicker.xaml b/src/Avalonia.Themes.Default/CalendarDatePicker.xaml index bc1aba1a03..aab7d06c46 100644 --- a/src/Avalonia.Themes.Default/CalendarDatePicker.xaml +++ b/src/Avalonia.Themes.Default/CalendarDatePicker.xaml @@ -93,6 +93,8 @@ Watermark="{TemplateBinding Watermark}" UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Column="0"/>