### Install MauiEx NuGet Package
Source: https://github.com/dotmorten/mauiex/blob/main/MauiEx/readme.md
Installs the dotMorten.MauiEx NuGet package using the Package Manager Console.
```powershell
Install-Package dotMorten.MauiEx
```
--------------------------------
### AutoSuggestBox XAML Setup
Source: https://github.com/dotmorten/mauiex/blob/main/MauiEx/readme.md
Defines an AutoSuggestBox in XAML with event handlers for text changes, suggestion choices, and query submissions. Set the PlaceholderText and WidthRequest for basic configuration.
```xml
```
--------------------------------
### Accessing Raw Assets at Runtime
Source: https://github.com/dotmorten/mauiex/blob/main/SampleApp/Resources/Raw/AboutAssets.txt
This C# code demonstrates how to open and read the contents of a raw asset file that has been deployed with your application package. Ensure the file exists in the specified path.
```csharp
async Task LoadMauiAsset()
{
using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
using var reader = new StreamReader(stream);
var contents = reader.ReadToEnd();
}
```
--------------------------------
### Include Raw Assets in .csproj
Source: https://github.com/dotmorten/mauiex/blob/main/SampleApp/Resources/Raw/AboutAssets.txt
This XML snippet shows how to configure the MauiAsset build action in your .csproj file to include all files in the Resources/Raw directory and its subdirectories as deployable assets.
```xml
```
--------------------------------
### Register MauiEx Controls
Source: https://github.com/dotmorten/mauiex/blob/main/README.md
Register the MauiEx control library in your MauiProgram.CreateMauiApp method. Ensure you include the necessary using statement.
```csharp
using MauiEx; // Include using to get extension method
namespace SampleApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseMauiEx(); //Register control library
return builder.Build();
}
}
```
--------------------------------
### AutoSuggestBox C# Event Handlers
Source: https://github.com/dotmorten/mauiex/blob/main/MauiEx/readme.md
Provides C# event handlers for AutoSuggestBox. The TextChanged handler filters data based on user input. SuggestionChosen allows custom text population. QuerySubmitted handles user actions after a query.
```csharp
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
// Only get results when it was a user typing,
// otherwise assume the value got filled in by TextMemberPath
// or the handler for SuggestionChosen.
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
{
//Set the ItemsSource to be your filtered dataset
//sender.ItemsSource = dataset;
}
}
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
// Set sender.Text. You can use args.SelectedItem to build your text string.
}
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
if (args.ChosenSuggestion != null)
{
// User selected an item from the suggestion list, take an action on it here.
}
else
{
// User hit Enter from the search box. Use args.QueryText to determine what to do.
}
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.