DisplayMemberName isn't trim safe (#2553)

* DisplayMemberName isn't trim safe.

* Edits.

* Fix link.

* Fix link.

* Version new content.

* Edit.
This commit is contained in:
David Britch 2024-10-08 15:12:36 +01:00 коммит произвёл GitHub
Родитель 6d04b5d6f1
Коммит aad6128966
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -1,7 +1,7 @@
--- ---
title: ".NET MAUI Shell search" title: ".NET MAUI Shell search"
description: "Learn how .NET MAUI Shell apps can use integrated search functionality that's provided by a search box that can be added to the top of each page." description: "Learn how .NET MAUI Shell apps can use integrated search functionality that's provided by a search box that can be added to the top of each page."
ms.date: 08/30/2024 ms.date: 10/30/2024
--- ---
# .NET MAUI Shell search # .NET MAUI Shell search
@ -99,6 +99,13 @@ Shell.SetSearchHandler(this, new AnimalSearchHandler
The `AnimalSearchHandler.OnQueryChanged` method returns a `List` of `Animal` objects. The `DisplayMemberName` property is set to the `Name` property of each `Animal` object, and so the data displayed in the suggestions area will be each animal name. The `AnimalSearchHandler.OnQueryChanged` method returns a `List` of `Animal` objects. The `DisplayMemberName` property is set to the `Name` property of each `Animal` object, and so the data displayed in the suggestions area will be each animal name.
::: moniker range=">=net-maui-9.0"
> [!WARNING]
> `SearchHandler.DisplayMemberName` isn't trim safe and shouldn't be used with full trimming or NativeAOT. Instead, you should provide an `ItemTemplate` to define the appearance of `SearchHandler` results. For more information, see [Define search results item appearance](#define-search-results-item-appearance).
::: moniker-end
The `ShowsResults` property is set to `true`, so that search suggestions are displayed as the user enters a search query: The `ShowsResults` property is set to `true`, so that search suggestions are displayed as the user enters a search query:
:::image type="content" source="media/search/search-results.png" alt-text="Screenshot of search results in a Shell SearchHandler, with results for the partial string M."::: :::image type="content" source="media/search/search-results.png" alt-text="Screenshot of search results in a Shell SearchHandler, with results for the partial string M.":::

Просмотреть файл

@ -429,6 +429,10 @@ dotnet new maui-blazor-web -n AllTheTargets
In .NET MAUI 9, a stand-alone XAML <xref:Microsoft.Maui.Controls.ResourceDictionary> (which isn't backed by a code-behind file) defaults to having its XAML compiled. To opt out of this behavior, specify `<?xaml-comp compile="false" ?>` after the XML header. In .NET MAUI 9, a stand-alone XAML <xref:Microsoft.Maui.Controls.ResourceDictionary> (which isn't backed by a code-behind file) defaults to having its XAML compiled. To opt out of this behavior, specify `<?xaml-comp compile="false" ?>` after the XML header.
## Shell apps
`SearchHandler.DisplayMemberName` isn't trim safe and shouldn't be used with full trimming or NativeAOT. Instead, you should provide an `ItemTemplate` to define the appearance of `SearchHandler` results. For more information, see [Define search results item appearance](~/fundamentals/shell/search.md#define-search-results-item-appearance).
## Trimming feature switches ## Trimming feature switches
Several areas of .NET MAUI come with trimmer directives, known as feature switches, that make it possible to remove the code for disabled features when `TrimMode=full`, as well as for NativeAOT: Several areas of .NET MAUI come with trimmer directives, known as feature switches, that make it possible to remove the code for disabled features when `TrimMode=full`, as well as for NativeAOT: