Skip to content

Commit ce3fdfa

Browse files
authored
Merge pull request #1 from NirmalKumarYuvaraj/main
MAUI-1574:How to apply item text color in .NET MAUI ListView
2 parents ec4a1f4 + a1c48b6 commit ce3fdfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+950
-0
lines changed

ListViewMaui.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListViewMaui", "ListViewMaui\ListViewMaui.csproj", "{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{57EFD801-7E6A-4E1B-8D51-C72BBD6D88D7}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26+
EndGlobalSection
27+
EndGlobal

ListViewMaui/App.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3+
xmlns:local="clr-namespace:ListViewMaui"
4+
x:Class="ListViewMaui.App">
5+
<Application.Resources>
6+
<ResourceDictionary>
7+
8+
<Color x:Key="PrimaryColor">#512bdf</Color>
9+
<Color x:Key="SecondaryColor">White</Color>
10+
11+
<Style TargetType="Label">
12+
<Setter Property="TextColor" Value="{DynamicResource PrimaryColor}" />
13+
<Setter Property="FontFamily" Value="OpenSansRegular" />
14+
</Style>
15+
16+
<Style TargetType="Button">
17+
<Setter Property="TextColor" Value="{DynamicResource SecondaryColor}" />
18+
<Setter Property="FontFamily" Value="OpenSansRegular" />
19+
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}" />
20+
<Setter Property="Padding" Value="14,10" />
21+
</Style>
22+
23+
</ResourceDictionary>
24+
</Application.Resources>
25+
</Application>

ListViewMaui/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace ListViewMaui;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new MainPage();
10+
}
11+
}

ListViewMaui/Helper/Converter.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Globalization;
2+
3+
namespace ListViewMaui
4+
{
5+
public class ColorConverter : IValueConverter
6+
{
7+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
8+
{
9+
if (value == null)
10+
return false;
11+
var itemdata = value as Contacts;
12+
if (itemdata.ContactType == "HOME")
13+
return Colors.RoyalBlue;
14+
else if (itemdata.ContactType == "WORK")
15+
return Colors.PaleGreen;
16+
else if (itemdata.ContactType == "MOBILE")
17+
return Colors.HotPink;
18+
else if (itemdata.ContactType == "OTHER")
19+
return Colors.DarkGoldenrod;
20+
else
21+
return Colors.BlueViolet;
22+
}
23+
24+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25+
{
26+
throw new NotImplementedException();
27+
}
28+
}
29+
}

ListViewMaui/Images/Image0.png

56.3 KB

ListViewMaui/Images/Image1.png

66.6 KB

ListViewMaui/Images/Image10.png

52.8 KB

ListViewMaui/Images/Image11.png

62.7 KB

ListViewMaui/Images/Image12.png

58.3 KB

ListViewMaui/Images/Image13.png

56.1 KB

0 commit comments

Comments
 (0)