Evenementer
Mar 17, 9 PM - Mar 21, 10 AM
Maacht mat bei der Meetup-Serie, fir skaléierbar KI-Léisungen op Basis vu realistesche Benotzungsfäll mat aneren Entwéckler an Experten ze bauen.
Elo umellenDëse Browser gëtt net méi ënnerstëtzt.
Upgrat op Microsoft Edge fir vun de Virdeeler vun leschten Eegeschaften, Sécherheetsupdaten, an techneschem Support ze profitéieren.
The IconTintColorBehavior
is a behavior
that allows you to tint an image.
Wichteg
The .NET MAUI Community Toolkit Behaviors do not set the BindingContext
of a behavior, because behaviors can be shared and applied to multiple controls through styles. For more information refer to .NET MAUI Behaviors
In order to use the toolkit in XAML the following xmlns
needs to be added into your page or view:
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Therefore the following:
<ContentPage
x:Class="CommunityToolkit.Maui.Sample.Pages.MyPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
</ContentPage>
Would be modified to include the xmlns
as follows:
<ContentPage
x:Class="CommunityToolkit.Maui.Sample.Pages.MyPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
</ContentPage>
The IconTintColorBehavior
can be used as follows in XAML:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="MyLittleApp.MainPage">
<Image Source="shield.png">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" />
</Image.Behaviors>
</Image>
</ContentPage>
The IconTintColorBehavior
can be used as follows in C#:
class IconTintColorBehaviorPage : ContentPage
{
public IconTintColorBehaviorPage()
{
var image = new Image();
var behavior = new IconTintColorBehavior
{
TintColor = Color.Red
};
image.Behaviors.Add(behavior);
Content = image;
}
}
Our CommunityToolkit.Maui.Markup
package provides a much more concise way to use this Behavior
in C#.
using CommunityToolkit.Maui.Markup;
class IconTintColorBehaviorPage : ContentPage
{
public IconTintColorBehaviorPage()
{
Content = new Image()
.Behaviors(new IconTintColorBehavior
{
TintColor = Color.Red
});
}
}
Property | Type | Description |
---|---|---|
TintColor | Color | The Color name from the Microsoft.Maui.Graphics namespace. |
You can find an example of this behavior in action in the .NET MAUI Community Toolkit Sample Application.
You can find the source code for IconTintColorBehavior
over on the .NET MAUI Community Toolkit GitHub repository.
Feedback zu .NET MAUI Community Toolkit
.NET MAUI Community Toolkit ass en Open-Source-Projet. Wielt e Link, fir Feedback ze ginn:
Evenementer
Mar 17, 9 PM - Mar 21, 10 AM
Maacht mat bei der Meetup-Serie, fir skaléierbar KI-Léisungen op Basis vu realistesche Benotzungsfäll mat aneren Entwéckler an Experten ze bauen.
Elo umellenTraining
Modul
Design consistent .NET MAUI XAML pages by using shared resources - Training
Learn how to use static and dynamic shared resources to build a .NET Multi-platform App UI (MAUI) user interface. And see how styles can make the user interface both consistent and accessible.
Dokumentatioun
TouchBehavior - .NET MAUI Community Toolkit - Community Toolkits for .NET
The TouchBehavior is a Behavior that provides the ability to interact with any VisualElement based on touch, mouse click and hover events.
Fonts in .NET MAUI - .NET MAUI
This article explains how to specify font information on controls that display text in .NET MAUI apps.
StatusBarBehavior - .NET MAUI Community Toolkit - Community Toolkits for .NET
The StatusBarBehavior provides the ability to customize the color and style of a devices status bar.