diff --git a/.github/workflows/api_unittest.yml b/.github/workflows/api_unittest.yml
new file mode 100644
index 0000000..10cce38
--- /dev/null
+++ b/.github/workflows/api_unittest.yml
@@ -0,0 +1,31 @@
+name: API Unittest
+
+on:
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup .NET10
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 10.0.x
+
+ - name: Restore workloads
+ run: dotnet workload restore ./Test.RelativeControl/Test.RelativeControl.csproj
+
+ - name: Restore dependencies
+ run: dotnet restore ./Test.RelativeControl/Test.RelativeControl.csproj
+
+ - name: Build
+ run: dotnet build --no-restore --configuration Release ./Test.RelativeControl/Test.RelativeControl.csproj
+
+ - name: Run tests
+ run: dotnet run --project ./Test.RelativeControl/Test.RelativeControl.csproj
\ No newline at end of file
diff --git a/.github/workflows/headless_unittest.yml b/.github/workflows/headless_unittest.yml
new file mode 100644
index 0000000..5f5735b
--- /dev/null
+++ b/.github/workflows/headless_unittest.yml
@@ -0,0 +1,33 @@
+# 工作流的名称
+name: Headless Unittest
+
+# 触发工作流的事件:当代码推送到 main 分支或发起 pull request 时运行
+on:
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup .NET10
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 10.0.x
+
+ - name: Restore workloads
+ run: dotnet workload restore ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
+
+ - name: Restore dependencies
+ run: dotnet restore ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
+
+ - name: Build
+ run: dotnet build --no-restore --configuration Release ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
+
+ - name: Run tests
+ run: dotnet run --project ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Demo.RelativeControl.Android.csproj b/Demo.RelativeControl/Demo.RelativeControl.Android/Demo.RelativeControl.Android.csproj
deleted file mode 100644
index 473d3a9..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Demo.RelativeControl.Android.csproj
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- Exe
- net9.0-android
- 21
- enable
- com.CompanyName.Demo.RelativeControl
- 1
- 1.0
- apk
- false
-
-
-
-
- Resources\drawable\Icon.png
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Icon.png b/Demo.RelativeControl/Demo.RelativeControl.Android/Icon.png
deleted file mode 100644
index 41a2a61..0000000
Binary files a/Demo.RelativeControl/Demo.RelativeControl.Android/Icon.png and /dev/null differ
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/MainActivity.cs b/Demo.RelativeControl/Demo.RelativeControl.Android/MainActivity.cs
deleted file mode 100644
index dc5fb7a..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/MainActivity.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Android.App;
-using Android.Content.PM;
-using Avalonia;
-using Avalonia.Android;
-using Avalonia.ReactiveUI;
-
-namespace Demo.RelativeControl.Android;
-
-[Activity(
- Label = "Demo.RelativeControl.Android",
- Theme = "@style/MyTheme.NoActionBar",
- Icon = "@drawable/icon",
- MainLauncher = true,
- ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
-public class MainActivity : AvaloniaMainActivity {
- protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) {
- return base.CustomizeAppBuilder(builder).WithInterFont().UseReactiveUI();
- }
-}
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Properties/AndroidManifest.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Properties/AndroidManifest.xml
deleted file mode 100644
index f6039c3..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Properties/AndroidManifest.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/AboutResources.txt b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/AboutResources.txt
deleted file mode 100644
index c2bca97..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/AboutResources.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-Images, layout descriptions, binary blobs and string dictionaries can be included
-in your application as resource files. Various Android APIs are designed to
-operate on the resource IDs instead of dealing with images, strings or binary blobs
-directly.
-
-For example, a sample Android app that contains a user interface layout (main.axml),
-an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
-would keep its resources in the "Resources" directory of the application:
-
-Resources/
- drawable/
- icon.png
-
- layout/
- main.axml
-
- values/
- strings.xml
-
-In order to get the build system to recognize Android resources, set the build action to
-"AndroidResource". The native Android APIs do not operate directly with filenames, but
-instead operate on resource IDs. When you compile an Android application that uses resources,
-the build system will package the resources for distribution and generate a class called "R"
-(this is an Android convention) that contains the tokens for each one of the resources
-included. For example, for the above Resources layout, this is what the R class would expose:
-
-public class R {
- public class drawable {
- public const int icon = 0x123;
- }
-
- public class layout {
- public const int main = 0x456;
- }
-
- public class strings {
- public const int first_string = 0xabc;
- public const int second_string = 0xbcd;
- }
-}
-
-You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
-to reference the layout/main.axml file, or R.strings.first_string to reference the first
-string in the dictionary file values/strings.xml.
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-night-v31/avalonia_anim.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-night-v31/avalonia_anim.xml
deleted file mode 100644
index fb8ed42..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-night-v31/avalonia_anim.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-v31/avalonia_anim.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-v31/avalonia_anim.xml
deleted file mode 100644
index 149badf..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-v31/avalonia_anim.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable/splash_screen.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable/splash_screen.xml
deleted file mode 100644
index fcceec6..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable/splash_screen.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- -
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-night/colors.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-night/colors.xml
deleted file mode 100644
index 3c9f0b1..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-night/colors.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- #212121
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-v31/styles.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-v31/styles.xml
deleted file mode 100644
index a93e7c4..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-v31/styles.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/colors.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/colors.xml
deleted file mode 100644
index 53097af..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/colors.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- #FFFFFF
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/styles.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/styles.xml
deleted file mode 100644
index 2deaa4c..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Demo.RelativeControl.Browser.csproj b/Demo.RelativeControl/Demo.RelativeControl.Browser/Demo.RelativeControl.Browser.csproj
deleted file mode 100644
index 8926bb4..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Demo.RelativeControl.Browser.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- net9.0-browser
- Exe
- true
-
-
-
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Program.cs b/Demo.RelativeControl/Demo.RelativeControl.Browser/Program.cs
deleted file mode 100644
index 4aa5937..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Program.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Runtime.Versioning;
-using System.Threading.Tasks;
-using Avalonia;
-using Avalonia.Browser;
-using Avalonia.ReactiveUI;
-using Demo.RelativeControl;
-
-[assembly: SupportedOSPlatform("browser")]
-
-internal sealed partial class Program {
- private static Task Main(string[] args) =>
- BuildAvaloniaApp().WithInterFont().UseReactiveUI().StartBrowserAppAsync("out");
-
- public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure();
-}
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/AssemblyInfo.cs b/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/AssemblyInfo.cs
deleted file mode 100644
index f31aed8..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1 +0,0 @@
-[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")]
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/launchSettings.json b/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/launchSettings.json
deleted file mode 100644
index 8593603..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/launchSettings.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "profiles": {
- "Demo.RelativeControl.Browser": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:7169;http://localhost:5235",
- "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
- }
- }
-}
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/runtimeconfig.template.json b/Demo.RelativeControl/Demo.RelativeControl.Browser/runtimeconfig.template.json
deleted file mode 100644
index 0d03d03..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/runtimeconfig.template.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "wasmHostProperties": {
- "perHostConfig": [
- {
- "name": "browser",
- "host": "browser"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/app.css b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/app.css
deleted file mode 100644
index f79185c..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/app.css
+++ /dev/null
@@ -1,58 +0,0 @@
-/* HTML styles for the splash screen */
-.avalonia-splash {
- position: absolute;
- height: 100%;
- width: 100%;
- background: white;
- font-family: 'Outfit', sans-serif;
- justify-content: center;
- align-items: center;
- display: flex;
- pointer-events: none;
-}
-
-/* Light theme styles */
-@media (prefers-color-scheme: light) {
- .avalonia-splash {
- background: white;
- }
-
- .avalonia-splash h2 {
- color: #1b2a4e;
- }
-
- .avalonia-splash a {
- color: #0D6EFD;
- }
-}
-
-@media (prefers-color-scheme: dark) {
- .avalonia-splash {
- background: #1b2a4e;
- }
-
- .avalonia-splash h2 {
- color: white;
- }
-
- .avalonia-splash a {
- color: white;
- }
-}
-
-.avalonia-splash h2 {
- font-weight: 400;
- font-size: 1.5rem;
-}
-
-.avalonia-splash a {
- text-decoration: none;
- font-size: 2.5rem;
- display: block;
-}
-
-.avalonia-splash.splash-close {
- transition: opacity 200ms, display 200ms;
- display: none;
- opacity: 0;
-}
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/favicon.ico b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/favicon.ico
deleted file mode 100644
index da8d49f..0000000
Binary files a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/favicon.ico and /dev/null differ
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/index.html b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/index.html
deleted file mode 100644
index 4250d06..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/index.html
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
- Demo.RelativeControl.Browser
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/main.js b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/main.js
deleted file mode 100644
index 4d5852e..0000000
--- a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/main.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import {dotnet} from './_framework/dotnet.js'
-
-const is_browser = typeof window != "undefined";
-if (!is_browser) throw new Error(`Expected to be running in a browser`);
-
-const dotnetRuntime = await dotnet
- .withDiagnosticTracing(false)
- .withApplicationArgumentsFromQuery()
- .create();
-
-const config = dotnetRuntime.getConfig();
-
-await dotnetRuntime.runMain(config.mainAssemblyName, [globalThis.location.href]);
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj
index a737814..2cc1f7a 100644
--- a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj
+++ b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj
@@ -3,7 +3,7 @@
WinExe
- net9.0
+ net10.0
enable
true
@@ -13,9 +13,8 @@
-
+
-
diff --git a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs
index 095d31b..40801a6 100644
--- a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs
+++ b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs
@@ -1,6 +1,5 @@
using System;
using Avalonia;
-using Avalonia.ReactiveUI;
namespace Demo.RelativeControl.Desktop;
@@ -8,9 +7,10 @@ sealed class Program {
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
- [STAThread] public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
+ [STAThread]
+ public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp() =>
- AppBuilder.Configure().UsePlatformDetect().WithInterFont().UseReactiveUI().LogToTrace();
+ AppBuilder.Configure().UsePlatformDetect().WithInterFont().LogToTrace();
}
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs b/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs
index 1d2403b..d21f9ed 100644
--- a/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs
+++ b/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs
@@ -1,10 +1,6 @@
using Foundation;
-using UIKit;
using Avalonia;
-using Avalonia.Controls;
using Avalonia.iOS;
-using Avalonia.Media;
-using Avalonia.ReactiveUI;
namespace Demo.RelativeControl.iOS;
@@ -17,6 +13,6 @@ public partial class AppDelegate : AvaloniaAppDelegate
#pragma warning restore CA1711 // Identifiers should not have incorrect suffix
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) {
- return base.CustomizeAppBuilder(builder).WithInterFont().UseReactiveUI();
+ return base.CustomizeAppBuilder(builder).WithInterFont();
}
}
\ No newline at end of file
diff --git a/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj b/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj
index 20fb5ea..a36a528 100644
--- a/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj
+++ b/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj
@@ -1,13 +1,13 @@
Exe
- net9.0-ios
+ net10.0-ios
13.0
enable
-
+
diff --git a/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj b/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj
index bfe8e81..e83f5a0 100644
--- a/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj
+++ b/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj
@@ -1,18 +1,15 @@
- net9.0
+ net10.0
enable
latest
true
-
+
-
-
-
-
-
-
+
+
+
diff --git a/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml b/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml
index 9bd6d1c..33f6c35 100644
--- a/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml
+++ b/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml
@@ -28,7 +28,7 @@
diff --git a/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs b/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs
index dd8c48d..9e15561 100644
--- a/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs
+++ b/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs
@@ -1,7 +1,5 @@
using Avalonia.Controls;
-using Avalonia.Controls.Templates;
using Avalonia.Headless.XUnit;
-using Avalonia.VisualTree;
using RelativeControl.Avalonia;
namespace HeadlessTest.RelativeControl;
diff --git a/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj b/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
index 4d71747..8a85db7 100644
--- a/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
+++ b/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj
@@ -1,6 +1,7 @@
+ Exe
net9.0
enable
enable
@@ -8,20 +9,16 @@
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
diff --git a/README.md b/README.md
index 4e39f23..b943f54 100644
--- a/README.md
+++ b/README.md
@@ -8,16 +8,6 @@ This provides some relative units and features for [Avalonia](https://github.com
[More Info](API%20References.md)
-## New Features in 1.3.x
-- Now support using relatives in style setters.
-```xaml
-
-```
-- Now you can use a visual anchor to provide relative feature for objects which is non-visual but have layout properties.
-
-
## Get Started
### Add NuGet package:
@@ -97,7 +87,7 @@ Other properties using `RelativeThickness`:
### Bind any property
```xaml
-
+
```
> This will set the `PROPERTY`'s value to 50% of `SOURCE_PROPERTY`'s value.
@@ -154,115 +144,4 @@ public static readonly AttachedProperty> XXXProperty =
em: The control's FontSize
vw: Window's width
vh: Window's height
- %: Represents percentage. Only used for custom bindings.
-
-## Minimum Available Version of an API
-
-### 0.0.5
-
-- Width
-- Height
-- MinWidth
-- MinHeight
-- MaxWidth
-- MaxHeight
-- BorderThickness
-- CornerRadius
-
-### 0.1.0
-
-- Margin
-- Padding
-
-### 1.0.0-alpha
-
-- RelativeBinding
-
-> You can bind any property! *[How to bind a custom property?](#bind-any-property)*
-
-### 1.0.0-beta
-
-- SetOneTimeWidth
-- SetOneTimeHeight
-- RelativeBindOneTime
-
-> These will update only once when the control is attached to visual tree!
-
-## Breaking Changes
-
-### 0.2.1:
-
-Relative units are using percentages (Excepts `em`). To make it more like *css*.
-
-```diff
--
-+
-```
-
-### 1.0.0-alpha:
-
-*Move all relative length from **Units.cs** to **RelativeLength.cs***
-
-#### RelativeLength.cs:
-
-```diff
-+ public abstract class RelativeLengthBase
-
-- RelativeLength.RelativeLengthChanged (Rename)
-+ RelativeLengthBase.RelativeLengthChanged
-
-- RelativeLengthBase.OnRelativeLengthChanged (Rename)
-+ RelativeLengthBase.RelativeLengthChanged
-
-- RelativeMerge.Multiplier (Rename)
-+ RelativeLengthCollection.Scaler
-
-- SetTarget
-```
-
-#### RelativeThickness.cs:
-
-```diff
-- RelativeThicknessChanged (Rename)
-+ RelativeThicknessChangedHandler
-
-- OnRelativeThicknessChanged (Rename)
-+ RelativeThicknessChanged
-
-- SetTarget
-```
-
-#### RelativeSize.cs:
-
-```diff
-- RelativeSizeChanged (Rename)
-+ RelativeSizeChangedHandler
-
-- OnRelativeSizeChanged (Rename)
-+ RelativeSizeChanged
-
-- SetTarget
-```
-
-#### RelativeCornerRadius.cs:
-
-```diff
-- RelativeCornerRadiusChanged (Rename)
-+ RelativeCornerRadiusChangedHandler
-
-- OnRelativeCornerRadiusChanged (Rename)
-+ RelativeCornerRadiusChanged
-
-- SetTarget
-```
-
-### 1.0.0-beta:
-
-```diff
-- public event RelativeXXXChanged(T oldValue,T newValue);
-+ public event RelativeChanged(IRelative sender,RelativeChangedEventArgs args);
-+ public class RelativeChangedEventArgs(T oldValue, T newValue) : RelativeChangedEventArgs {
-+ public readonly T OldValue = oldValue;
-+ public readonly T NewValue = newValue;
-+ }
-```
\ No newline at end of file
+ %: Represents percentage. Only used for RelativeScale.
\ No newline at end of file
diff --git a/README_CN.md b/README_CN.md
index 4640c80..f2abc96 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -8,23 +8,6 @@
[更多信息](API%20References.md)
-## 1.3.x中增加的新功能
-
-- 现在支持在Style Setter中使用相对单位
-
-```xaml
-
-```
-
-- 现在你可以为非Visual控件,但是有布局属性的实例使用相对单位
-
-```csharp
-var _object: AvaloniaObject = new();
-Relative.SetWidth(_object,"10pw",)
-```
-
## 开始使用
### 添加NuGet包:
@@ -102,7 +85,7 @@ dotnet add package RelativeControl.Avalonia
### 为任意属性绑定相对值
```xaml
-
+
```
> 这会设定此`Property`的值为`SOURCE_PROPERTY`值的50%.
@@ -115,8 +98,9 @@ dotnet add package RelativeControl.Avalonia
> `RelativeBindOneTime`只在控件附加到视觉树时更新一次。
### 为非Visual控件,但是有布局属性的实例使用相对单位
+
> 实际上,此功能是将Source的搜索锚点由Target修改为VisualAnchor实现的。
->
+>
> 此功能还可以用于让某个控件以另一个控件作为自己的相对源
```csharp
@@ -170,115 +154,4 @@ public static readonly AttachedProperty> XXXProperty =
em: 字宽
vw: 窗口宽度
vh: 窗口高度
- %: 百分比,仅用于RelativeBinding和RelativeBindOneTime
-
-## API最小可用版本
-
-### 0.0.5
-
-- Width
-- Height
-- MinWidth
-- MinHeight
-- MaxWidth
-- MaxHeight
-- BorderThickness
-- CornerRadius
-
-### 0.1.0
-
-- Margin
-- Padding
-
-### 1.0.0-alpha
-
-- RelativeBinding
-
-> 支持相对属性绑定 *[如何绑定自定义属性?](#为任意属性绑定相对值)*
-
-### 1.0.0-beta
-
-- SetOneTimeWidth
-- SetOneTimeHeight
-- RelativeBindOneTime
-
-> 这些属性仅会在自身控件附加到视觉树时更新一次
-
-## 破坏性变化
-
-### 0.2.1:
-
-除了`em`之外的所有相对单位均改为百分比计算。*使相对单位更接近CSS用法*
-
-```diff
--
-+
-```
-
-### 1.0.0-alpha:
-
-*将所有相对类型从 **Units.cs** 移至 **RelativeLength.cs***
-
-#### RelativeLength.cs:
-
-```diff
-+ public abstract class RelativeLengthBase
-
-- RelativeLength.RelativeLengthChanged (Rename)
-+ RelativeLengthBase.RelativeLengthChanged
-
-- RelativeLengthBase.OnRelativeLengthChanged (Rename)
-+ RelativeLengthBase.RelativeLengthChanged
-
-- RelativeMerge.Multiplier (Rename)
-+ RelativeLengthCollection.Scaler
-
-- SetTarget
-```
-
-#### RelativeThickness.cs:
-
-```diff
-- RelativeThicknessChanged (Rename)
-+ RelativeThicknessChangedHandler
-
-- OnRelativeThicknessChanged (Rename)
-+ RelativeThicknessChanged
-
-- SetTarget
-```
-
-#### RelativeSize.cs:
-
-```diff
-- RelativeSizeChanged (Rename)
-+ RelativeSizeChangedHandler
-
-- OnRelativeSizeChanged (Rename)
-+ RelativeSizeChanged
-
-- SetTarget
-```
-
-#### RelativeCornerRadius.cs:
-
-```diff
-- RelativeCornerRadiusChanged (Rename)
-+ RelativeCornerRadiusChangedHandler
-
-- OnRelativeCornerRadiusChanged (Rename)
-+ RelativeCornerRadiusChanged
-
-- SetTarget
-```
-
-### 1.0.0-beta:
-
-```diff
-- public event RelativeXXXChanged(T oldValue,T newValue);
-+ public event RelativeChanged(IRelative sender,RelativeChangedEventArgs args);
-+ public class RelativeChangedEventArgs(T oldValue, T newValue) : RelativeChangedEventArgs {
-+ public readonly T OldValue = oldValue;
-+ public readonly T NewValue = newValue;
-+ }
-```
\ No newline at end of file
+ %: 百分比,仅用于RelativeScale
\ No newline at end of file
diff --git a/RelativeControl.Avalonia.sln b/RelativeControl.Avalonia.sln
index d84b8eb..13aba7b 100644
--- a/RelativeControl.Avalonia.sln
+++ b/RelativeControl.Avalonia.sln
@@ -15,14 +15,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.RelativeControl", "Dem
{FEA7395D-C139-4586-8822-457457163A16} = {FEA7395D-C139-4586-8822-457457163A16}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.RelativeControl.Android", "Demo.RelativeControl\Demo.RelativeControl.Android\Demo.RelativeControl.Android.csproj", "{3A391BA4-9171-4041-95B1-FA6C82A0A787}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.RelativeControl.Desktop", "Demo.RelativeControl\Demo.RelativeControl.Desktop\Demo.RelativeControl.Desktop.csproj", "{D024C9A0-F054-4AD0-8B28-CD63CA5C2708}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.RelativeControl.iOS", "Demo.RelativeControl\Demo.RelativeControl.iOS\Demo.RelativeControl.iOS.csproj", "{30EA88A3-A559-445E-BE82-821A50F97E44}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.RelativeControl.Browser", "Demo.RelativeControl\Demo.RelativeControl.Browser\Demo.RelativeControl.Browser.csproj", "{C269224E-CFC8-40FE-969E-CD36AB2F31D7}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.RelativeControl", "Test.RelativeControl\Test.RelativeControl.csproj", "{ACCCD38A-95FA-423C-B56E-CACA7C0AEF59}"
ProjectSection(ProjectDependencies) = postProject
{FEA7395D-C139-4586-8822-457457163A16} = {FEA7395D-C139-4586-8822-457457163A16}
@@ -42,10 +38,6 @@ Global
{BBD7DE1F-4E7D-44AC-8EF2-09ADA78DCC1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBD7DE1F-4E7D-44AC-8EF2-09ADA78DCC1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBD7DE1F-4E7D-44AC-8EF2-09ADA78DCC1F}.Release|Any CPU.Build.0 = Release|Any CPU
- {3A391BA4-9171-4041-95B1-FA6C82A0A787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3A391BA4-9171-4041-95B1-FA6C82A0A787}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3A391BA4-9171-4041-95B1-FA6C82A0A787}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3A391BA4-9171-4041-95B1-FA6C82A0A787}.Release|Any CPU.Build.0 = Release|Any CPU
{D024C9A0-F054-4AD0-8B28-CD63CA5C2708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D024C9A0-F054-4AD0-8B28-CD63CA5C2708}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D024C9A0-F054-4AD0-8B28-CD63CA5C2708}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -54,10 +46,6 @@ Global
{30EA88A3-A559-445E-BE82-821A50F97E44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30EA88A3-A559-445E-BE82-821A50F97E44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30EA88A3-A559-445E-BE82-821A50F97E44}.Release|Any CPU.Build.0 = Release|Any CPU
- {C269224E-CFC8-40FE-969E-CD36AB2F31D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C269224E-CFC8-40FE-969E-CD36AB2F31D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C269224E-CFC8-40FE-969E-CD36AB2F31D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C269224E-CFC8-40FE-969E-CD36AB2F31D7}.Release|Any CPU.Build.0 = Release|Any CPU
{ACCCD38A-95FA-423C-B56E-CACA7C0AEF59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACCCD38A-95FA-423C-B56E-CACA7C0AEF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACCCD38A-95FA-423C-B56E-CACA7C0AEF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -70,10 +58,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{BBD7DE1F-4E7D-44AC-8EF2-09ADA78DCC1F} = {9A5B88AA-507E-41F6-B04B-D70955C1D756}
{86F801CC-3A7F-4A84-A8BA-CB5CB8381096} = {3824750C-0D79-41F1-9334-3835D493A719}
- {3A391BA4-9171-4041-95B1-FA6C82A0A787} = {3824750C-0D79-41F1-9334-3835D493A719}
{D024C9A0-F054-4AD0-8B28-CD63CA5C2708} = {3824750C-0D79-41F1-9334-3835D493A719}
{30EA88A3-A559-445E-BE82-821A50F97E44} = {3824750C-0D79-41F1-9334-3835D493A719}
- {C269224E-CFC8-40FE-969E-CD36AB2F31D7} = {3824750C-0D79-41F1-9334-3835D493A719}
{ACCCD38A-95FA-423C-B56E-CACA7C0AEF59} = {9A5B88AA-507E-41F6-B04B-D70955C1D756}
EndGlobalSection
EndGlobal
diff --git a/Test.RelativeControl/Test.RelativeControl.csproj b/Test.RelativeControl/Test.RelativeControl.csproj
index 97aac5e..f0dfb10 100644
--- a/Test.RelativeControl/Test.RelativeControl.csproj
+++ b/Test.RelativeControl/Test.RelativeControl.csproj
@@ -1,6 +1,7 @@
+ Exe
net9.0
enable
enable
@@ -8,13 +9,12 @@
-
-
-
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/global.json b/global.json
index a27a2b8..397bd94 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "9.0.0",
+ "version": "10.0.100",
"rollForward": "latestMajor",
"allowPrerelease": false
}
diff --git a/src/RelativeControl.Avalonia/Relative.cs b/src/RelativeControl.Avalonia/Relative.cs
index 2dd91ae..0e8c6a4 100644
--- a/src/RelativeControl.Avalonia/Relative.cs
+++ b/src/RelativeControl.Avalonia/Relative.cs
@@ -2,9 +2,9 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
-using Avalonia.Data;
using Avalonia.Layout;
using Avalonia.Markup.Xaml;
+using Avalonia.Metadata;
using Avalonia.VisualTree;
namespace RelativeControl.Avalonia;
@@ -465,27 +465,16 @@ public static void SetOneTimeRelativeCornerRadiusProperty(Visual target, Avaloni
}
}
-public class RelativeBinding(BindingBase sourceValue, string value) : MarkupExtension {
- public readonly RelativeScale Scale = RelativeScale.Parse(value);
- public readonly BindingBase SourceValue = sourceValue;
+public class Scale : MarkupExtension {
+ public Scale(string value) { Value = value; }
- public override object ProvideValue(IServiceProvider serviceProvider) {
- SourceValue.Converter = new RelativeConverter();
- SourceValue.ConverterParameter = Scale;
- return SourceValue;
+ [ConstructorArgument("value")]
+ public string Value {
+ set => _parsed = RelativeScale.Parse(value);
}
-}
-
-public class OneTimeRelativeBinding(BindingBase sourceValue, string value) : MarkupExtension {
- public readonly RelativeScale Scale = RelativeScale.Parse(value);
- public readonly BindingBase SourceValue = sourceValue;
- public override object ProvideValue(IServiceProvider serviceProvider) {
- SourceValue.Mode = BindingMode.OneTime;
- SourceValue.Converter = new RelativeConverter();
- SourceValue.ConverterParameter = Scale;
- return SourceValue;
- }
+ private RelativeScale _parsed;
+ public override object ProvideValue(IServiceProvider serviceProvider) { return _parsed; }
}
public static class RelativeParseHelper {
@@ -502,7 +491,7 @@ public static IRelative ParseToThickness(Visual target, object value)
return value switch {
RelativeExpression expression => RelativeThickness.Parse(expression.Expression, target),
string s => RelativeThickness.Parse(s, target),
- IRelative relative => relative,
+ IRelative relative => relative,
_ => throw new InvalidCastException($"{value.GetType()} is not a valid type.")
};
}
@@ -510,9 +499,9 @@ public static IRelative ParseToThickness(Visual target, object value)
public static IRelative ParseToCornerRadius(Visual target, object value) {
return value switch {
RelativeExpression expression => RelativeCornerRadius.Parse(expression.Expression, target),
- string s => RelativeCornerRadius.Parse(s, target),
- IRelative relative => relative,
- _ => throw new InvalidCastException($"{value.GetType()} is not a valid type.")
+ string s => RelativeCornerRadius.Parse(s, target),
+ IRelative relative => relative,
+ _ => throw new InvalidCastException($"{value.GetType()} is not a valid type.")
};
}
}
\ No newline at end of file
diff --git a/src/RelativeControl.Avalonia/RelativeControl.Avalonia.csproj b/src/RelativeControl.Avalonia/RelativeControl.Avalonia.csproj
index 5ef4092..aa2550e 100644
--- a/src/RelativeControl.Avalonia/RelativeControl.Avalonia.csproj
+++ b/src/RelativeControl.Avalonia/RelativeControl.Avalonia.csproj
@@ -1,7 +1,7 @@
enable
- 1.3.3
+ 12.0.0
RelativeControl.Avalonia
metaone01
Provide some relative units and features for Avalonia.
@@ -13,7 +13,7 @@
true
snupkg
true
- net8.0;net9.0
+ net10.0;net8.0;net9.0
@@ -24,8 +24,8 @@
true
-
+
+
-
diff --git a/src/RelativeControl.Avalonia/RelativeLength.cs b/src/RelativeControl.Avalonia/RelativeLength.cs
index ac7925b..e151b5a 100644
--- a/src/RelativeControl.Avalonia/RelativeLength.cs
+++ b/src/RelativeControl.Avalonia/RelativeLength.cs
@@ -824,6 +824,8 @@ public static RelativeScale Parse(string scale) {
}
public sealed class RelativeConverter : IValueConverter {
+ public static readonly RelativeConverter Instance = new();
+
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
RelativeScale para = parameter switch {
RelativeScale rs => rs,