diff --git a/docs/basics/data/data-binding/compiled-bindings.md b/docs/basics/data/data-binding/compiled-bindings.md index 6d8f76b19..70d11c881 100644 --- a/docs/basics/data/data-binding/compiled-bindings.md +++ b/docs/basics/data/data-binding/compiled-bindings.md @@ -103,7 +103,7 @@ If you have compiled bindings enabled in the root node (via `x:CompileBindings=" ## Type casting -In some cases the target type of the binding expression cannot be automatically evaluated. In such cases you muss provide an explicite type cast in the binding expression. +In some cases the target type of the binding expression cannot be automatically evaluated. In such cases you must provide an explicite type cast in the binding expression. ```markup @@ -121,4 +121,4 @@ In some cases the target type of the binding expression cannot be automatically ``` -In this case, the button command shall not be bound to the item's `DataContext` but to a command that is defined in the `DataContext`of the `ItemsRepeater`. The single item will be identified using a `CommandParameter` bound to the item's `DataContext`. Therefore, you must specify the type of the "parent" `DataContext` via cast expression `((vm:MyUserControlViewModel)DataContext)`. \ No newline at end of file +In this case, the button command shall not be bound to the item's `DataContext` but to a command that is defined in the `DataContext`of the `ItemsRepeater`. The single item will be identified using a `CommandParameter` bound to the item's `DataContext`. Therefore, you must specify the type of the "parent" `DataContext` via cast expression `((vm:MyUserControlViewModel)DataContext)`. diff --git a/docs/basics/user-interface/controls/creating-controls/defining-events.md b/docs/basics/user-interface/controls/creating-controls/defining-events.md index 506ef495b..91e6a705d 100644 --- a/docs/basics/user-interface/controls/creating-controls/defining-events.md +++ b/docs/basics/user-interface/controls/creating-controls/defining-events.md @@ -39,8 +39,8 @@ public class MyCustomSlider : Control } ``` -In this example, a custom routed event called `ValueChangedEvent` is defined for the `MyCustomSlider` control. The event is registered using the `RoutedEvent` system, allowing it to be subscribed by users of the control. A CLR event is also defined for concenience, allowing the event to be consumed in manner consistent with standard .NET APIs. +In this example, a custom routed event called `ValueChangedEvent` is defined for the `MyCustomSlider` control. The event is registered using the `RoutedEvent` system, allowing it to be subscribed by users of the control. A CLR event is also defined for convenience, allowing the event to be consumed in manner consistent with standard .NET APIs. ## Further Reading -For more information see the [Routed Events Deep Dive](../../../../concepts/input/routed-events.md) \ No newline at end of file +For more information see the [Routed Events Deep Dive](../../../../concepts/input/routed-events.md) diff --git a/docs/concepts/reactiveui/reactive-command.md b/docs/concepts/reactiveui/reactive-command.md index 1eae2317b..ab3486d88 100644 --- a/docs/concepts/reactiveui/reactive-command.md +++ b/docs/concepts/reactiveui/reactive-command.md @@ -19,8 +19,8 @@ As a starting point, you can create a simple view like this: ```xml User Name - - + + ``` diff --git a/docs/concepts/view-locator.md b/docs/concepts/view-locator.md index ccb23cc19..dfb427d99 100644 --- a/docs/concepts/view-locator.md +++ b/docs/concepts/view-locator.md @@ -11,9 +11,9 @@ The View Locator is a mechanism in Avalonia that is used to resolve the view (us ## How it works -The View Locator uses naming conventions to map ViewModel types to view types. By default, it strips "ViewModel" from the end of the ViewModel type name, and looks for a type with the same name in the same namespace, but in the corresponding "Views" namespace. +The View Locator uses naming conventions to map ViewModel types to view types. By default, it replaces every occurrence of the string "ViewModel" within the fully-qualified ViewModel type name with "View". -For example, given a ViewModel named `MyApplication.ViewModels.ExampleViewModel`, the View Locator will look for a View named `MyApplication.Views.Example`. +For example, given a ViewModel named `MyApplication.ViewModels.ExampleViewModel`, the View Locator will look for a View named `MyApplication.Views.ExampleView`. The View Locator is typically used in conjunction with the `DataContext` property, which is used to link a view to its ViewModel. @@ -46,8 +46,29 @@ public class ViewLocator : IDataTemplate } ``` -In this example, the View Locator is implemented as an `IDataTemplate`. The `Build` method creates the view for the ViewModel, and the `Match` method checks if the data object is a ViewModel that this locator knows how to handle. +In this example, the View Locator is implemented as an `IDataTemplate`. The `Build` method creates the view for the ViewModel, and the `Match` method checks if the data object is a ViewModel that this locator knows how to handle. If you do not have a `ViewModelBase` class, at a minimum your ViewModel must implement `INotifyPropertyChanged`, and the comparison in `Match` should be changed accordingly. ## Customizing the View Locator You can customize the View Locator to use different conventions. For example, you might want to look for views in a different assembly, or use a different naming convention. To do this, you can implement your own View Locator by creating a class that implements the `IDataTemplate` interface, and replace the default View Locator with your own. + +## Using the View Locator + +By default, the View Locator is referenced in App.axaml as a DataTemplate, in the content of the `Application.DataTemplates` XAML tag. Ensure that its appropriate 'using' statement is in the `xmlns:local` property of the Application root tag. + +```xaml + + + + + + + + + + +``` diff --git a/docs/get-started/test-drive/code-with-controls.md b/docs/get-started/test-drive/code-with-controls.md index 5484a970d..3e9e5b90f 100644 --- a/docs/get-started/test-drive/code-with-controls.md +++ b/docs/get-started/test-drive/code-with-controls.md @@ -87,7 +87,7 @@ You can check your work using the following conversion table: - You have now used an event handler to get and set control properties at runtime. You could now try some of these exercises: - Stop showing the gridlines (easy). -- Stop the user changing the text in the Fahrenheit input by setting the `ReadOnly` attribute (easy). +- Stop the user changing the text in the Fahrenheit input by setting the `IsReadOnly` attribute (easy). - Calculate the conversion as the user types into the Celsius input (moderate). :::info diff --git a/docs/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md b/docs/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md index e543e0521..055803e28 100644 --- a/docs/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md +++ b/docs/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md @@ -25,6 +25,8 @@ Legend: | x:Array | ✖ | ✔ | ✖ | x:Array isn't supported in UWP. | | x:Static | ✔ | ✔ | ⚡ | x:Static could be replaced with x:Bind | | x:Type | ✔ | ✔ | ✖ | | +| x:True | ✔ | ✖ | ✖ | | +| x:False | ✔ | ✖ | ✖ | | | Full Markup Extension | ✔ | ✔ | ✖ | UWP only implements a subset of the full markup extension support in WPF. This area needs to be expanded upon in the future. | | Compiled Bindings | ✔ | ✖ | ✖ | | diff --git a/docs/guides/data-binding/binding-from-code.md b/docs/guides/data-binding/binding-from-code.md index 2260fe9a6..6895169d8 100644 --- a/docs/guides/data-binding/binding-from-code.md +++ b/docs/guides/data-binding/binding-from-code.md @@ -149,10 +149,10 @@ For example if you want to listen to changes to your control's `Foo` property yo ```csharp static MyControl() { - FooProperty.Changed.AddClassHandler(x => x.FooChanged); + FooProperty.Changed.AddClassHandler(FooChanged); } -private void FooChanged(AvaloniaPropertyChangedEventArgs e) +private static void FooChanged(MyControl sender, AvaloniaPropertyChangedEventArgs e) { // The 'e' parameter describes what's changed. } diff --git a/docs/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md b/docs/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md index e54dcbf95..68aa6f092 100644 --- a/docs/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md +++ b/docs/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md @@ -23,6 +23,8 @@ public Task Start(Visual? from, Visual? to, bool forward, This example will shrink the old view and then open up the new view vertically. ```csharp +using Avalonia.VisualTree; + public class CustomTransition : IPageTransition { /// @@ -86,7 +88,7 @@ public class CustomTransition : IPageTransition }, Duration = Duration }; - tasks.Add(animation.RunAsync(from, null, cancellationToken)); + tasks.Add(animation.RunAsync(from, cancellationToken)); } if (to != null) @@ -120,7 +122,7 @@ public class CustomTransition : IPageTransition }, Duration = Duration }; - tasks.Add(animation.RunAsync(to, null, cancellationToken)); + tasks.Add(animation.RunAsync(to, cancellationToken)); } await Task.WhenAll(tasks); @@ -143,10 +145,10 @@ public class CustomTransition : IPageTransition /// /// Any one of the parameters may be null, but not both. /// - private static IVisual GetVisualParent(IVisual? from, IVisual? to) + private static Visual GetVisualParent(Visual? from, Visual? to) { - var p1 = (from ?? to)!.VisualParent; - var p2 = (to ?? from)!.VisualParent; + var p1 = (from ?? to)!.GetVisualParent(); + var p2 = (to ?? from)!.GetVisualParent(); if (p1 != null && p2 != null && p1 != p2) { diff --git a/docs/reference/controls/detailed-reference/treedatagrid/README.md b/docs/reference/controls/detailed-reference/treedatagrid/README.md index 087eae316..963ef100d 100644 --- a/docs/reference/controls/detailed-reference/treedatagrid/README.md +++ b/docs/reference/controls/detailed-reference/treedatagrid/README.md @@ -43,7 +43,7 @@ dotnet add package Avalonia.Controls.TreeDataGrid Or add package reference directly to the project (`.csproj`) file: ```xml - + ``` :::warning diff --git a/docs/reference/controls/grid.md b/docs/reference/controls/grid.md index 484e436a2..0531ee2f5 100644 --- a/docs/reference/controls/grid.md +++ b/docs/reference/controls/grid.md @@ -94,7 +94,7 @@ If a child control has its own dimensions these will be obeyed when it is drawn. You can mix any of the above in the same size definition sequence. For example: -`ColumnDefinitions="300, *, 2*"` +`ColumnDefinitions="200, *, 2*"` Using full expanded XAML, this is the same as: diff --git a/docs/reference/controls/menu.md b/docs/reference/controls/menu.md index d28a8fd97..345efd1d1 100644 --- a/docs/reference/controls/menu.md +++ b/docs/reference/controls/menu.md @@ -90,7 +90,7 @@ For guidance on how to bind to commands, see [here](../../basics/user-interface/ A menu icon can be displayed by placing an image or a path icon in the `` attached property. For example: ```markup -< + diff --git a/docs/tutorials/music-store-app/add-and-layout-controls.md b/docs/tutorials/music-store-app/add-and-layout-controls.md index 3b4acc5c4..196592ed4 100644 --- a/docs/tutorials/music-store-app/add-and-layout-controls.md +++ b/docs/tutorials/music-store-app/add-and-layout-controls.md @@ -128,7 +128,7 @@ Follow this procedure to include the icons file: ```markup - + ``` diff --git a/docs/tutorials/music-store-app/creating-a-modern-looking-window.md b/docs/tutorials/music-store-app/creating-a-modern-looking-window.md index 7325d35cc..9b0b0bf4f 100644 --- a/docs/tutorials/music-store-app/creating-a-modern-looking-window.md +++ b/docs/tutorials/music-store-app/creating-a-modern-looking-window.md @@ -12,10 +12,11 @@ Follow this procedure to style the main window in 'dark' mode: - Stop the app if it is still running. - Locate and open the file **App.axaml**. -- In the XAML, change the `Mode` attribute in the element`` from light to dark +- In the XAML, change the `RequestedThemeVariant` attribute in the `` element from "Default" to "Dark" ```markup - + ``` - Now locate and open the **MainWindow.axaml** file in the **/Views** folder. diff --git a/docs/tutorials/music-store-app/return-from-dialog.md b/docs/tutorials/music-store-app/return-from-dialog.md index 09c0610c9..3e37cba0a 100644 --- a/docs/tutorials/music-store-app/return-from-dialog.md +++ b/docs/tutorials/music-store-app/return-from-dialog.md @@ -40,7 +40,7 @@ Notice you are using `ReactiveCommand` here. This is provided by the _ReactiveUI Your next step is bind the **Buy Album** button to the reactive command in the music store view model, follow this procedure: -- Locate and open the **MusicStoreView .cs** file. +- Locate and open the **MusicStoreView .axaml** file. - Add the data binding `Command="{Binding BuyMusicCommand}"` to the button element. ## Close the Dialog diff --git a/docs/tutorials/music-store-app/searching-for-albums.md b/docs/tutorials/music-store-app/searching-for-albums.md index 32a5b3772..25f981c5c 100644 --- a/docs/tutorials/music-store-app/searching-for-albums.md +++ b/docs/tutorials/music-store-app/searching-for-albums.md @@ -175,9 +175,13 @@ Follow this procedure to add the album name and artist name to the tile: - Locate and open the **AlbumView.asaml** file. - Add the two text block controls with their data bindings, as shown: +- To have compiled binding working, you need to indicate the datatype used in the view : AlbumViewModel. ```xml + diff --git a/docs/tutorials/music-store-app/summary.md b/docs/tutorials/music-store-app/summary.md index 237c99fba..6951424f2 100644 --- a/docs/tutorials/music-store-app/summary.md +++ b/docs/tutorials/music-store-app/summary.md @@ -12,7 +12,7 @@ This tutorial has used an application solution architecture that uses the MVVM p Application state is kept in the 'top level' view model, and can be persisted to disk. The main window and search dialog are composed from in _Avalonia UI_ window controls, built-in controls and user controls. -This tutorial application targets a windowing platform such as _Apple iOS_ or _Windows_. +This tutorial application targets a windowing platform such as _Apple Mac OS_ or _Windows_. :::info To learn more about targeting applications for iOS (Apple) platforms, see [here](../../guides/platforms/ios). diff --git a/docs/tutorials/todo-list-app/locating-views.md b/docs/tutorials/todo-list-app/locating-views.md index f092a0909..f8d7979b9 100644 --- a/docs/tutorials/todo-list-app/locating-views.md +++ b/docs/tutorials/todo-list-app/locating-views.md @@ -72,7 +72,7 @@ In your to do list app, the main window has had its content set to an object tha For more information about the concepts behind data templates, see [here](../../concepts/templates/). ::: -As no other data templates match, the search will eventually reach the `ViewLocator` in the application data templates element. This will run its checks and if they pass, return an instance of the corresponding view. It your app this will be the to do list view. +As no other data templates match, the search will eventually reach the `ViewLocator` in the application data templates element. This will run its checks and if they pass, return an instance of the corresponding view. In your app this will be the to do list view.
@@ -85,6 +85,6 @@ In this way the content of the main window is set to the correct view, based on Note that the view locator class is included in the project source rather than being part of the _Avalonia UI_ framework itself. This is because using an implementation of the 'convention over configuration' paradigm is an architectural choice for the application developer. -If you do not want to use the view locator (in a diffent app); then remove it from the project and the **App.axaml** file. +If you do not want to use the view locator (in a different app); then remove it from the project and the **App.axaml** file. On the next page you will learn how to add revealed functionality and actions to the **OK** and **Cancel** buttons. diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/data/data-binding/compiled-bindings.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/data/data-binding/compiled-bindings.md index cc989a26b..c28e2f7b4 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/data/data-binding/compiled-bindings.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/data/data-binding/compiled-bindings.md @@ -106,7 +106,7 @@ description: CONCEPTS 在某些情况下,绑定表达式的目标类型无法自动计算。在这种情况下,您必须在绑定表达式中提供一个明确的类型转换。 ```markup - + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/choosing-a-custom-contro-type.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/choosing-a-custom-contro-type.md index 8299290d7..0f50022c9 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/choosing-a-custom-contro-type.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/choosing-a-custom-contro-type.md @@ -50,10 +50,10 @@ Avalonia提供了多种方法来创建自定义控件以满足应用程序的特 自绘控件通常用于表示大部分非交互式的图形元素,不需要进行主题化。 ::: -要创建自绘控件,您需要重写控件的`OnRender`方法,并使用低级别的绘制API(例如`DrawingContext`)来定义控件的外观。这种方法可以对控件的每个像素进行精细控制,实现高度个性化的可视化。 +要创建自绘控件,您需要重写控件的`Render`方法,并使用低级别的绘制API(例如`DrawingContext`)来定义控件的外观。这种方法可以对控件的每个像素进行精细控制,实现高度个性化的可视化。 创建自绘控件的步骤如下: 1. **定义控件类**:创建一个新的类,该类派生自`Control`。这个类将定义控件的行为和渲染逻辑。 -2. **重写OnRender方法**:在控件类中重写`OnRender`方法,并使用`DrawingContext`来绘制控件的内容。 +2. **重写Render方法**:在控件类中重写`Render`方法,并使用`DrawingContext`来绘制控件的内容。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/defining-events.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/defining-events.md index b9f3db432..1e8a5de98 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/defining-events.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/defining-events.md @@ -43,4 +43,4 @@ public class MyCustomSlider : Control ## 进一步阅读 -如需更多信息,请参阅[路由事件深入](../../../../concepts/input/routed-events.md) \ No newline at end of file +如需更多信息,请参阅[路由事件深入](../../../../concepts/input/routed-events.md) diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/index.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/index.md index 0d330f926..1a0c0d885 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/index.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/controls/creating-controls/index.md @@ -2,3 +2,12 @@ id: index title: 创建控件 --- + +# 创建控件 + +```mdx-code-block +import {DocsCardList} from '../../../../../../../../src/components/DocsCard'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/file-dialogs.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/file-dialogs.md index 167e300e3..738fc3075 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/file-dialogs.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/file-dialogs.md @@ -57,7 +57,7 @@ public class MyView : UserControl var topLevel = TopLevel.GetTopLevel(this); // 启动异步操作以打开对话框。 - var file = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerSaveOptions + var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { Title = "Save Text File" }); diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/styling/themes/fluent.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/styling/themes/fluent.md index c0b6054e6..9f5b2984d 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/styling/themes/fluent.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/basics/user-interface/styling/themes/fluent.md @@ -68,9 +68,9 @@ Fluent 主题有两套预定义的密度变体。 // highlight-start - + - + // highlight-end @@ -80,10 +80,10 @@ Fluent 主题有两套预定义的密度变体。 虽然 `ColorPaletteResources` 具有许多可以单独为每个变体重写的颜色属性,但是只能重新定义所需的最小集合,其他所有内容保持默认值。如上面的示例中,仅覆盖了几种颜色。 -如果未重写 AccentColor,Avalonia 将使用平台 OS 的强调颜色(如果可用)。 -另外,AccentColor 支持绑定,并且可以在运行时更改,但其他属性不支持,因为它们在应用程序启动后被读取一次,并且为了性能原因而静态使用。 +如果未重写 Accent,Avalonia 将使用平台 OS 的强调颜色(如果可用)。 +另外,Accent 支持绑定,并且可以在运行时更改,但其他属性不支持,因为它们在应用程序启动后被读取一次,并且为了性能原因而静态使用。 -可以在代码中构建调色板,但是同样的规则适用——只有 AccentColor 可以在运行时更新,并且调色板应该在样式或主题加载后设置为不可变。 +可以在代码中构建调色板,但是同样的规则适用——只有 Accent 可以在运行时更新,并且调色板应该在样式或主题加载后设置为不可变。 :::note FluentTheme 仅支持暗色和浅色主题变体,不支持为自定义变体定义调色板。 @@ -92,7 +92,8 @@ FluentTheme 仅支持暗色和浅色主题变体,不支持为自定义变体 ## 使用在线编辑器创建自定义颜色调色板 Microsoft Fluent Theme Editor 已移植到 Avalonia,现在也可以与我们的 FluentTheme 一起使用。 -它可在 https://theme.xaml.live/ 页面上使用,并支持以下功能: +它可在 页面上使用,并支持以下功能: + 1. 编辑浅色和暗色变体的调色板颜色。 2. 预览当前调色板。 3. 将当前调色板导出为可以复制粘贴到 `App.axaml` 文件中的 XAML 代码。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/binding-to-sorted-filtered-list.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/binding-to-sorted-filtered-list.md index fd76f82a2..a29ea57e5 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/binding-to-sorted-filtered-list.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/binding-to-sorted-filtered-list.md @@ -47,7 +47,7 @@ public MainWindowViewModel(){ - + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/observable-collections.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/observable-collections.md deleted file mode 100644 index 7fdd56e48..000000000 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/observable-collections.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -description: CONCEPTS - ReactiveUI ---- - -# Observable Collections - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/reactive-command.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/reactive-command.md index b5628c6b6..5572717f2 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/reactive-command.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/reactive-command.md @@ -1,6 +1,7 @@ --- description: CONCEPTS - ReactiveUI --- + # 响应式命令 在本页面中,您将学习如何使用_ReactiveUI_的`ReactiveCommand`和在代码中创建的`ObservableObject`来实现UI的功能逐步展示原则。 @@ -17,9 +18,9 @@ description: CONCEPTS - ReactiveUI ```xml - User Name - - + User Name + + ``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/routing.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/routing.md index c3968139c..86a724b7f 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/routing.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/reactiveui/routing.md @@ -85,7 +85,7 @@ namespace RoutingExample public ReactiveCommand GoNext { get; } // 导航用户返回的命令。 - public ReactiveCommand GoBack => Router.NavigateBack; + public ReactiveCommand GoBack => Router.NavigateBack; public MainWindowViewModel() { diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/file-picker-options.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/file-picker-options.md index 0028d618d..78daf4d20 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/file-picker-options.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/file-picker-options.md @@ -19,6 +19,9 @@ title: 文件选择器选项 File Picker Options :::note 这是对系统的建议,如果应用程序无法访问文件夹或文件夹不存在,可以忽略此参数。 ::: +:::note +在 Linux 上,一些 DBus 文件选择器不支持启动位置。对于使用 GTK Free Desktop,请在 `X11PlatformOptions` 中禁用 `UseDBusFilePicker`。 +::: ## FilePickerOpenOptions @@ -70,6 +73,7 @@ title: 文件选择器选项 File Picker Options # 定义自定义文件类型 Avalonia 有一组内置的文件类型: + - FilePickerFileTypes.All - 所有文件 - FilePickerFileTypes.TextPlain - 文本文件 (txt) - FilePickerFileTypes.ImageAll - 所有图片 @@ -81,6 +85,7 @@ Avalonia 有一组内置的文件类型: 例如,内置的 ImageAll 类型定义如下 ```cs + public static FilePickerFileType ImageAll { get; } = new("All Images") { Patterns = new[] { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp" }, diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/index.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/index.md index ea2662a09..4552e806b 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/index.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/index.md @@ -85,7 +85,7 @@ Task TryGetFileFromPathAsync(Uri filePath); ``` 该方法返回文件,如果文件不存在,则返回 null。filePath 参数预期是带有 "file" scheme 的绝对路径,但在 Android 上可以是带有 "content" scheme 的 URI。 -### TryGetFolderFromPathAsync +### TryGetFolderFromPathAsync 尝试根据文件夹路径从文件系统中读取文件夹。 ```cs @@ -101,6 +101,27 @@ Task TryGetWellKnownFolderAsync(WellKnownFolder wellKnownFolder ``` 该方法返回文件夹,如果文件夹不存在,则返回 null。 +## 扩展方法 + +### TryGetFileFromPathAsync +尝试根据文件路径从文件系统中读取文件。 + +```cs +Task TryGetFileFromPathAsync(this IStorageProvider provider, string filePath); +``` +该方法将返回一个文件,如果文件不存在,则返回null。 +此方法接受本地文件路径字符串作为参数,不带任何scheme。 +仅在操作系统上受支持,使用物理文件路径,主要仅适用于桌面。 + +### TryGetFolderFromPathAsync +尝试根据文件夹路径从文件系统中读取文件夹。 + +```cs +Task TryGetFolderFromPathAsync(this IStorageProvider provider, string folderPath); +``` +该方法将返回一个文件夹,如果文件夹不存在,则返回null。 +此方法接受本地文件夹路径字符串作为参数,不带任何scheme。 +仅在操作系统上受支持,使用物理文件路径,主要仅适用于桌面。 ## 平台兼容性: diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/storage-item.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/storage-item.md index 0e7364bfc..e0524790b 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/storage-item.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/storage-provider/storage-item.md @@ -82,4 +82,15 @@ Android 后端可能返回带有 "content:" 方案的文件路径。 ### CreateFolderAsync -在当前存储文件夹的子级中创建一个具有指定名称的文件夹。 \ No newline at end of file +在当前存储文件夹的子级中创建一个具有指定名称的文件夹。 + +## Extension methods + +### TryGetLocalPath + +Gets the local file system path of the item as a string. +Android platform usually uses "content:" virtual file paths and Browser platform has isolated access without full paths, so on these platforms this method will return null. + +:::note +If you want to save file path to reuse it later (in combination with TryGetFileFromPathAsync), please consider using [Bookmarks](./bookmarks) instead as they are designed to work in sandboxed environment, where user app might not have direct access to the physical file system. +::: \ No newline at end of file diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/data-templates.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/data-templates.md index 25fe2faf1..29cc113ec 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/data-templates.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/data-templates.md @@ -61,14 +61,14 @@ namespace MySample } ``` -并且将XML命名空间`local`定义为`Example`命名空间(来自上面的代码),您可以在窗口的内容区域中定义一个学生对象,如下所示: +并且将XML命名空间`local`定义为`MySample`命名空间(来自上面的代码),您可以在窗口的内容区域中定义一个学生对象,如下所示: ```markup - + ``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/implement-idatatemplate.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/implement-idatatemplate.md index 8351c778e..f6f722f81 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/implement-idatatemplate.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/implement-idatatemplate.md @@ -9,7 +9,7 @@ description: CONCEPTS - Data Templates 要使用`IDataTemplate`接口,您必须在数据模板类中实现以下两个成员: * `public bool Match(object data) { ... }` - 实现此成员以检查提供的绑定数据是否与您的`IDataTemplate`匹配。如果绑定的数据类型匹配,则返回true,否则返回false。 -* `public IControl Build(object param) { ... }` - 实现此成员以构建并返回用于呈现数据的控件。 +* `public Control Build(object param) { ... }` - 实现此成员以构建并返回用于呈现数据的控件。 ## 示例 @@ -20,7 +20,7 @@ using Avalonia.Controls.Templates; ... public class MyDataTemplate : IDataTemplate { - public IControl Build(object param) + public Control Build(object param) { return new TextBlock() { Text = (string)param }; } diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/reusing-data-templates.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/reusing-data-templates.md index c64795411..4fdb88046 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/reusing-data-templates.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/templates/reusing-data-templates.md @@ -33,9 +33,10 @@ namespace MySample + x:Class="MySample.App" + RequestedThemeVariant="Light"> - + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/toplevel.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/toplevel.md index 63a571e68..63825a84e 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/toplevel.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/toplevel.md @@ -1,6 +1,7 @@ --- description: CONCEPTS --- + # 顶级控件 顶级控件充当视觉根,并且是所有顶级控件(例如`Window`)的基类。它处理布局、样式和渲染的调度,以及跟踪客户端大小。大多数服务都通过顶级控件访问。 @@ -10,12 +11,14 @@ description: CONCEPTS 以下是两种常见的访问顶级控件实例的方法。 ### 使用TopLevel.GetTopLevel + 您可以使用TopLevel类的静态`GetTopLevel`方法获取包含当前控件的顶级控件。 ```cs var topLevel = TopLevel.GetTopLevel(control); // 在此处,您可以从topLevel实例引用各种服务,如Clipboard或StorageProvider。 ``` + 如果您在用户控件或较低级别的组件中工作并且需要访问顶级控件的服务,此方法可能会有所帮助。 :::note @@ -35,6 +38,7 @@ var topLevel = window; ## 常见属性 ### ActualTransparencyLevel + 获取平台能够提供的实际`WindowTransparencyLevel`。 ```cs @@ -42,6 +46,7 @@ WindowTransparencyLevel ActualTransparencyLevel { get; } ``` ### ClientSize + 获取窗口的客户端大小。 ```cs @@ -49,6 +54,7 @@ Size ClientSize { get; } ``` ### Clipboard + 获取平台的[Clipboard](./services/clipboard)实现。 ```cs @@ -56,6 +62,7 @@ IClipboard? Clipboard { get; } ``` ### FocusManager + 获取根的[焦点管理器](./services/focus-manager)。 ```cs @@ -63,12 +70,15 @@ IFocusManager? FocusManager { get; } ``` ### FrameSize + 获取顶级控件的总大小,包括系统框架(如果有)。 ```cs Size? FrameSize { get; } ``` + ### InsetsManager + 获取平台的[InsetsManager](./services/insets-manager)实现。 ```cs @@ -76,6 +86,7 @@ IInsetsManager? InsetsManager { get; } ``` ### PlatformSettings + 表示访问顶级[平台特定设置](./services/platform-settings)的契约。 ```cs @@ -83,6 +94,7 @@ IPlatformSettings? PlatformSettings { get; } ``` ### RendererDiagnostics + 获取一个值,指示渲染器是否应绘制特定的诊断信息。 ```cs @@ -90,6 +102,7 @@ RendererDiagnostics RendererDiagnostics { get; } ``` ### RenderScaling + 获取用于渲染的缩放因子。 ```cs @@ -97,6 +110,7 @@ double RenderScaling { get; } ``` ### RequestedThemeVariant + 获取或设置控件(及其子元素)用于资源确定的UI主题变体。您使用ThemeVariant指定的UI主题可以覆盖应用程序级别的ThemeVariant。 ```cs @@ -104,6 +118,7 @@ ThemeVariant? RequestedThemeVariant { get; set; } ``` ### StorageProvider + 用于文件选择器和书签的[文件系统存储](./services/storage-provider/)服务。 ```cs @@ -111,6 +126,7 @@ IStorageProvider StorageProvider { get; } ``` ### TransparencyBackgroundFallback + 获取或设置当不支持透明度时,透明度将与之混合的`IBrush`。默认情况下,这是一个纯白色的画刷。 ```cs @@ -118,6 +134,7 @@ IBrush TransparencyBackgroundFallback { get; set; } ``` ### TransparencyLevelHint + 获取或设置TopLevel在可能的情况下应使用的`WindowTransparencyLevel`。接受多个值,按照回退顺序应用。例如,使用"Mica,Blur",Mica仅在支持它的平台上应用,其余平台上使用Blur。默认值是一个空数组或"None"。 ```cs @@ -127,6 +144,7 @@ IReadOnlyList TransparencyLevelHint { get; set; } ## 常见事件 ### BackRequested + 在按下物理返回按钮或请求后退导航时发生。 ```cs @@ -134,6 +152,7 @@ event EventHandler BackRequested { add; remove; } ``` ### Closed + 窗口关闭时触发。 ```cs @@ -141,6 +160,7 @@ event EventHandler Closed; ``` ### Opened + 窗口打开时触发。 ```cs @@ -148,6 +168,7 @@ event EventHandler Opened; ``` ### ScalingChanged + 当TopLevel的缩放发生变化时发生。 ```cs @@ -157,9 +178,12 @@ event EventHandler ScalingChanged; ## 常见方法 ### GetTopLevel + 获取给定`Visual`所托管的`TopLevel`。 + #### 参数 -`control` + +`control` 要查询其TopLevel的可视对象 ```cs @@ -167,6 +191,7 @@ static TopLevel? GetTopLevel(Visual? visual) ``` ### RequestAnimationFrame + 将回调排队,以在下一个动画刻度上调用 ```cs @@ -174,6 +199,7 @@ void RequestAnimationFrame(Action action) ``` ### RequestPlatformInhibition + 请求抑制`PlatformInhibitionType`。行为将保持抑制,直到返回值被释放。可用的`PlatformInhibitionType`集取决于平台。如果在不支持此类型的平台上抑制行为,则请求将不起作用。 ```cs @@ -181,13 +207,13 @@ async Task RequestPlatformInhibition(PlatformInhibitionType type, s ``` ### TryGetPlatformHandle + 尝试获取派生自TopLevel的控件的平台句柄。 ```cs IPlatformHandle? TryGetPlatformHandle() ``` - ## 更多信息 -在_GitHub_上查看源代码 [`TopLevel.cs`](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/TopLevel.cs)" \ No newline at end of file +在_GitHub_上查看源代码 [`TopLevel.cs`](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/TopLevel.cs)" diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/view-locator.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/view-locator.md index 1b331c62d..0610a3837 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/view-locator.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/view-locator.md @@ -4,15 +4,16 @@ description: CONCEPTS # 视图定位器 + 虽然视图定位器的使用是默认模板的一部分,但需要注意它并不是强制要求的。它是一个可选工具,旨在帮助您使用模型-视图-视图模型(MVVM)设计模式来构建Avalonia应用程序。 视图定位器是Avalonia中用于解析与特定视图模型对应的视图(用户界面)的机制。这是MVVM(模型-视图-视图模型)模式的核心部分,该模式将图形用户界面的开发与业务逻辑或后端逻辑的开发分离。 ## 工作原理 -视图定位器使用命名约定将视图模型类型映射到视图类型。默认情况下,它会从视图模型类型名称的末尾删除“ViewModel”,然后在相同的命名空间中查找具有相同名称的类型,但在相应的“Views”命名空间中。 +视图定位器使用命名约定将视图模型类型映射到视图类型。默认情况下,它会将完全限定的视图模型类型名称中每次出现的字符串“ViewModel”替换为“View”。 -例如,给定一个名为`MyApplication.ViewModels.ExampleViewModel`的视图模型,视图定位器将查找一个名为`MyApplication.Views.Example`的视图。 +例如,给定一个名为`MyApplication.ViewModels.ExampleViewModel`的视图模型,视图定位器将查找一个名为`MyApplication.Views.ExampleView`的视图。 视图定位器通常与`DataContext`属性一起使用,该属性用于将视图与其视图模型关联起来。 @@ -23,7 +24,7 @@ public class ViewLocator : IDataTemplate { public bool SupportsRecycling => false; - public IControl Build(object data) + public Control Build(object data) { var name = data.GetType().FullName.Replace("ViewModel", "View"); var type = Type.GetType(name); @@ -45,19 +46,29 @@ public class ViewLocator : IDataTemplate } ``` -在此示例中,视图定位器被实现为`IDataTemplate`。`Build`方法创建视图的视图模型,`Match`方法检查数据对象是否是此定位器知道如何处理的视图模型。 +在此示例中,视图定位器被实现为`IDataTemplate`。`Build`方法创建视图的视图模型,`Match`方法检查数据对象是否是此定位器知道如何处理的视图模型。If you do not have a `ViewModelBase` class, at a minimum your ViewModel must implement `INotifyPropertyChanged`, and the comparison in `Match` should be changed accordingly. ## 自定义视图定位器 您可以自定义视图定位器以使用不同的约定。例如,您可能希望在不同的程序集中查找视图,或使用不同的命名约定。为此,您可以创建一个实现`IDataTemplate`接口的类来实现自己的视图定位器,并用自己的视图定位器替换默认的视图定位器。 - - - - - - - - - - +## Using the View Locator + +By default, the View Locator is referenced in App.axaml as a DataTemplate, in the content of the `Application.DataTemplates` XAML tag. Ensure that its appropriate 'using' statement is in the `xmlns:local` property of the Application root tag. + +```xaml + + + + + + + + + + +``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/index.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/index.md index b65e93f74..be49b7bb2 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/index.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/index.md @@ -1,4 +1,4 @@ -# Get Started +# 开始使用 ```mdx-code-block import {DocsCardList} from '../../../../../src/components/DocsCard'; diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/test-drive/code-with-controls.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/test-drive/code-with-controls.md index ca09adbd7..1333b4c90 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/test-drive/code-with-controls.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/test-drive/code-with-controls.md @@ -87,7 +87,7 @@ else - 您现在已经使用事件处理程序在运行时获取和设置控件属性。您现在可以尝试一些练习: - 停止显示网格线(简单)。 -- 通过设置`ReadOnly`属性,阻止用户更改华氏度输入的文本(简单)。 +- 通过设置`IsReadOnly`属性,阻止用户更改华氏度输入的文本(简单)。 - 当用户输入摄氏度时,实时计算转换结果(中等)。 :::info diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md index 7b3c9cd20..aa716c4dc 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/get-started/wpf/comparison-of-avalonia-with-wpf-and-uwp.md @@ -25,6 +25,8 @@ description: REFERENCE - WPF Conversion | x:Array | ✖ | ✔ | ✖ | x:Array isn't supported in UWP. | | x:Static | ✔ | ✔ | ⚡ | x:Static could be replaced with x:Bind | | x:Type | ✔ | ✔ | ✖ | | +| x:True | ✔ | ✖ | ✖ | | +| x:False | ✔ | ✖ | ✖ | | | Full Markup Extension | ✔ | ✔ | ✖ | UWP only implements a subset of the full markup extension support in WPF. This area needs to be expanded upon in the future. | | Compiled Bindings | ✔ | ✖ | ✖ | | diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-a-custom-flyout.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-a-custom-flyout.md index 1acd0ae4b..644a8a196 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-a-custom-flyout.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-a-custom-flyout.md @@ -1,6 +1,6 @@ --- id: how-to-create-a-custom-flyout -title: 如何创建自定义面板 +title: 如何创建自定义弹出窗口 --- # 如何创建自定义弹出窗口 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-attached-properties.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-attached-properties.md index 890c56b22..3a3f28039 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-attached-properties.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/how-to-create-attached-properties.md @@ -130,7 +130,7 @@ public class DoubleTappedBehav : AvaloniaObject xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="clr-namespace:MyApp.Behaviors" x:Class="MyApp.Views.TestView"> - (EditProfileExecuted); + EditCommand = ReactiveCommand.CreateFromTask(EditCommandExecuted); } private async Task EditCommandExecuted(object p) diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/types-of-control.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/types-of-control.md index 9475beeeb..9a5cda3b8 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/types-of-control.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/custom-controls/types-of-control.md @@ -24,4 +24,4 @@ title: 控件类型 :::info 在WPF/UWP中,您将从`FrameworkElement`类继承以创建新的基本控件,但在Avalonia中,您应该从`Control`继承。 -::: \ No newline at end of file +::: diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/data-binding/binding-classes.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/data-binding/binding-classes.md index 962c88f76..100ed9d1d 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/data-binding/binding-classes.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/data-binding/binding-classes.md @@ -13,7 +13,7 @@ title: 如何绑定样式类 然后,您可以使用特殊的类语法和数据绑定有条件地将类应用于控件。语法如下: ``` - + ``` ## 示例 @@ -22,7 +22,7 @@ title: 如何绑定样式类 ```xml title='XAML' - + - + x is DataAnnotationsValidationPlugin); - + // Get an array of plugins to remove + var dataValidationPluginsToRemove = + BindingPlugins.DataValidators.OfType().ToArray(); + + // remove each entry found + foreach (var plugin in dataValidationPluginsToRemove) + { + BindingPlugins.DataValidators.Remove(plugin); + } + // Continue with normal startup if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/development-guides/how-to-implement-multi-page-apps.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/development-guides/how-to-implement-multi-page-apps.md index 656667137..ef1952005 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/development-guides/how-to-implement-multi-page-apps.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/development-guides/how-to-implement-multi-page-apps.md @@ -17,7 +17,7 @@ that is added by the Avalonia MVVM solution template. ```csharp public class ViewLocator : IDataTemplate { - public IControl? Build(object? data) + public Control? Build(object? data) { if (data==null) return null; var name = data.GetType().FullName!.Replace("ViewModel", "View"); diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md index 58cb8a392..5fe088fad 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/graphics-and-animation/how-to-create-a-custom-page-transition.md @@ -23,6 +23,8 @@ public Task Start(Visual? from, Visual? to, bool forward, 此示例将缩小旧视图,然后垂直打开新视图。 ```csharp +using Avalonia.VisualTree; + public class CustomTransition : IPageTransition { /// @@ -86,7 +88,7 @@ public class CustomTransition : IPageTransition }, Duration = Duration }; - tasks.Add(animation.RunAsync(from, null, cancellationToken)); + tasks.Add(animation.RunAsync(from, cancellationToken)); } if (to != null) @@ -120,7 +122,7 @@ public class CustomTransition : IPageTransition }, Duration = Duration }; - tasks.Add(animation.RunAsync(to, null, cancellationToken)); + tasks.Add(animation.RunAsync(to, cancellationToken)); } await Task.WhenAll(tasks); @@ -143,10 +145,10 @@ public class CustomTransition : IPageTransition /// /// 任何一个参数可能为null,但不能都为null。 /// - private static IVisual GetVisualParent(IVisual? from, IVisual? to) + private static Visual GetVisualParent(Visual? from, Visual? to) { - var p1 = (from ?? to)!.VisualParent; - var p2 = (to ?? from)!.VisualParent; + var p1 = (from ?? to)!.GetVisualParent(); + var p2 = (to ?? from)!.GetVisualParent(); if (p1 != null && p2 != null && p1 != p2) { diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/built-in-data-binding-converters.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/built-in-data-binding-converters.md index 7d0ff6bb6..c0ff12273 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/built-in-data-binding-converters.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/built-in-data-binding-converters.md @@ -33,7 +33,7 @@ _Avalonia UI_ 包含许多用于常见场景的内置数据绑定转换器: ```markup - + No results found ``` @@ -44,7 +44,7 @@ _Avalonia UI_ 包含许多用于常见场景的内置数据绑定转换器: ```markup - + ``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/README.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/README.md new file mode 100644 index 000000000..15cd38b53 --- /dev/null +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/README.md @@ -0,0 +1,60 @@ +--- +description: REFERENCE - Built-in Controls +--- + +# 按钮控件 + +Avalonia UI 提供了各种类型的按钮控件: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
控件描述
+ 按钮(Button) + 基本的按钮控件——可以显示文本、图标或二者兼有。具有标准的“点击”行为。
+ 重复按钮(Repeat Button) + 按住并持续按下时会重复触发其点击事件的按钮。
+ 单选按钮(Radio Button) + 具有选中状态的按钮。可以放置在一组中,使得选择一个按钮会取消选中组中的所有其他按钮。
+ 切换按钮(Toggle Button) + 具有选中状态和未选中状态的按钮。连续点击会在这两个状态之间“切换”。可以使用“checked”伪类为选中状态和未选中状态分配不同的样式。
+ 按钮微调器(Button Spinner) + 带有两个微调按钮和一个内容区的控件。
+ 分裂按钮(Split Button) + 此按钮具有主要部分和次要部分,可以分别进行独立的点击。主要部分的行为类似于标准按钮,而次要部分会打开一个包含附加操作的弹出菜单。
+ 切换分裂按钮(Toggle Split Button) + 此按钮具有主要部分和次要部分,可以分别进行独立的点击。主要部分的行为类似于切换按钮,而次要部分会打开一个包含附加操作的弹出菜单。
diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/buttonspinner.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/buttonspinner.md index 5ff8666cb..2fc0c69fa 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/buttonspinner.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/buttonspinner.md @@ -2,15 +2,15 @@ description: REFERENCE - Built-in Controls --- -# 按钮旋转器 +# 按钮微调器 -按钮旋转器是一个包含向上和向下旋转按钮的控件。该按钮的内容是灵活的,但您需要编写相当多的行为代码。 +按钮微调器是一个包含向上和向下微调按钮的控件。该按钮的内容是灵活的,但您需要编写相当多的行为代码。 ## 有用的属性 您可能经常使用以下属性: -
属性描述
ButtonSpinnerLocation旋转按钮的位置:左侧或右侧。
ValidSpinDirection用于限制旋转方向:增加、减少或无。
+
属性描述
ButtonSpinnerLocation微调按钮的位置:左侧或右侧。
ValidSpinDirection用于限制微调方向:增加、减少或无。
## 示例 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/splitbutton.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/splitbutton.md index dc806dc6d..b3486c5a4 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/splitbutton.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/splitbutton.md @@ -1,4 +1,4 @@ -# 分隔按钮 +# 分裂按钮 `SplitButton` 作为 [`Button`](./button) 的扩展,具有可以单独按下的主要和次要部分。主要部分的行为与普通的 `Button` 相同,而次要部分会打开一个 [`Flyout`](docs/controls/flyouts),其中包含额外的操作。 @@ -81,7 +81,7 @@ _SplitButton(Flyout已打开)_ Command="{Binding ChangeColorCommand}"> - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglebutton.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglebutton.md index 7c141f05e..9d9ef0d18 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglebutton.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglebutton.md @@ -2,19 +2,19 @@ description: REFERENCE - Built-in Controls --- -# Toggle Button +# 切换按钮 -The toggle button can present a Boolean value by using styles and a pseudo class that is either present (true) or absent (false). +切换按钮可以通过使用样式和伪类来呈现布尔值,这些样式和伪类可以存在(true)或不存在(false)。 :::info -To review the concepts behind a pseudo class, see [here](../../../concepts/pseudo-classes.md). +要查看伪类背后的概念,请参阅[这里](../../../concepts/pseudo-classes.md)。 ::: -This allows a wide range of possible graphical presentations for the control in each of the pseudo class states. +这允许在每个伪类状态中对控件进行广泛的可能的图形呈现。 -## Example +## 示例 -This example shows a toggle button containing a speaker icon, or a muted speaker icon, depending on whether the button has the checked pseudo class or not. +此示例显示了一个切换按钮,其中包含一个扬声器图标或静音扬声器图标,具体取决于按钮是否具有已检查的伪类。 @@ -77,25 +77,24 @@ This example shows a toggle button containing a speaker icon, or a muted speaker ``` - -The content zone of the toggle button contains two path icon elements, only one of which is visible at a time. The path icons get their graphics from an assets file which is referenced as an included style set in the `App.xaml` file. The icon geometries are from the _Avalonia UI_ Fluent icons resource. +切换按钮的内容区域包含两个路径图标元素,每次只有一个图标可见。路径图标从一个资产文件中获取其图形,该文件被引用为`App.xaml`文件中包含的样式集。图标几何图形来自_Avalonia UI_的Fluent图标资源。 :::info -To see the full list of Fluent icons available with _Avalonia UI_, see [https://avaloniaui.github.io/icons.html](https://avaloniaui.github.io/icons.html) +要查看_Avalonia UI_中提供的完整Fluent图标列表,请访问 [https://avaloniaui.github.io/icons.html](https://avaloniaui.github.io/icons.html) ::: -The visibility of the path icons is set by the window styles, and these use the `:checked` pseudo class to determine when the toggle button is in its checked state. So, when the toggle button is checked, then the `audio-on` path icon is visible, and the `audio-mute` path icon is hidden. And conversely, when the toggle button is not checked, then the `audio-mute` path icon is visible, and the `audio-on` path icon is hidden. +路径图标的可见性由窗口样式设置,这些样式使用`:checked`伪类来确定切换按钮何时处于已选中状态。因此,当切换按钮被选中时,`audio-on`路径图标可见,而`audio-mute`路径图标隐藏。反之,当切换按钮未选中时,`audio-mute`路径图标可见,而`audio-on`路径图标隐藏。 -## More Information +## 更多信息 :::info -For the complete API documentation about this control, see [here](https://reference.avaloniaui.net/api/Avalonia.Controls.Primitives/ToggleButton/). +有关此控件的完整API文档,请参阅[这里](https://reference.avaloniaui.net/api/Avalonia.Controls.Primitives/ToggleButton/). ::: :::info -View the source code on _GitHub_ [`ToggleButton.cs`](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Primitives/ToggleButton.cs) +在_GitHub_上查看源代码[`ToggleButton.cs`](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Primitives/ToggleButton.cs) ::: diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglesplitbutton.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglesplitbutton.md index b75e0b720..152ddb932 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglesplitbutton.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/buttons/togglesplitbutton.md @@ -1,49 +1,49 @@ -# Toggle Split Button +# 切换分裂按钮 -The `ToggleSplitButton` functions as a [`ToggleButton`](togglebutton) with primary and secondary parts that can each be pressed separately. The primary part behaves like a normal `ToggleButton` and the secondary part opens a [`Flyout`](../flyouts) with additional actions. +`ToggleSplitButton` 作为一个带有主要和次要部分的 [`ToggleButton`](togglebutton),每个部分都可以单独按下。主要部分的行为类似于普通的 `ToggleButton`,而次要部分会打开一个带有附加操作的 [`Flyout`](../flyouts)。 :::info -The `ToggleSplitButton` has only two states: checked and unchecked. Indeterminate is not supported like it is with a standard `ToggleButton`. This was done intentionally to match WinUI and restricts the control’s usage. The `ToggleSplitButton` should only be used to turn features on/off. Anything other than that is currently considered poor practice from a usability standpoint. +`ToggleSplitButton` 仅有两个状态:选中和未选中。与标准的 `ToggleButton` 一样,不支持不确定状态。这是有意为之,这是为了匹配 WinUI 并限制控件的使用。`ToggleSplitButton` 应仅用于打开/关闭功能。除此之外的任何用法目前都被认为是不良实践。 ::: -## Is this the right control? +## 这是正确的控件吗? -A `ToggleSplitButton` is a fairly specialized control and its usage should be restricted to where it makes clear sense from a user-standpoint. It is intended to turn a feature on/off while allowing some additional configurations to be specified rather than the default. +`ToggleSplitButton` 是一个相当专门化的控件,其使用应该限制在从用户角度清晰合理的地方。它的用途是在打开/关闭功能的同时允许指定一些附加配置,而不是使用默认配置。 -Like a [`SplitButton`](../buttons/splitbutton), the most common action should be the default and what is shown in the primary part. However, unlike the `SplitButton`, pressing the primary part will turn this feature on or off instead of simply invoking an action. Additional configurations for the feature should be added to the `Flyout` which is shown when the secondary (drop down) part is pressed. +与 [`SplitButton`](../buttons/splitbutton) 一样,最常见的操作应该是默认操作,显示在主要部分中。然而,与 `SplitButton` 不同,按下主要部分会打开或关闭该功能,而不仅仅是调用一个操作。为功能添加附加配置应该在按下次要(下拉)部分时显示的 `Flyout` 中进行。 :::info -Pressing a configuration in the `Flyout` should either (1) turn on the feature with the selected configuration, or (2) change the feature to the selected configuration. Pressing a configuration in the `Flyout` should never turn off the feature – that can only be done by toggling the primary part. +在 `Flyout` 中按下配置应该是要么(1)使用所选配置打开功能,要么(2)将功能更改为所选配置。在 `Flyout` 中按下配置不能关闭该功能,只能通过切换主要部分来关闭功能。 ::: -## Common Properties +## 常见属性 -| Property | Description | -| ----------- | -------------------------------------------------------------- | -| `Content` | The content to display in the primary part | -| `Flyout` | The `Flyout` which shows up when the secondary part is clicked | -| `Command` | A command to be invoked when the primary button is clicked | -| `IsChecked` | Gets or sets if the `ToggleSplitButton` is checked | +| 属性 | 描述 | +|-------------|---------------------------------| +| `Content` | 要显示在主要部分的内容 | +| `Flyout` | 当点击次要部分时显示的 `Flyout` | +| `Command` | 主按钮点击时要调用的命令 | +| `IsChecked` | 获取或设置 `ToggleSplitButton` 是否被选中 | -## Pseudoclasses +## 伪类 -| Pseudoclass | Description | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `:pressed` | Set when the entire `ToggleSplitButton` is pressed using a keyboard input such as Space or Enter. In this state no distinction is made between primary or secondary parts | -| `:flyout-open` | Set when the `Flyout` is open | -| `:checked` | Set when the `ToggleSplitButton` is checked. (`IsChecked="true"`) | +| 伪类 | 描述 | +|----------------|---------------------------------------------------------------| +| `:pressed` | 当使用键盘输入(如空格或回车)按下整个 `ToggleSplitButton` 时设置。在此状态下,主要或次要部分没有区别 | +| `:flyout-open` | 当 `Flyout` 打开时设置 | +| `:checked` | 当 `ToggleSplitButton` 被选中时设置。(`IsChecked="true"`) | -## API Reference +## API 参考 [ToggleSplitButton](http://reference.avaloniaui.net/api/Avalonia.Controls/ToggleSplitButton/) -## Source code +## 源代码 [ToggleSplitButton.cs](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs) -## Examples +## 示例 -### Basic example +### 基本示例 ```xml _SplitButton (Flyout opened, checked)_ -### Text editor with numbered or bulleted list example +### 带编号或项目符号列表的文本编辑器示例 -Continuing the text editor example from `SplitButton`, a common use case of the `ToggleSplitButton` is to add bulleted/numbered lists to text. In this example the primary part will toggle the list on/off while the secondary part will open a `Flyout` and allow selecting the bullet or number style. +延续 `SplitButton` 的文本编辑器示例,`ToggleSplitButton` 的常见用例是向文本添加项目符号/编号列表。在此示例中,主要部分将切换列表的打开/关闭状态,而次要部分将打开一个 `Flyout`,允许选择项目符号或编号样式。 ```xml diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/README.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/README.md index 870a363fa..36cf3a59c 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/README.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/README.md @@ -55,21 +55,21 @@ dotnet add package Avalonia.Controls.DataGrid 您可能经常使用以下属性: -| 属性 | 描述 | -| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | -| `AutoGenerateColumns` | 是否根据绑定项数据源属性名称自动生成列头。 (默认为false) | -| `Items` | 作为控件数据源的绑定集合。 | -| `IsReadOnly` | 当为true时,将绑定方向设置为单向。默认值为false,网格将接受对绑定数据的更改。 | -| `CanUserReorderColumns` | 指示用户是否可以通过拖动列头更改列的显示顺序。 (默认为false) | -| `CanUserResizeColumns` | 指示用户是否可以使用指针调整列宽度。 (默认为false) | -| `CanUserSortColumns` | 指示用户是否可以通过单击列头对列进行排序。 (默认为true) | +| 属性 | 描述 | +|-------------------------| ---------------------------------------------------------------------------------------------------------------------------- | +| `AutoGenerateColumns` | 是否根据绑定项数据源属性名称自动生成列头。 (默认为false) | +| `ItemsSource` | 作为控件数据源的绑定集合。 | +| `IsReadOnly` | 当为true时,将绑定方向设置为单向。默认值为false,网格将接受对绑定数据的更改。 | +| `CanUserReorderColumns` | 指示用户是否可以通过拖动列头更改列的显示顺序。 (默认为false) | +| `CanUserResizeColumns` | 指示用户是否可以使用指针调整列宽度。 (默认为false) | +| `CanUserSortColumns` | 指示用户是否可以通过单击列头对列进行排序。 (默认为true) | ## 示例 这个示例将生成一个基本的数据网格,列头名称将根据项类自动生成。项目数据源绑定到主窗口的视图模型。 ```xml - @@ -124,7 +124,7 @@ public class Person 通常来说,从项类中获取的属性名称通常不会成为好的列名。下面这个示例为网格添加了自定义的列头名称。它还允许列重新排序和调整大小,并禁用了默认的列排序选项: ```markup - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/datagridcolumns.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/datagridcolumns.md index 1d8a4214f..6633f5f3f 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/datagridcolumns.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/datagrid/datagridcolumns.md @@ -55,7 +55,7 @@ description: REFERENCE - Built-in Controls - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/datagrid/data-grid-template-columns.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/datagrid/data-grid-template-columns.md index 9a3423027..17f7db588 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/datagrid/data-grid-template-columns.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/datagrid/data-grid-template-columns.md @@ -24,7 +24,7 @@ This example adds a numeric up-down control when the age property for a person i - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/togglebutton.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/togglebutton.md deleted file mode 100644 index 7c141f05e..000000000 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/togglebutton.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -description: REFERENCE - Built-in Controls ---- - -# Toggle Button - -The toggle button can present a Boolean value by using styles and a pseudo class that is either present (true) or absent (false). - -:::info -To review the concepts behind a pseudo class, see [here](../../../concepts/pseudo-classes.md). -::: - -This allows a wide range of possible graphical presentations for the control in each of the pseudo class states. - -## Example - -This example shows a toggle button containing a speaker icon, or a muted speaker icon, depending on whether the button has the checked pseudo class or not. - - - -```xml - - Audio - - - - - - - -``` - - -```xml title='Styles' - - - - - - -``` - - -```xml title='Icons' - - - -``` - - -```xml title='App' - - - - - - -``` - - - -The content zone of the toggle button contains two path icon elements, only one of which is visible at a time. The path icons get their graphics from an assets file which is referenced as an included style set in the `App.xaml` file. The icon geometries are from the _Avalonia UI_ Fluent icons resource. - -:::info -To see the full list of Fluent icons available with _Avalonia UI_, see [https://avaloniaui.github.io/icons.html](https://avaloniaui.github.io/icons.html) -::: - -The visibility of the path icons is set by the window styles, and these use the `:checked` pseudo class to determine when the toggle button is in its checked state. So, when the toggle button is checked, then the `audio-on` path icon is visible, and the `audio-mute` path icon is hidden. And conversely, when the toggle button is not checked, then the `audio-mute` path icon is visible, and the `audio-on` path icon is hidden. - - - -## More Information - -:::info -For the complete API documentation about this control, see [here](https://reference.avaloniaui.net/api/Avalonia.Controls.Primitives/ToggleButton/). -::: - -:::info -View the source code on _GitHub_ [`ToggleButton.cs`](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Primitives/ToggleButton.cs) -::: - - - - - - - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/togglesplitbutton.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/togglesplitbutton.md deleted file mode 100644 index b75e0b720..000000000 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/togglesplitbutton.md +++ /dev/null @@ -1,114 +0,0 @@ -# Toggle Split Button - -The `ToggleSplitButton` functions as a [`ToggleButton`](togglebutton) with primary and secondary parts that can each be pressed separately. The primary part behaves like a normal `ToggleButton` and the secondary part opens a [`Flyout`](../flyouts) with additional actions. - -:::info -The `ToggleSplitButton` has only two states: checked and unchecked. Indeterminate is not supported like it is with a standard `ToggleButton`. This was done intentionally to match WinUI and restricts the control’s usage. The `ToggleSplitButton` should only be used to turn features on/off. Anything other than that is currently considered poor practice from a usability standpoint. -::: - -## Is this the right control? - -A `ToggleSplitButton` is a fairly specialized control and its usage should be restricted to where it makes clear sense from a user-standpoint. It is intended to turn a feature on/off while allowing some additional configurations to be specified rather than the default. - -Like a [`SplitButton`](../buttons/splitbutton), the most common action should be the default and what is shown in the primary part. However, unlike the `SplitButton`, pressing the primary part will turn this feature on or off instead of simply invoking an action. Additional configurations for the feature should be added to the `Flyout` which is shown when the secondary (drop down) part is pressed. - -:::info -Pressing a configuration in the `Flyout` should either (1) turn on the feature with the selected configuration, or (2) change the feature to the selected configuration. Pressing a configuration in the `Flyout` should never turn off the feature – that can only be done by toggling the primary part. -::: - -## Common Properties - -| Property | Description | -| ----------- | -------------------------------------------------------------- | -| `Content` | The content to display in the primary part | -| `Flyout` | The `Flyout` which shows up when the secondary part is clicked | -| `Command` | A command to be invoked when the primary button is clicked | -| `IsChecked` | Gets or sets if the `ToggleSplitButton` is checked | - -## Pseudoclasses - -| Pseudoclass | Description | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `:pressed` | Set when the entire `ToggleSplitButton` is pressed using a keyboard input such as Space or Enter. In this state no distinction is made between primary or secondary parts | -| `:flyout-open` | Set when the `Flyout` is open | -| `:checked` | Set when the `ToggleSplitButton` is checked. (`IsChecked="true"`) | - -## API Reference - -[ToggleSplitButton](http://reference.avaloniaui.net/api/Avalonia.Controls/ToggleSplitButton/) - -## Source code - -[ToggleSplitButton.cs](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs) - -## Examples - -### Basic example - -```xml - - - - - - - - - - - - - -``` - - -_SplitButton (Flyout closed, unchecked)_ - - -_SplitButton (Flyout closed, checked)_ - - -_SplitButton (Flyout opened, checked)_ - -### Text editor with numbered or bulleted list example - -Continuing the text editor example from `SplitButton`, a common use case of the `ToggleSplitButton` is to add bulleted/numbered lists to text. In this example the primary part will toggle the list on/off while the secondary part will open a `Flyout` and allow selecting the bullet or number style. - -```xml - - {{ Path Data }} - {{ Path Data }} -``` - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - -``` - - -_Sample of ToggleSplitButton for toggle text lists on and off and selecting the list format_ diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treedatagrid/README.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treedatagrid/README.md index 087eae316..963ef100d 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treedatagrid/README.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treedatagrid/README.md @@ -43,7 +43,7 @@ dotnet add package Avalonia.Controls.TreeDataGrid Or add package reference directly to the project (`.csproj`) file: ```xml - + ``` :::warning diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treeview-1.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treeview-1.md index 0b3bedf89..38bd71255 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treeview-1.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/detailed-reference/treeview-1.md @@ -15,7 +15,7 @@ This example uses a MVVM pattern view model to hold some hierarchical data based ```xml - + @@ -89,7 +89,7 @@ This is a development of the previous example with multiple root nodes, a revise ```xml diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/grid.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/grid.md index 0f0660a71..0531ee2f5 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/grid.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/grid.md @@ -94,7 +94,7 @@ If a child control has its own dimensions these will be obeyed when it is drawn. You can mix any of the above in the same size definition sequence. For example: -`ColumnDefinitions="300, *, 2*"` +`ColumnDefinitions="200, *, 2*"` Using full expanded XAML, this is the same as: @@ -148,6 +148,7 @@ Here, after the absolute width 100 has been subtracted (for column 0), column 1 The button is drawn to fill the span from the cell (column 1, row 1) plus one column (to the right) and one row down. The result looks like this: + ## More Information :::info diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/gridsplitter.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/gridsplitter.md index 896e4e6c3..78af8112f 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/gridsplitter.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/gridsplitter.md @@ -40,6 +40,9 @@ This is a row splitter: ``` + +## More Information + :::info For the complete API documentation about this control, see [here](http://reference.avaloniaui.net/api/Avalonia.Controls/GridSplitter/). ::: diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/itemscontrol.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/itemscontrol.md index 1b67cdab6..cf4c27284 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/itemscontrol.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/itemscontrol.md @@ -14,7 +14,7 @@ To see the full list of _Avalonia UI_ built-in repeating data controls, see [her You will probably use these properties most often: -
PropertyDescription
ItemsThe bound collection that is used as the data source for the control.
ItemsControl.ItemTemplateAttached property element to contain the data template for an individual item.
+
PropertyDescription
ItemsSourceThe bound collection that is used as the data source for the control.
ItemsControl.ItemTemplateAttached property element to contain the data template for an individual item.
## Example @@ -25,7 +25,7 @@ This example binds an observable collection of crockery items to an items contro ```xml List of crockery: - + List of crockery: - + List of crockery: - + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/menu.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/menu.md index d28a8fd97..345efd1d1 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/menu.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/controls/menu.md @@ -90,7 +90,7 @@ For guidance on how to bind to commands, see [here](../../basics/user-interface/ A menu icon can be displayed by placing an image or a path icon in the `` attached property. For example: ```markup -< + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/upgrade-from-0.10.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/upgrade-from-0.10.md index 705106899..e0fe5c7a9 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/upgrade-from-0.10.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/upgrade-from-0.10.md @@ -9,13 +9,14 @@ Avalonia 11 版本引入了许多与 0.10 版本不兼容的变化。以下指 1. 将 Avalonia 包更新为 11.x 版本。 2. Avalonia.Desktop 包不再包含主题,因此您需要添加以下任一包引用: - - `Avalonia.Themes.Fluent` - - `Avalonia.Themes.Simple` + - `Avalonia.Themes.Fluent` + - `Avalonia.Themes.Simple` 3. 移除对`XamlNameReferenceGenerator`包的引用,Avalonia 现在默认包含内置的生成器。 4. 如有需要,将``更新至至少 9,以便使用仅限初始化属性 (init-only properties)。 5. 如果需要与 0.10 版本相同的字体,还需包括`Avalonia.Fonts.Inter`包,并在应用程序构建器中添加`.WithInterFont()`。在 11.0 版本中,默认情况下不包含任何自定义字体。 ## 主题处理 + 在 0.10 版本中,主题直接在`Application.axaml`文件的`Application.Styles`标签内指定。以下是示例: ```xml @@ -23,11 +24,13 @@ Avalonia 11 版本引入了许多与 0.10 版本不兼容的变化。以下指 ``` + 在这个示例中,`FluentTheme`标签的`Mode`属性用于指定主题模式,可以是 "Light" 或 "Dark"。 引入了一个新属性`RequestedThemeVariant`,用于`Application`标签,该属性用于设置应用程序的主题,如果指定了,则会覆盖系统当前的主题。如果要遵循系统当前的主题,可以将其设置为 "Default"。其他可用选项为 "Dark" 和 "Light"。 以下示例展示了如何使用该属性: + ```xml ``` + `FluentTheme`标签不再需要`Mode`属性,可以将其留空: ```xml @@ -43,7 +47,21 @@ Avalonia 11 版本引入了许多与 0.10 版本不兼容的变化。以下指 ``` +### 主题字典和主题变体 + +根据 PR [#8166](https://github.com/AvaloniaUI/Avalonia/pull/8166),现在方法 `Styles.TryGetResource` 需要一个可为空的 `ThemeVariant` 参数。这允许用户指定 `Light`、`Dark` 和 `Default`。 +使用 `ThemeVariant.Default` 作为键将特定的主题字典标记为一种回退(fallback),以防在其他主题字典中找不到主题变体或资源键。 + +除了内置的 `Light`、`Dark` 和 `Default` 值外,任何对象值都可以用作键(_因为它包装在 `ThemeVariant(object key)` 结构中_)。如果开发人员希想要在 XAML 代码中定义多个自定义主题作为静态属性并从中引用它们,则可以在此处使用 `{x:Static}` 标记扩展。 + +```cs +// 以前 +bool TryGetResource(object key, out object? value) + +// Avalonia v11 +bool TryGetResource(object key, ThemeVariant? theme, out object? value) +``` ## System.Reactive/Observables @@ -112,7 +130,7 @@ class MyButton : Button 请注意,此源生成器仅适用于 C#。对于 F#,没有进行任何更改。 -# ItemsControl +## ItemsControl `ItemsControl` 和派生类(例如 `ListBox` 和 `ComboBox`)现在都有 `Items` 属性和 `ItemsSource` 属性,与 WPF/UWP 类似。 @@ -120,13 +138,13 @@ class MyButton : Button 将所有绑定到 `Items` 的绑定更改为绑定到 `ItemsSource`: -``` +```xml ``` -替换为: +替换为: -``` +```xml ``` @@ -198,7 +216,7 @@ var bitmap = new Bitmap(AssetLoader.Open(new Uri(uri))); protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) ``` -替换为: +替换为: ```csharp protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) @@ -219,11 +237,11 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang - `PointerEnter` -> `PointerEntered` - `PointerLeave` -> `PointerExited` - `ContextMenu` - - `ContextMenuClosing` -> `Closing` - - `ContextMenuOpening` -> `Opening` + - `ContextMenuClosing` -> `Closing` + - `ContextMenuOpening` -> `Opening` - `MenuBase` - - `MenuClosed` -> `Closed` - - `MenuOpened` -> `Opened` + - `MenuClosed` -> `Closed` + - `MenuOpened` -> `Opened` `RoutedEventArgs.Source` 的类型从 `IInteractive` 更改为 `object`: :需要将其转换为具体类型(如 `Control`)才能使用它。 @@ -279,7 +297,7 @@ InputElement.GotFocusEvent.Raised.Subscribe(new AnonymousObserver<(object, Route 在 0.10.x 版本中,使用 `IVisual` 暴露控件的视觉父级和视觉子级。由于 `IVisual` 不再可用,现在将其作为扩展方法暴露在 `Avalonia.VisualTree` 命名空间中: -``` +```csharp using Avalonia.VisualTree; var visualParent = control.GetVisualParent(); @@ -297,6 +315,7 @@ var visualChildren = control.GetVisualChildren(); ## 定位器 `AvaloniaLocator` 不再可用。现在大多数通过定位器可用的服务都有替代方法: + 1. `AssetLoader` 现在是一个静态类,具有所有旧方法。 2. `IPlatformSettings` 已移到 `TopLevel.PlatformSettings` 和 `Application.PlatformSettings`。请注意,始终应优先使用特定顶级(窗口)的设置,而不是全局设置。 3. `IClipboard` 已移到 `TopLevel.Clipboard`。请注意,`Application.Clipboard` 也已被移除。 @@ -312,4 +331,5 @@ var visualChildren = control.GetVisualChildren(); - 在直接返回 `Task` 的方法中,在对 `Dispatcher.UIThread.InvokeAsync` 进行调用时,请在调用结尾添加 `.GetTask()`。 - `IRenderRoot.RenderScaling` 已移至 `TopLevel.RenderScaling` - `LightweightObservableBase` 和 `SingleSubscriberObservableBase` 现在已变为内部类。这些实用程序类设计用于 Avalonia 中的特定目的,并不打算由客户端使用,因为它们不能处理某些边缘情况。使用 `System.Reactive` 提供的机制来创建可观察对象,例如 `Observable.Create` -- 在绑定到方法时,方法必须没有参数或仅有一个对象参数。 \ No newline at end of file +- 在绑定到方法时,方法必须没有参数或仅有一个对象参数。 +- `OpenFileDialog` 和 `SaveFileDialog` 现在已移除。对于文件系统存储服务,请在 `TopLevel` 使用 `IStorageProvider`。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/whats-new.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/whats-new.md index 74e766b07..89f47221f 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/whats-new.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/stay-up-to-date/whats-new.md @@ -3,4 +3,51 @@ id: whats-new title: What's new --- -TODO: What's new in Avalonia 11 \ No newline at end of file +The Avalonia team has been working hard on this release and we're excited to share with you all the new features and improvements. Let's dive in! + +## New Features + +### A11y (Accessibility) +This version of Avalonia takes major strides in making applications more accessible. We've added support for various accessibility tools, making it easier for everyone to use Avalonia applications. + +### IME (Input Method Editor) Support +We have introduced support for Input Method Editor (IME), facilitating users to input characters and symbols not found on their input devices. + +### Composition Renderer +The new composition renderer enhances the graphical rendering capabilities, providing a more robust, efficient, and flexible rendering pipeline. + +### WebAssembly (WASM) Support +WASM support allows Avalonia applications to run directly in the browser, broadening our platform support and giving developers more freedom and flexibility. + +### iOS and Android Support +We've added support for both iOS and Android platforms. Developers can now build and run Avalonia applications on two of the most popular mobile platforms. + +### Text Inlines +With the Text Inlines feature, you can easily construct complex formatted text blocks. It enables you to add annotations, hyperlinks, and other inline elements in your text. + +### Smooth Virtualization (Reworked ItemsControl) +We've completely reworked the ItemsControl to provide smooth virtualization. This improves the efficiency and user experience for controls with many items. + +### Performance Improvements +Avalonia 11.0 comes with significant performance improvements, enhancing the speed and efficiency of your applications. + +### Control Themes, Nested Styles, and Theme Variants +We've added the ability to theme controls, apply nested styles, and choose theme variants. This makes it easier to build beautiful and consistent UIs. + +### Bitmap Effects +The Bitmap Effects feature lets you apply visual effects to bitmaps. You can add blur, drop shadows, and other effects to images. + +### 3D Transforms +With 3D Transforms, you can now create stunning three-dimensional effects in your UI. + +### AOT (Ahead-Of-Time) Compilation and Trimming +AOT compilation enables your apps to run faster by compiling them before runtime. Trimming reduces the size of your apps by removing unused code. + +### GPU Interop +The GPU Interop feature allows Avalonia to work more efficiently with the GPU, improving rendering performance and visuals. + +### Experimental Metal Support +We're testing Metal support to improve performance on iOS and macOS devices. + +## Important Notes +This version also includes many bug fixes and improvements based on community feedback. As always, your feedback and contributions help us make Avalonia better. Please report any issues or suggestions on [GitHub](https://www.github.com/avaloniaui/avalonia). \ No newline at end of file diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-and-layout-controls.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-and-layout-controls.md index 7bca9e481..a12e23629 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-and-layout-controls.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-and-layout-controls.md @@ -128,7 +128,7 @@ description: TUTORIALS - Music Store App ```markup - + ``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-items-to-users-collection.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-items-to-users-collection.md index c96bf0e11..8127a4ea3 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-items-to-users-collection.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/add-items-to-users-collection.md @@ -54,7 +54,7 @@ xmlns:views="clr-namespace:Avalonia.MusicStore.Views" - 在按钮元素下方,添加如下所示的 XAML: ```xml - + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/album-view.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/album-view.md index 11dbfc34c..1dcbfa0fd 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/album-view.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/album-view.md @@ -121,7 +121,7 @@ public class AlbumViewModel : ViewModelBase - 添加所示的 `` XAML: ```markup - diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/creating-a-modern-looking-window.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/creating-a-modern-looking-window.md index 897bb61b3..2bfd5d5cf 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/creating-a-modern-looking-window.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/creating-a-modern-looking-window.md @@ -12,10 +12,11 @@ description: TUTORIALS - Music Store App - 如果应用程序仍在运行,请停止它。 - 找到并打开文件 **App.axaml**。 -- 在 XAML 中,将 `` 元素中的 `Mode` 属性从 `Light` 更改为 `Dark`: +- 在 XAML 中,将 `` 元素中的 `RequestedThemeVariant` 属性从 `Default` 更改为 `Dark`: ```markup - + ``` - 现在,在 **/Views** 文件夹中找到并打开 **MainWindow.axaml** 文件。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/mock-search.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/mock-search.md index bb0941ee2..b16df2697 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/mock-search.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/mock-search.md @@ -118,7 +118,7 @@ public AlbumViewModel? SelectedAlbum - 将所示的绑定表达式添加到 `` 元素中: ``` - + ``` ## 模拟数据 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/return-from-dialog.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/return-from-dialog.md index a65d91b8c..e3dff3b88 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/return-from-dialog.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/return-from-dialog.md @@ -40,7 +40,7 @@ public MusicStoreViewModel() 您的下一步是将 **购买专辑** 按钮绑定到音乐商店视图模型中的响应式命令,按照以下步骤操作: -- 找到并打开 **MusicStoreView.cs** 文件。 +- 找到并打开 **MusicStoreView.axaml** 文件。 - 将数据绑定 `Command="{Binding BuyMusicCommand}"` 添加到按钮元素中。 ## 关闭对话框 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/searching-for-albums.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/searching-for-albums.md index 345daefea..6432b64bb 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/searching-for-albums.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/searching-for-albums.md @@ -175,9 +175,13 @@ namespace Avalonia.MusicStore.ViewModels - 定位并打开 **AlbumView.asaml** 文件。 - 添加两个文本块控件及其数据绑定,如下所示: +- To have compiled binding working, you need to indicate the datatype used in the view : AlbumViewModel. ```xml + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/summary.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/summary.md index d4f2b5878..1879fdeba 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/summary.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/music-store-app/summary.md @@ -12,7 +12,7 @@ description: TUTORIALS - Music Store App 应用程序状态保存在“顶级”视图模型中,并可以持久化到磁盘。主窗口和搜索对话框是由 _Avalonia UI_ 窗口控件、内置控件和用户控件组成的。 -本教程应用程序针对的是像 _Apple iOS_ 或 _Windows_ 这样的窗口平台。 +本教程应用程序针对的是像 _Apple Mac OS_ 或 _Windows_ 这样的窗口平台。 :::info 要了解有关针对 iOS(Apple)平台的应用程序的更多信息,请参阅[这里](../../guides/platforms/ios)。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-a-data-context.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-a-data-context.md index 5df0305ee..690b58e9b 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-a-data-context.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-a-data-context.md @@ -9,24 +9,25 @@ description: TUTORIALS - To Do List App 要设置数据上下文,请按照以下步骤进行: - 在 **Views** 文件夹中找到 **MainWindowView.axaml** 文件。 -- 删除 `xmlns:vm` 的命名空间声明。 - 完全删除 `` 标签。 -- 编辑 title 属性,将窗口标题更改为 'Avalonia To Do List'。 +- 将 `x:DataType="vm:MainWindowViewModel"` 属性添加到 `` 元素。 - 定位到内容 ``。 - 添加属性 `DataContext="{Binding ToDoList}"`,如下所示: ```xml - ``` 视图和视图模型的排列现在有了一个额外的数据上下文;这个数据上下文被定义为一个绑定,它将允许 _Avalonia UI_ 绑定器定位 `ToDoListViewModel` 对象上的 `ToDoList` 属性。此对象在应用程序初始化时已经被实例化。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-item-buttons.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-item-buttons.md index c610d952f..efb3ed58c 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-item-buttons.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/add-item-buttons.md @@ -110,10 +110,12 @@ CancelCommand = ReactiveCommand.Create(() => { }); ```markup + x:Class="ToDoList.Views.AddItemView" + x:DataType="vm:AddItemViewModel"> - - - + x:Class="ToDoList.Views.AddItemView" + x:DataType="vm:AddItemViewModel"> + + + + + ``` @@ -52,31 +84,4 @@ description: TUTORIALS - To Do List App * `Text` 将文本框中显示的文本绑定到视图模型上的 `Description` 属性(您还没有创建视图模型)。 * `Watermark` 当文本框为空时显示一个占位符。 -## 创建视图模型 - -目前为止,您只绑定了一个描述属性。因此,相应的视图模型可以从简开始。 - -按照以下步骤为新视图创建视图模型: - -- In the **Solution Explorer** locate and right-click the **ViewModels** folder. -- Click **Add**, then **Class**. -- Name the class 'AddItemViewModel'. Click **Add**. -- Add the description property as shown: -- 在 **解决方案资源管理器** 中找到并右键单击 **ViewModels** 文件夹。 -- 点击 **添加**,然后点击 **类**。 -- 将类命名为 `AddItemViewModel`,然后点击 **添加**。 -- 添加如下所示的描述属性: - -```csharp -using System; - -namespace ToDoList.ViewModels -{ - public class AddItemViewModel : ViewModelBase - { - public string Description { get; set; } = String.Empty; - } -} -``` - 在下一页中,您将学习如何更改主窗口中的视图,以在待办事项列表视图的位置显示新项目视图。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-model.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-model.md index 9ed53d6d7..6e816a047 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-model.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-model.md @@ -24,6 +24,8 @@ description: TUTORIALS - To Do List App - 更改类中的代码如下所示: ```csharp +using System; + namespace ToDoList.DataModel { public class ToDoItem diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-new-project.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-new-project.md index 6f2accb3e..1a687b814 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-new-project.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-new-project.md @@ -55,10 +55,10 @@ dotnet new avalonia.mvvm -o ToDoList -n ToDoList ToDoList |- App.axaml |- App.axaml.cs + |- app.manifest |- Assets | |- avalonia-logo.ico |- Models - |- nuget.config |- Program.cs |- ToDoList.csproj |- ViewLocator.cs diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-view.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-view.md index edc0b8c8a..f50bc2f72 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-view.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/creating-a-view.md @@ -85,7 +85,7 @@ namespace ToDoList.Views xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="450" - x:Class="ToDoList.Views.TodoListView"> + x:Class="ToDoList.Views.ToDoListView"> ``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/process-a-new-item.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/process-a-new-item.md index bc74cff91..9f4fc0320 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/process-a-new-item.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/process-a-new-item.md @@ -24,15 +24,14 @@ namespace ToDoList.ViewModels public class MainWindowViewModel : ViewModelBase { private ViewModelBase _contentViewModel; - public ToDoListViewModel ToDoListViewModel { get; } // 这个视图模型依赖于 ToDoListService public MainWindowViewModel() { var service = new ToDoListService(); - ToDoListViewModel = new ToDoListViewModel(service.GetItems()); - _contentViewModel = ToDoListViewModel; + ToDoList = new ToDoListViewModel(service.GetItems()); + _contentViewModel = ToDoList; } public ViewModelBase ContentViewModel @@ -41,6 +40,8 @@ namespace ToDoList.ViewModels private set => this.RaiseAndSetIfChanged(ref _contentViewModel, value); } + public ToDoListViewModel ToDoList { get; } + public void AddItem() { AddItemViewModel addItemViewModel = new(); @@ -53,9 +54,9 @@ namespace ToDoList.ViewModels { if (newItem != null) { - ToDoListViewModel.ListItems.Add(newItem ); + ToDoList.ListItems.Add(newItem ); } - ContentViewModel = ToDoListViewModel; + ContentViewModel = ToDoList; }); ContentViewModel = addItemViewModel; diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/wiring-up-the-views.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/wiring-up-the-views.md index d48e1e457..9987879e2 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/wiring-up-the-views.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/todo-list-app/wiring-up-the-views.md @@ -11,6 +11,7 @@ description: TUTORIALS - To Do List App 按照以下步骤调整您的用户控件以使用项控件: - 找到并打开 **ToDoListView.axaml** 文件。 +- 将 `xmlns:vm="using:ToDoList.ViewModels"` 和 `x:DataType="vm:ToDoListViewModel"` 属性添加到 `` 元素。 - 替换 `` 元素,使代码如下所示: ```xml @@ -20,22 +21,22 @@ description: TUTORIALS - To Do List App xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="450" x:Class="ToDoList.Views.ToDoListView"> - - - - - - - - - - + + + + + + + + + + ``` diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/welcome.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/welcome.md index 848aa8194..272d49657 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/welcome.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/welcome.md @@ -5,12 +5,6 @@ title: 欢迎 欢迎阅读 Avalonia 文档 -```info -Avalonia v11 是一个发布候选版本。 - -我们预计在2023年7月初正式发布GA版本。 -``` - ## 概述 Avalonia是一个强大的框架,使开发人员能够使用.NET创建跨平台应用程序。它使用自己的渲染引擎绘制UI控件,确保在Windows、macOS、Linux、Android、iOS和WebAssembly等不同平台上具有一致的外观和行为。这意味着开发人员可以共享他们的UI代码,并在不同的目标平台上保持统一的外观和感觉。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/controls/textbox.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/controls/textbox.md index fb5981d04..0998dd5ee 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/controls/textbox.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/controls/textbox.md @@ -60,6 +60,11 @@ produces the following output in **Windows 10** when text is input
+When using the Fluent theme, you can apply the style class, `revealPasswordButton`, and the TextBox will provide an eye 👁 glyph for the user to show the plane text temporally. Please note, the `TextBox` may be written to but not copied from. + +```markup + +``` ### TextBox with watermark diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/compiled-bindings.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/compiled-bindings.md index 84098cc9d..901ddca7d 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/compiled-bindings.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/compiled-bindings.md @@ -3,7 +3,7 @@ id: compiled-bindings title: Compiled Bindings --- -Bindings defined in the XAML are using reflection in order to find and access the requested property in your `ViewModel`. In Avalonia you can also use compiled bindings, which has some benefits: +Bindings defined in the XAML are using reflection in order to find and access the requested property in your `ViewModel`. In Avalonia, you can also use compiled bindings, which have some benefits: * If you use compiled bindings and the property you bind to is not found, you will get a compile-time error. Hence you get a much better debugging experience. * Reflection is known to be slow ([see this article on codeproject.com](https://www.codeproject.com/Articles/1161127/Why-is-reflection-slow)). Using compiled bindings can therefore improve the performance of your application. @@ -101,4 +101,4 @@ Compiled bindings have some known limitations: * Compiled bindings cannot be used to bind to named elements * Compiled bindings cannot be used in Styles with RelativeSource set to TemplatedParent (e.g.: `{Binding Width, RelativeSource={RelativeSource TemplatedParent}}`) -If you hit one of those limitations you should disable compiled bindings for the failing XAML-node or use `ReflectionBinding` instead. \ No newline at end of file +If you hit one of those limitations you should disable compiled bindings for the failing XAML-node or use `ReflectionBinding` instead. diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/index.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/index.md index 8412f08de..49fffb5d6 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/index.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/data-binding/index.md @@ -2,6 +2,6 @@ Data binding provides a simple way to get data into your application's UI without having to set properties on each control each time a value changes. -Data binding is a way to establish mapping between properties of the object, to properties of UI controls. These mapping can be either bidirectional, where changes in control, apply change to underlying object, and vice versa, when changes of the object's property result in the UI changes or single-directional where changes propagated just in one direction. For example, if the user edits the value in a `TextBox`, the underlying object's property is automatically updated to include value entered by the user. +Data binding is a way to establish a mapping between the properties of the object, to properties of UI controls. These mapping can be either bidirectional, where changes in control, apply changes to the underlying object, and vice versa when changes of the object's property result in the UI changes, or single-directional where changes propagated just in one direction. For example, if the user edits the value in a `TextBox`, the underlying object's property is automatically updated to include value entered by the user. Binding is often used with the [MVVM Pattern](https://msdn.microsoft.com/en-us/library/hh848246.aspx) and for the rest of this guide we'll be assuming that you're using that pattern in your code. diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/guides/developer-guides/debugging-previewer.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/guides/developer-guides/debugging-previewer.md index 5303ae7de..36a313b67 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/guides/developer-guides/debugging-previewer.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/guides/developer-guides/debugging-previewer.md @@ -5,21 +5,31 @@ title: Debugging Previewer By default, even if you would put a breakpoint in Avalonia main repo directly it would not be hit when Previewer executes this code. This is because Previewer is a completely different process usually run by IDE. -**But how do we debug it then?** +**Debugging with JetBrains Rider** -You may try to attach the debugger manually. For doing that you will need to find a previewer process. You may use e.g "Process Hacker". Here you will see all processes in the system. Everything you will need to do is to type Avalonia in the search field. +First of all to debug previewer process you will need to attach debugger to the process. To do that you may use Ctrl+Alt+P shortcut or click "..." button and then click "Attach to the Process". -
- -
+![image](https://github.com/AvaloniaUI/avalonia-docs/assets/53405089/767a290d-905a-483d-bfa4-e8ee918c6bca) -In my case process was called **.NET Host**. You can understand that this process is Avalonia Previewer by clicking with the right mouse button on the process and selecting "Properties".Here in the "Command line" field, you will see a command that invokes previewer. +Then in the search field you will need to type Avalonia and find this process,you may identify it by the Avalonia.Designer.HostApp.dll in the name. -
- -
+![image](https://github.com/AvaloniaUI/avalonia-docs/assets/53405089/bf29bb6a-76a3-4290-944c-be06e2cb0eb4) + +Then you click "Attach with .NET Core Debugger" and after that by using "Search everywhere" Rider feature you may place breakpoints in the previewer code and debug it. + + +**Debugging with Visual Studio** -When you know the process id you can simply click "Debug" in process explorer. But sometimes previewer process may crash even before you would attach your debugger. Then you will need to modify this file [Program.cs](https://github.com/AvaloniaUI/Avalonia/blob/master/src/tools/Avalonia.Designer.HostApp/Program.cs) specifically method Main\(one of them depending on target framework\). +To start debugging you would need a process ID. To get it you need to switch the output to Avalonia Diagnostics. Then you copy the number before the "Connection initialized" message. This number is the previewer process ID. +![image](https://github.com/AvaloniaUI/avalonia-docs/assets/53405089/0b77cb87-2454-458e-9722-0659525feeb9) + + +Then you may find process by the process id in the process explorer or some other program and attach the debugger manually. + +![image](https://github.com/AvaloniaUI/avalonia-docs/assets/53405089/2c50bf8d-047c-481c-af01-00474acc73fe) + + +When you know the process id you can simply click "Debug" in process explorer. But sometimes previewer process may crash even before you would attach your debugger. Then you will need to add this code th the Main method in the Program.cs. ```csharp Debugger.Launch(); @@ -29,10 +39,12 @@ while (!Debugger.IsAttached) This code will attach debugger to the previewer programmatically. +But if you need to place breakpoints in the previewer code you may need to use [dnSpy](https://github.com/dnSpy/dnSpy) or something similar because Visual Studio doesen't support that. + **How would I understand that I have launched a debugger?** You should see a window like this.
-
\ No newline at end of file + diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/styling/resources.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/styling/resources.md index 194914089..c3f716b07 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/styling/resources.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/styling/resources.md @@ -155,4 +155,4 @@ Window ## Theme resources -Themes will usually define brushes, colors and other settings as resources. By changing these resources one can e.g. switch from a dark to a light theme. The resources defined will usually be specific to the theme in use but you can see the resources defined by the default theme [here](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Default/Accents/BaseLight.xaml). +Themes will usually define brushes, colors and other settings as resources. By changing these resources one can e.g. switch from a dark to a light theme. The resources defined will usually be specific to the theme in use but you can see the resources defined by the default theme [here](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Accents/BaseResources.xaml). diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/tutorials/music-store-app/creating-a-modern-looking-window.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/tutorials/music-store-app/creating-a-modern-looking-window.md index 2d81f89a8..9d8d85c8f 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/tutorials/music-store-app/creating-a-modern-looking-window.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/tutorials/music-store-app/creating-a-modern-looking-window.md @@ -9,10 +9,15 @@ Let's try and make this look a little more modern by applying `Dark` mode and so 1. Open App.axaml - Change the FluentTheme Mode from Light to Dark. + Change the FluentTheme Mode from Default to Dark. ```markup - + + ``` 1. Open `MainWindow.axaml` notice that it's still showing the Light mode version in the previewer. diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/welcome.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/welcome.md index 2696a6413..401b134d6 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/welcome.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10.x/welcome.md @@ -3,7 +3,7 @@ id: welcome title: Welcome --- -欢迎阅读 Avalonia 文档 Welcome to the documentation for Avalonia, a cross-platform .NET framework for building beautiful, modern graphical user interfaces (GUIs). With Avalonia, you can create native applications for Windows, macOS, Linux, iOS, Android, and WebAssembly, all from a single codebase. +Welcome to the documentation for Avalonia, a cross-platform .NET framework for building beautiful, modern graphical user interfaces (GUIs). With Avalonia, you can create native applications for Windows, macOS, Linux, iOS, Android, and WebAssembly, all from a single codebase. ## Supported .NET Versions