HelloMauiToolkit
1.0.0
.NET MAUI コミュニティ ツールキットは、.NET MAUI を使用した開発のための共通要素のコレクションであり、開発者はこれらを複数のアプリ間で複製する傾向があります。 .NET MAUI を使用してアプリを構築する際の一般的な開発者のタスクを簡略化し、デモンストレーションします。
この特定の例ではColorToHexRgbStringConverterを使用します。
UseMauiCommunityToolkit()を追加.NET MAUI Community Toolkit を使用するには、次のようにMauiProgram.csファイル内の拡張メソッドを呼び出す必要があります。
using CommunityToolkit . Maui ;
public static class MauiProgram
{
public static MauiApp CreateMauiApp ( )
{
var builder = MauiApp . CreateBuilder ( ) ;
// Initialise the toolkit
builder . UseMauiApp < App > ( ) . UseMauiCommunityToolkit ( ) ;
// the rest of your logic...
}
} XAML ファイルの先頭に、次のxmlnsを追加します。
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"ColorToHexRgbStringConverterを使用するBindingでConverter={converters:ColorToHexRgbStringConverter}を割り当てます。
Text="{Binding Source={x:Reference ClickMeButton}, Path=BackgroundColor, Converter={toolkit:ColorToHexRgbStringConverter}}