Unify and improve language settings for code snippets
This commit is contained in:
Родитель
874d1464ef
Коммит
60cc950df2
|
@ -18,7 +18,7 @@ You can run "dotnet add package" from the command line:
|
|||
dotnet add package Avalonia.Controls.DataGrid
|
||||
```
|
||||
Or add package reference directly to the csproj file:
|
||||
```xml
|
||||
```markup
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.16" />
|
||||
```
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ This column is used to display text data, normally represented by a `string`. In
|
|||
|
||||
### Example
|
||||
|
||||
```
|
||||
```markup
|
||||
<DataGrid Name="MyDataGrid" Items="{Binding People}" AutoGenerateColumns="False" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Forename" Binding="{Binding FirstName}"/>
|
||||
|
@ -47,7 +47,7 @@ This column is used to represent a `bool` value. The value is represented by a
|
|||
|
||||
### Example
|
||||
|
||||
```
|
||||
```markup
|
||||
<DataGrid Name="MyDataGrid" Items="{Binding ToDoListItems}" AutoGenerateColumns="False" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header="✔" Binding="{Binding IsChecked}"/>
|
||||
|
@ -74,7 +74,7 @@ The DataGridTemplateColumn is editable from Avalonia version 0.10.12 onward. If
|
|||
|
||||
### Example
|
||||
|
||||
```
|
||||
```markup
|
||||
<DataGrid Name="MyDataGrid"
|
||||
xmlns:model="using:MyApp.Models" >
|
||||
<DataGrid.Columns>
|
||||
|
|
|
@ -67,7 +67,7 @@ There are two built-in types of Flyouts: `Flyout` and `MenuFlyout`. A regular `F
|
|||
|
||||
In order to be shown Flyouts have to be attached to a specific control, though this is not a static assignment and can be changed at runtime. `Button` has a `Flyout` property that can be used open a Flyout upon click.
|
||||
|
||||
```Xml
|
||||
```markup
|
||||
<Button Content="Click me">
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
|
@ -80,7 +80,7 @@ In order to be shown Flyouts have to be attached to a specific control, though t
|
|||
### Attached Flyouts
|
||||
For other controls that don't have built-in support for flyouts, one can be assigned using attached flyouts
|
||||
|
||||
```Xml
|
||||
```markup
|
||||
<Border Background="Red" PointerPressed="Border_PointerPressed">
|
||||
<FlyoutBase.AttachedFlyout>
|
||||
<Flyout>
|
||||
|
@ -92,7 +92,7 @@ For other controls that don't have built-in support for flyouts, one can be assi
|
|||
|
||||
Attached Flyouts can be shown by calling the `ShowAttachedFlyout` method
|
||||
|
||||
```C#
|
||||
```csharp
|
||||
public void Border_PointerPressed(object sender, RoutedEventArgs args)
|
||||
{
|
||||
FlyoutBase.ShowAttachedFlyout(sender as Control);
|
||||
|
@ -109,7 +109,7 @@ ContextFlyouts are invoked automatically like normal `ContextMenu`s. Although cu
|
|||
|
||||
As previously mentioned, Flyouts can be shared between various elements within your app.
|
||||
|
||||
```Xml
|
||||
```markup
|
||||
<Window.Resources>
|
||||
<Flyout x:Key="MySharedFlyout">
|
||||
<!-- Flyout content here -->
|
||||
|
@ -126,7 +126,7 @@ As previously mentioned, Flyouts can be shared between various elements within y
|
|||
|
||||
Although `Flyout`s are not controls themselves, their general appearance can still be customized by targeting the presenter the `Flyout` uses to display its content. For a normal `Flyout` this is `FlyoutPresenter` and for `MenuFlyout` this is `MenuFlyoutPresenter`. Because flyout presenters are not exposed, special style classes that should pertain to specific flyouts can be passed using the `FlyoutPresenterClasses` property on `FlyoutBase`
|
||||
|
||||
```Xml
|
||||
```markup
|
||||
<Style Selector="FlyoutPresenter.mySpecialClass">
|
||||
<Setter Property="Background" Value="Red" />
|
||||
</Style>
|
||||
|
@ -142,7 +142,7 @@ To create a custom flyout type, derive from FlyoutBase. You'll have to override
|
|||
|
||||
The following example creates a simple `Flyout` that hosts an image
|
||||
|
||||
```C#
|
||||
```csharp
|
||||
public class MyImageFlyout : FlyoutBase
|
||||
{
|
||||
public static readonly StyledProperty<IImage> ImageProperty = AvaloniaProperty.Register<MyImageFlyout, IImage>(nameof(Image));
|
||||
|
|
|
@ -45,7 +45,7 @@ Here is another example showing the difference between those two.
|
|||
|
||||
First let's create sample 2x2 grid in our View, we can achieve this simply by writing code looking like this:
|
||||
|
||||
```text
|
||||
```markup
|
||||
<Grid ShowGridLines="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
|
@ -68,7 +68,7 @@ Now let's fill our grid with some elements, I will fill every field with button,
|
|||
|
||||
Now our View code look's like this:
|
||||
|
||||
```text
|
||||
```markup
|
||||
<Grid ShowGridLines="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
|
@ -94,7 +94,7 @@ As you can see our grid become sticky to its content, it is very useful when we
|
|||
|
||||
This new View code look's like this:
|
||||
|
||||
```text
|
||||
```markup
|
||||
<Grid ShowGridLines="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
|
|
|
@ -94,7 +94,7 @@ By default bindings to this property are two-way.
|
|||
|
||||
Exposes the selected item in the `Items` collection, or in the case of multiple selection the first selected item. You will often want to bind this to a view model if your list `SelectionMode` is set to `Single`.
|
||||
|
||||
```text
|
||||
```markup
|
||||
<ListBox SelectedItem="{Binding SelectedItem}">
|
||||
```
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ Dynamically generated `TabItem`s through binding are also supported. In this cas
|
|||
|
||||
The following example uses a `TabItemModel` array to represent two tabs. Let's first create the model.
|
||||
|
||||
```markup
|
||||
```csharp
|
||||
public class TabItemModel
|
||||
{
|
||||
public string Header { get; }
|
||||
|
@ -108,7 +108,7 @@ public class TabItemModel
|
|||
|
||||
Create an array of two `TabItemModel` instances and bind it to the DataContext.
|
||||
|
||||
```markup
|
||||
```csharp
|
||||
DataContext = new TabItemModel[] {
|
||||
new TabItemModel("One", "Some content on first tab"),
|
||||
new TabItemModel("Two", "Some content on second tab"),
|
||||
|
|
|
@ -32,7 +32,7 @@ We accept issues and pull requests but we answer and review only pull requests a
|
|||
* Add the `Avalonia.Controls.TreeDataGrid` NuGet package to your project
|
||||
* Add the `TreeDataGrid` theme to your `App.xaml` file (the `StyleInclude` in the following markup):
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="AvaloniaApplication.App">
|
||||
|
|
|
@ -83,7 +83,7 @@ The columns above are defined as `TextColumn`s - again, `TextColumn` is a generi
|
|||
|
||||
It's now time to add the `TreeDataGrid` control to a window and bind it to the source.
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="AvaloniaApplication.MainWindow">
|
||||
|
|
|
@ -114,7 +114,7 @@ The remaining columns are also defined as `TextColumn`s - again, `TextColumn` is
|
|||
|
||||
It's now time to add the `TreeDataGrid` control to a window and bind it to the source.
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="AvaloniaApplication.MainWindow">
|
||||
|
|
|
@ -27,7 +27,7 @@ private async Task<string> GetTextAsync()
|
|||
```
|
||||
|
||||
You can bind to the result in the following way:
|
||||
```xaml
|
||||
```markup
|
||||
<TextBlock Text="{Binding MyAsyncText^, FallbackValue='Wait a second'}" />
|
||||
```
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Compiled bindings are not enabled by default. To enable compiled bindings, you w
|
|||
|
||||
You can now enable or disable compiled bindings by setting `x:CompileBindings="[True|False]"`. All child nodes will inherit this property, so you can enable it in your root node and disable it for a specific child, if needed.
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- Set DataType and enable compiled bindings -->
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -38,7 +38,7 @@ You can now enable or disable compiled bindings by setting `x:CompileBindings="[
|
|||
|
||||
If you don't want to enable compiled bindings for all child nodes, you can also use the `CompiledBinding`-markup. You still need to define the `DataType`, but you can omit `x:CompileBindings="True"`.
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- Set DataType -->
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -63,7 +63,7 @@ If you don't want to enable compiled bindings for all child nodes, you can also
|
|||
## ReflectionBinding-Markup
|
||||
If you have compiled bindings enabled in the root node (via `x:CompileBindings="True"`) and you either don't want to use compiled binding at a certain position or you hit one of the [known limitations](#known-limitations), you can use the `ReflectionBinding`-markup.
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- Set DataType -->
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
|
|
@ -49,7 +49,7 @@ If you need a protocol registration or file associations - open plist files from
|
|||
|
||||
Example protocol:
|
||||
|
||||
```text
|
||||
```xml
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -67,7 +67,7 @@ Example protocol:
|
|||
|
||||
Example file association
|
||||
|
||||
```text
|
||||
```xml
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -125,20 +125,20 @@ You'll first have to add the project as a `PackageReference` in your project. Ad
|
|||
|
||||
After that, you can create your `.app` by executing the following on the command line:
|
||||
|
||||
```text
|
||||
```bash
|
||||
dotnet restore -r osx-x64
|
||||
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -p:UseAppHost=true
|
||||
```
|
||||
|
||||
You can specify other parameters for the `dotnet msbuild` command. For instance, if you want to publish in release mode:
|
||||
|
||||
```text
|
||||
```bash
|
||||
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -property:Configuration=Release -p:UseAppHost=true
|
||||
```
|
||||
|
||||
or if you want to specify a different app name:
|
||||
|
||||
```text
|
||||
```bash
|
||||
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -p:CFBundleDisplayName=MyBestThingEver -p:UseAppHost=true
|
||||
```
|
||||
|
||||
|
@ -175,7 +175,7 @@ dotnet publish -r osx-x64 --configuration Release -p:UseAppHost=true
|
|||
|
||||
Create your `Info.plist` file, adding or modifying keys as necessary:
|
||||
|
||||
```markup
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
|
@ -248,7 +248,7 @@ You'll also need to have the Xcode command line tools installed. You can get tho
|
|||
|
||||
First, enable Hardened Runtime with [exceptions](https://developer.apple.com/documentation/security/hardened_runtime?language=objc) by creating an `MyAppEntitlements.entitlements` file:
|
||||
|
||||
```markup
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
|
@ -376,7 +376,7 @@ You should read all [entitlements documentation](https://developer.apple.com/doc
|
|||
|
||||
First for the entitlements file is to sign all helper executables inside `.app/Content/MacOS/` folder. It should look like this.
|
||||
|
||||
```text
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
|
@ -391,7 +391,7 @@ First for the entitlements file is to sign all helper executables inside `.app/C
|
|||
|
||||
Second is to sign app executable and a whole app bundle. It should contain all app's permissions. Here is an example:
|
||||
|
||||
```text
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
|
@ -416,7 +416,7 @@ Second is to sign app executable and a whole app bundle. It should contain all a
|
|||
|
||||
Also here is some optional parameters your app can need:
|
||||
|
||||
```text
|
||||
```xml
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
|
@ -505,7 +505,7 @@ When upload succeeds - you will see your package in App Store Connect.
|
|||
|
||||
This means that your application most likely does not specify a menu. On startup, Avalonia creates the default menu items for an application and automatically adds the _About Avalonia_ item when no menu has been configured. This can be resolved by adding one to your `App.xaml`:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:RoadCaptain.App.RouteBuilder"
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
To start hacking with Avalonia, install templates for it
|
||||
|
||||
```
|
||||
```bash
|
||||
dotnet new -i Avalonia.Templates
|
||||
```
|
||||
|
||||
Then create new application
|
||||
|
||||
```
|
||||
```bash
|
||||
dotnet new avalonia.app -o MyApp
|
||||
cd MyApp
|
||||
dotnet run
|
||||
|
|
|
@ -10,7 +10,7 @@ We recommend to log exceptions to the console, a file or anywhere else. There ar
|
|||
|
||||
You can catch any exception from the main thread, which is also the UI thread in Avalonia, in your `Program.cs`-file. To do so we just wrap the entire `void Main` in a `try` and `catch` block. In the `catch` block you can log the error, inform the user, send the log file or restart the application.
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
// File: Program.cs
|
||||
|
||||
public static void Main(string[] args)
|
||||
|
|
|
@ -6,7 +6,7 @@ Platforms are not created equal. The lifetime management that we are used to in
|
|||
|
||||
The preferred way of initializing your application on desktop is:
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
class Program
|
||||
{
|
||||
// This method is needed for IDE previewer infrastructure
|
||||
|
@ -23,7 +23,7 @@ class Program
|
|||
|
||||
So, where is the main window setup? It's now moved to Application class:
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
|
@ -78,7 +78,7 @@ We don't force you to use our lifetime model on platforms that allow us to do so
|
|||
|
||||
More docs will come later, for now see: [Issue #2564](https://github.com/AvaloniaUI/Avalonia/issues/2564) and [PR 2676](https://github.com/AvaloniaUI/Avalonia/pull/2676)
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
class Program
|
||||
{
|
||||
// This method is needed for IDE previewer infrastructure
|
||||
|
|
|
@ -34,7 +34,7 @@ To open the DevTools, press F12, or pass a different `Gesture` to the `this.Atta
|
|||
{% hint style="info" %}
|
||||
From release 0.10 to use DevTools, you must add `Avalonia.Diagnostics` nuget package.
|
||||
|
||||
```
|
||||
```bash
|
||||
dotnet add package Avalonia.Diagnostics --version 0.10.0
|
||||
```
|
||||
{% endhint %}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
The output will look similar to this.
|
||||
|
||||
```text
|
||||
```bash
|
||||
$ dotnet new -i Avalonia.Templates
|
||||
Determining projects to restore...
|
||||
Restored /Users/danwalmsley/.templateengine/dotnetcli/v5.0.200/scratch/restore.csproj (in 706 ms).
|
||||
|
|
|
@ -21,7 +21,7 @@ You can create `UserControl`s from templates:
|
|||
|
||||
Run this command replacing `[namespace]` with the namespace you'd like to create the `UserControl` in and `[name]` with the name of the control.
|
||||
|
||||
```text
|
||||
```bash
|
||||
dotnet new avalonia.usercontrol -na [namespace] -n [name]
|
||||
```
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ The default application templates create a single `Window` called `MainWindow`.
|
|||
|
||||
Run this command replacing `[namespace]` with the namespace you'd like to create the window in and `[name]` with the name of the window.
|
||||
|
||||
```text
|
||||
```bash
|
||||
dotnet new avalonia.window -na [namespace] -n [name]
|
||||
```
|
||||
|
||||
|
|
|
@ -112,9 +112,9 @@ Other pseudoclasses include `:focus`, `:disabled`, `:pressed` for buttons, `:che
|
|||
|
||||
You can create own pseudoclasses for your `CustomControl` or `TemplatedControl`.
|
||||
The function below adds or remove a pseudoclass depending on a boolean value on a `StyledElement`.
|
||||
````csharp
|
||||
PseudoClasses.Set(":className", bool);
|
||||
````
|
||||
```csharp
|
||||
PseudoClasses.Set(":className", bool);
|
||||
```
|
||||
***Remember:** PseudoClasses always starts with a `:`!*
|
||||
|
||||
### Selectors <a id="selectors"></a>
|
||||
|
|
|
@ -13,7 +13,7 @@ Avalonia selectors, like CSS selectors, do not raise any errors or warnings, whe
|
|||
Styles are applied in order of declaration. If there are **multiple** style files that target the same control property, one style can override the other:
|
||||
|
||||
{% code title="Styles2.axaml" %}
|
||||
```xml
|
||||
```markup
|
||||
<Style Selector="TextBlock.header">
|
||||
<Style Property="Foreground" Value="Green" />
|
||||
</Style>
|
||||
|
@ -21,7 +21,7 @@ Styles are applied in order of declaration. If there are **multiple** style file
|
|||
{% endcode %}
|
||||
|
||||
{% code title="Styles1.axaml" %}
|
||||
```xml
|
||||
```markup
|
||||
<Style Selector="TextBlock.header">
|
||||
<Style Property="Foreground" Value="Blue" />
|
||||
<Style Property="FontSize" Value="16" />
|
||||
|
@ -30,7 +30,7 @@ Styles are applied in order of declaration. If there are **multiple** style file
|
|||
{% endcode %}
|
||||
|
||||
{% code title="App.axaml" %}
|
||||
```xml
|
||||
```markup
|
||||
<StyleInclude Source="Style1.axaml" />
|
||||
<StyleInclude Source="Style2.axaml" />
|
||||
```
|
||||
|
@ -44,7 +44,7 @@ Similarly, to WPF, Avalonia properties can have multiple values, often of differ
|
|||
|
||||
In this example you can see that local value (defined directly on the control) has higher priority than style value, so text block will have red foreground:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<TextBlock Classes="header" Foreground="Red" />
|
||||
...
|
||||
<Style Selector="TextBlock.header">
|
||||
|
@ -62,7 +62,7 @@ Some default Avalonia styles use local values in their templates instead of temp
|
|||
|
||||
Let's imagine a situation in which you might expect a second style to override previous one, but it doesn't:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Style Selector="Border:pointerover">
|
||||
<Setter Property="Background" Value="Blue" />
|
||||
</Style>
|
||||
|
@ -87,7 +87,7 @@ Visit the Avalonia source code to find the [original templates](https://github.c
|
|||
|
||||
The following code example of styles that can be expected to work on top of default styles:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Style Selector="Button">
|
||||
<Setter Property="Background" Value="Red" />
|
||||
</Style>
|
||||
|
@ -100,7 +100,7 @@ You might expect the `Button` to be red by default and blue when pointer is over
|
|||
|
||||
The reason is hidden in the Button's template. You can find the default templates in the Avalonia source code (old [Default](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Default/Button.xaml) theme and new [Fluent](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Button.xaml) theme), but for convenience here we have simplified one from the Fluent theme:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<Style Selector="Button">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonBackground}"/>
|
||||
<Setter Property="Template">
|
||||
|
@ -118,7 +118,7 @@ The reason is hidden in the Button's template. You can find the default template
|
|||
|
||||
The actual background is rendered by a `ContentPresenter`, which in the default is bound to the Buttons `Background` property. However in the pointer-over state the selector is directly applying the background to the `ContentPresenter (Button:pointerover /template/ ContentPresenter#PART_ContentPresenter`) That's why when our setter was ignored in the previous code example. The corrected code should target content presenter directly as well:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- Here #PART_ContentPresenter name selector is not necessary, but was added to have more specific style -->
|
||||
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Background" Value="Blue" />
|
||||
|
|
|
@ -32,7 +32,7 @@ public class MyDataTemplate : IDataTemplate
|
|||
|
||||
You can now use the class `MyDataTemplate` in your view like this:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- remember to add the needed prefix in your view -->
|
||||
<!-- xmlns:dataTemplates="using:MyApp.DataTemplates" -->
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class ShapesTemplateSelector : IDataTemplate
|
|||
|
||||
Now we will setup the `ShapesTemplateSelector` in the `DataTemplates`-section of our `App.axaml`:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- remember to add the needed prefix in your view -->
|
||||
<!-- xmlns:dataTemplates="using:MyApp.DataTemplates" -->
|
||||
<!-- xmlns:model="using:MyApp.Model" -->
|
||||
|
@ -138,7 +138,7 @@ Now we will setup the `ShapesTemplateSelector` in the `DataTemplates`-section of
|
|||
|
||||
Now we can will create a `ComboBox` which the user can use to select a `ShapeType`:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<!-- remember to add the needed prefix in your view -->
|
||||
<!-- xmlns:model="using:MyApp.Model" -->
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ In the below example we have a `TextBlock` which shows the result and a `Button`
|
|||
|
||||
Our view looks like this:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<StackPanel>
|
||||
<TextBlock x:Name="TextBlock_Result" />
|
||||
<Button Content="Run long running process" Click="Button_OnClick" />
|
||||
|
@ -25,7 +25,7 @@ Our view looks like this:
|
|||
|
||||
The long running task looks like this:
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
async Task LongRunningTask()
|
||||
{
|
||||
// Do some work
|
||||
|
@ -37,7 +37,7 @@ async Task LongRunningTask()
|
|||
|
||||
Finally we can run the long running task as shown below:
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
private void Button_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Start the job and return immediately
|
||||
|
@ -47,7 +47,7 @@ private void Button_OnClick(object sender, RoutedEventArgs e)
|
|||
|
||||
if we want to get the result to work with it further, we need to change the long running task to return the result:
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
async Task<string> LongRunningTask()
|
||||
{
|
||||
// Do some work
|
||||
|
@ -62,7 +62,7 @@ async Task<string> LongRunningTask()
|
|||
|
||||
We can use the result now:
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
private async void Button_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Run the job
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
You can debug the XAML compiler adding at your's csproj AvaloniaXamlIlDebuggerLaunch property like this:
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
|
|
@ -27,7 +27,7 @@ In certain situations you need to run an Avalonia sample application as an app b
|
|||
|
||||
A solution to this is to change the sample's output path to [resemble an app bundle](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html). You can do this by modifying the output path in the csproj, e.g.:
|
||||
|
||||
```text
|
||||
```markup
|
||||
<OutputPath>bin\$(Configuration)\$(Platform)\ControlCatalog.NetCore.app/Contents/MacOS</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<UseAppHost>true</UseAppHost>
|
||||
|
|
|
@ -6,7 +6,7 @@ First it is very important to install the correct [dotnet SDK](https://dotnet.mi
|
|||
|
||||
### Install the Workload
|
||||
|
||||
```
|
||||
```bash
|
||||
dotnet workload install android
|
||||
```
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ If successful you may return to your IDE of choice and open the `info.plist` fil
|
|||
|
||||
12\. Now edit the `.iOS.csproj` file.
|
||||
|
||||
```xml
|
||||
```markup
|
||||
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
|
||||
<CodesignKey>Apple Development: dan@walms.co.uk (3L323F7VSS)</CodesignKey>
|
||||
```
|
||||
|
|
|
@ -16,20 +16,20 @@ dotnet new -i avalonia.templates
|
|||
|
||||
3. Create a new directory for the project.
|
||||
|
||||
```
|
||||
```bash
|
||||
mkdir WebTest
|
||||
cd WebTest
|
||||
```
|
||||
|
||||
4. Generate a new project that supports running in the browser.
|
||||
|
||||
```
|
||||
```bash
|
||||
dotnet new avalonia.xplat
|
||||
```
|
||||
|
||||
5. In order to run simply do:
|
||||
|
||||
```
|
||||
```bash
|
||||
cd WebTest.Web
|
||||
dotnet run
|
||||
```
|
||||
|
|
|
@ -147,7 +147,7 @@ Next we add another panel: a `StackPanel`. `StackPanel` lays out its child contr
|
|||
|
||||
Because this is the last child in the `DockPanel` it will fill the remaining space in the center of the control.
|
||||
|
||||
```
|
||||
```markup
|
||||
<CheckBox Margin="4">Walk the dog</CheckBox>
|
||||
<CheckBox Margin="4">Buy some milk</CheckBox>
|
||||
```
|
||||
|
|
Загрузка…
Ссылка в новой задаче