IconTintColorBehavior
behavior
이미지를 IconTintColorBehavior
착색할 수 있는 것입니다.
Important
동작을 공유하고 스타일을 통해 여러 컨트롤에 적용할 수 있으므로 .NET MAUI 커뮤니티 도구 키트 동작은 동작을 설정 BindingContext
하지 않습니다. 자세한 내용은 .NET MAUI 동작을 참조 하세요.
구문
XAML
XAML 네임스페이스 포함
XAML에서 도구 키트를 사용하려면 페이지 또는 보기에 다음 xmlns
을 추가해야 합니다.
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
따라서 다음을 수행합니다.
<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>
다음과 같이 포함 xmlns
하도록 수정됩니다.
<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>
IconTintColorBehavior 사용
XAML IconTintColorBehavior
에서 다음과 같이 사용할 수 있습니다.
<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>
C#
IconTintColorBehavior
C#에서 다음과 같이 사용할 수 있습니다.
class IconTintColorBehaviorPage : ContentPage
{
public IconTintColorBehaviorPage()
{
var image = new Image();
var behavior = new IconTintColorBehavior
{
TintColor = Color.Red
};
image.Behaviors.Add(behavior);
Content = image;
}
}
C# 태그
이 CommunityToolkit.Maui.Markup
패키지는 C#에서 이를 Behavior
사용하는 훨씬 더 간결한 방법을 제공합니다.
using CommunityToolkit.Maui.Markup;
class IconTintColorBehaviorPage : ContentPage
{
public IconTintColorBehaviorPage()
{
Content = new Image()
.Behaviors(new IconTintColorBehavior
{
TintColor = Color.Red
});
}
}
속성
속성 | Type | 설명 |
---|---|---|
TintColor | Color | Color Microsoft.Maui.Graphics 네임스페이스의 이름입니다. |
예제
.NET MAUI 커뮤니티 도구 키트 샘플 애플리케이션에서 이 동작의 예를 찾을 수 있습니다.
API
.NET MAUI 커뮤니티 도구 키트 GitHub 리포지토리에서 오버에 대한 IconTintColorBehavior
소스 코드를 찾을 수 있습니다.
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET MAUI Community Toolkit
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기