Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
egress-policy: audit

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
# - name: Setup .NET
# uses: actions/setup-dotnet@4d4a70f4a5b2a5a5329f13be4ac933f2c9206ac0
# with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
with:
egress-policy: audit

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: DavidAnson/markdownlint-cli2-action@992badcdf24e3b8eb7e87ff9287fe931bcb00c6e # v20.0.0
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- uses: DavidAnson/markdownlint-cli2-action@30a0e04f1870d58f8d717450cc6134995f993c63 # v21.0.0
with:
config: ".markdownlint-cli2.jsonc"
globs: "**/*.md"
3 changes: 2 additions & 1 deletion .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"MD050": {
"style": "asterisk"
},
"MD051": false
"MD051": false,
"MD060": false
},
"ignores": [
".github/",
Expand Down
2 changes: 1 addition & 1 deletion docs/data-cloud/aspire-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static class MauiProgram
});

// Add service defaults
builder.Services.AddServiceDefaults();
builder.AddServiceDefaults();

// Configure HTTP client with service discovery
builder.Services.AddHttpClient<WeatherApiClient>(client =>
Expand Down
2 changes: 1 addition & 1 deletion docs/fundamentals/bindable-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static bool IsValidValue(BindableObject view, object value)
}
```

Validation callbacks are provided with a value, and should return `true` if the value is valid for the property, otherwise `false`. An exception will be raised if a validation callback returns `false`, which you should handle. A typical use of a validation callback method is constraining the values of integers or doubles when the bindable property is set. For example, the `IsValidValue` method checks that the property value is a `double` within the range 0 to 360.
Validation callbacks are provided with a value, and should return `true` if the value is valid for the property, otherwise `false`. A typical use of a validation callback method is constraining the values of integers or doubles when the bindable property is set. For example, the `IsValidValue` method checks that the property value is a `double` within the range 0 to 360.

### Coerce value callbacks

Expand Down
9 changes: 6 additions & 3 deletions docs/fundamentals/data-binding/commanding.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ When the user presses the <xref:Microsoft.Maui.Controls.Button>, the <xref:Micro

When the binding is first defined on the `Command` property of the <xref:Microsoft.Maui.Controls.Button>, and when the data binding changes in some way, the <xref:Microsoft.Maui.Controls.Button> calls the `CanExecute` method in the <xref:System.Windows.Input.ICommand> object. If `CanExecute` returns `false`, then the <xref:Microsoft.Maui.Controls.Button> disables itself. This indicates that the particular command is currently unavailable or invalid.

The <xref:Microsoft.Maui.Controls.Button> also attaches a handler on the `CanExecuteChanged` event of <xref:System.Windows.Input.ICommand>. The event is raised from within the viewmodel. When that event is raised, the <xref:Microsoft.Maui.Controls.Button> calls `CanExecute` again. The <xref:Microsoft.Maui.Controls.Button> enables itself if `CanExecute` returns `true` and disables itself if `CanExecute` returns `false`.
The <xref:Microsoft.Maui.Controls.Button> also attaches a handler on the `CanExecuteChanged` event of <xref:System.Windows.Input.ICommand>. The event must be raised manually from within the viewmodel whenever conditions change that affect the `CanExecute` result. When that event is raised, the <xref:Microsoft.Maui.Controls.Button> calls `CanExecute` again. The <xref:Microsoft.Maui.Controls.Button> enables itself if `CanExecute` returns `true` and disables itself if `CanExecute` returns `false`.

> [!IMPORTANT]
> Unlike some UI frameworks (such as WPF), .NET MAUI does not automatically detect when the return value of `CanExecute` might change. You must manually raise the `CanExecuteChanged` event (or call `ChangeCanExecute()` on the `Command` class) whenever any condition changes that would affect the `CanExecute` result. This is typically done when properties that `CanExecute` depends on are modified.

> [!NOTE]
> You can also use the `IsEnabled` property of <xref:Microsoft.Maui.Controls.Button> instead of the `CanExecute` method, or in conjunction with it. In .NET MAUI 7 and earlier, it was not possible to use the `IsEnabled` property of <xref:Microsoft.Maui.Controls.Button> while using the command interface, as the `CanExecute` method's return value always overwrote the `IsEnabled` property. This is fixed in .NET MAUI 8 and above; the `IsEnabled` property is now usable on command-based <xref:Microsoft.Maui.Controls.Button>s. However, be aware that the `IsEnabled` property and the `CanExecute` method now must *both* return true in order for the <xref:Microsoft.Maui.Controls.Button> to be enabled (and the parent control must be enabled as well).

When your viewmodel defines a property of type <xref:System.Windows.Input.ICommand>, the viewmodel must also contain or reference a class that implements the <xref:System.Windows.Input.ICommand> interface. This class must contain or reference the `Execute` and `CanExecute` methods, and fire the `CanExecuteChanged` event whenever the `CanExecute` method might return a different value. You can use the `Command` or `Command<T>` class included in .NET MAUI to implement the <xref:System.Windows.Input.ICommand> interface. These classes allow you to specify the bodies of the `Execute` and `CanExecute` methods in class constructors.
When your viewmodel defines a property of type <xref:System.Windows.Input.ICommand>, the viewmodel must also contain or reference a class that implements the <xref:System.Windows.Input.ICommand> interface. This class must contain or reference the `Execute` and `CanExecute` methods, and manually fire the `CanExecuteChanged` event whenever the `CanExecute` method might return a different value. You can use the `Command` or `Command<T>` class included in .NET MAUI to implement the <xref:System.Windows.Input.ICommand> interface. These classes allow you to specify the bodies of the `Execute` and `CanExecute` methods in class constructors.

> [!TIP]
> Use `Command<T>` when you use the `CommandParameter` property to distinguish between multiple views bound to the same <xref:System.Windows.Input.ICommand> property, and the `Command` class when that isn't a requirement.
Expand Down Expand Up @@ -296,7 +299,7 @@ public class PersonCollectionViewModel : INotifyPropertyChanged

When the user clicks the **New** button, the `execute` function passed to the `Command` constructor is executed. This creates a new `PersonViewModel` object, sets a handler on that object's `PropertyChanged` event, sets `IsEditing` to `true`, and calls the `RefreshCanExecutes` method defined after the constructor.

Besides implementing the <xref:System.Windows.Input.ICommand> interface, the `Command` class also defines a method named `ChangeCanExecute`. A viewmodel should call `ChangeCanExecute` for an <xref:System.Windows.Input.ICommand> property whenever anything happens that might change the return value of the `CanExecute` method. A call to `ChangeCanExecute` causes the `Command` class to fire the `CanExecuteChanged` method. The <xref:Microsoft.Maui.Controls.Button> has attached a handler for that event and responds by calling `CanExecute` again, and then enabling itself based on the return value of that method.
Besides implementing the <xref:System.Windows.Input.ICommand> interface, the `Command` class also defines a method named `ChangeCanExecute`. Your viewmodel must call `ChangeCanExecute` for an <xref:System.Windows.Input.ICommand> property whenever anything happens that might change the return value of the `CanExecute` method. A call to `ChangeCanExecute` causes the `Command` class to fire the `CanExecuteChanged` event. The <xref:Microsoft.Maui.Controls.Button> has attached a handler for that event and responds by calling `CanExecute` again, and then enabling itself based on the return value of that method.

When the `execute` method of `NewCommand` calls `RefreshCanExecutes`, the `NewCommand` property gets a call to `ChangeCanExecute`, and the <xref:Microsoft.Maui.Controls.Button> calls the `canExecute` method, which now returns `false` because the `IsEditing` property is now `true`.

Expand Down
8 changes: 3 additions & 5 deletions docs/tutorials/notes-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ The _AppShell.xaml_ defines two tabs, one for the `NotesPage` and another for `A
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Notes"
Shell.FlyoutBehavior="Disabled">
xmlns:local="clr-namespace:Notes">

<TabBar>
<ShellContent
Expand Down Expand Up @@ -382,8 +381,7 @@ The `local` XML namespace was used by the `ShellContent.ContentTemplate` propert
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Notes.Views"
Shell.FlyoutBehavior="Disabled">
xmlns:views="clr-namespace:Notes.Views">

<TabBar>
<ShellContent
Expand Down Expand Up @@ -568,7 +566,7 @@ The previous XAML introduces a few new concepts:

- The `ContentPage.ToolbarItems` property contains a `ToolbarItem`. The buttons defined here are usually display at the top of the app, along the page title. Depending on the platform, though, it might be in a different position. When one of these buttons is pressed, the `Clicked` event is raised, just like a normal button.

The `ToolbarItem.IconImageSource` property sets the icon to display on the button. The icon can be any image resource defined by the project, however, in this example, a `FontImage` is used. A `FontImage` can use a single glyph from a font as an image.
The `ToolbarItem.IconImageSource` property sets the icon to display on the button. The icon can be any image resource defined by the project, however, in this example, a `FontImageSource` is used. A `FontImageSource` can use a single glyph from a font as an image.

- The <xref:Microsoft.Maui.Controls.CollectionView> control displays a collection of items, and in this case, is bound to the model's `Notes` property. The way each item is presented by the collection view is set through the `CollectionView.ItemsLayout` and `CollectionView.ItemTemplate` properties.

Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/snippets/notes-app/allnotes/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Notes.Views"
Shell.FlyoutBehavior="Disabled">
xmlns:views="clr-namespace:Notes.Views">

<TabBar>
<ShellContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
x:DataType="models:AllNotes">
<!-- Add an item to the toolbar -->
<ContentPage.ToolbarItems>
<ToolbarItem Text="Add" Clicked="Add_Clicked" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" />
<ToolbarItem Text="Add" Clicked="Add_Clicked" IconImageSource="{FontImageSource Glyph='+', Color=Black, Size=22}" />
</ContentPage.ToolbarItems>

<!-- Display notes in a list -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Notes.Views"
Shell.FlyoutBehavior="Disabled">
xmlns:views="clr-namespace:Notes.Views">

<TabBar>
<ShellContent
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/snippets/notes-app/note/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Notes"
Shell.FlyoutBehavior="Disabled">
xmlns:local="clr-namespace:Notes">

<TabBar>
<ShellContent
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/snippets/notes-app/shell/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Notes"
Shell.FlyoutBehavior="Disabled">
xmlns:local="clr-namespace:Notes">

<TabBar>
<ShellContent
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/snippets/notes-mvvm/bugs/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Notes.Views"
Shell.FlyoutBehavior="Disabled">
xmlns:views="clr-namespace:Notes.Views">

<TabBar>
<ShellContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Add an item to the toolbar -->
<ContentPage.ToolbarItems>
<ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" />
<ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImageSource Glyph='+', Color=Black, Size=22}" />
</ContentPage.ToolbarItems>

<!-- Display notes in a list -->
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/snippets/notes-mvvm/model/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Notes.Views"
Shell.FlyoutBehavior="Disabled">
xmlns:views="clr-namespace:Notes.Views">

<TabBar>
<ShellContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Title="Your Notes">
<!-- Add an item to the toolbar -->
<ContentPage.ToolbarItems>
<ToolbarItem Text="Add" Clicked="Add_Clicked" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" />
<ToolbarItem Text="Add" Clicked="Add_Clicked" IconImageSource="{FontImageSource Glyph='+', Color=Black, Size=22}" />
</ContentPage.ToolbarItems>

<!-- Display notes in a list -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
x:Class="Notes.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Notes.Views"
Shell.FlyoutBehavior="Disabled">
xmlns:views="clr-namespace:Notes.Views">

<TabBar>
<ShellContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Add an item to the toolbar -->
<ContentPage.ToolbarItems>
<ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" />
<ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImageSource Glyph='+', Color=Black, Size=22}" />
</ContentPage.ToolbarItems>

<!-- Display notes in a list -->
Expand Down
3 changes: 3 additions & 0 deletions docs/user-interface/controls/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ Image image = new Image

The [`FontImage`](xref:Microsoft.Maui.Controls.Xaml.FontImageExtension) markup extension enables you to display a font icon in any view that can display an <xref:Microsoft.Maui.Controls.ImageSource>. It provides the same functionality as the <xref:Microsoft.Maui.Controls.FontImageSource> class, but with a more concise representation.

> [!NOTE]
> The `FontImage` markup extension is deprecated in .NET 10 and will be removed in a future release. Use <xref:Microsoft.Maui.Controls.FontImageSource> instead.

The [`FontImage`](xref:Microsoft.Maui.Controls.Xaml.FontImageExtension) markup extension is supported by the <xref:Microsoft.Maui.Controls.Xaml.FontImageExtension> class, which defines the following properties:

- `FontFamily` of type `string`, the font family to which the font icon belongs.
Expand Down
4 changes: 4 additions & 0 deletions docs/user-interface/fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,8 @@ The following screenshot shows several font icons being displayed:

:::image type="content" source="media/fonts/font-image-source.png" alt-text="Screenshot of three font icons.":::

::: moniker range=">=net-maui-8.0 <=net-maui-9.0"

Alternatively, you can display a font icon with the [`FontImage`](xref:Microsoft.Maui.Controls.Xaml.FontImageExtension) markup extension. For more information, see [Load a font icon](~/user-interface/controls/image.md#load-a-font-icon).

::: moniker-end
Loading
Loading