Skip to content

Commit 74f99c8

Browse files
committed
Sample app for .NET MAUI RatingView control
1 parent 433e1c2 commit 74f99c8

37 files changed

+1307
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Made available in the `src\NET_9\` directory:
1919
|`HybridWebViewApp`|A sample app showcasing the features of the new [HybridWebView](https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0#hybridwebview) control. <br /> Refer to this [Exploring .NET MAUI 9: HybridWebView](https://egvijayanand.in/2024/10/04/exploring-dotnet-maui-9-hybridwebview-features/) article for working with this sample|
2020
|`WinUIBlazor`|.NET MAUI `BlazorWebView` embedded in a Native WinUI 3 App, making it as a Blazor Hybrid app <br /> Refer to this [.NET MAUI - Blazor Hybrid - WinUI 3](https://egvijayanand.in/2023/03/29/dotnet-maui-blazor-hybrid-winui-3/) article for working with this sample|
2121
|`TitleBarApp`|A sample app showcasing the features of the new [TitleBar](https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0#titlebar-for-windows) control. <br /> Refer to this [What's New in .NET MAUI 9: Window TitleBar](https://egvijayanand.in/2024/12/04/what-is-new-in-dotnet-maui-9-window-titlebar/) article for working with this sample|
22+
|`RatingApp`|A sample app showcasing the features of the new [RatingView](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/views/ratingview) control. <br /> Refer to this [Exploring the New RatingView Control in .NET MAUI Community Toolkit v11.2](https://egvijayanand.in/2025/03/28/exploring-the-new-ratingview-control-in-dotnet-maui-community-toolkit-v11/?utm_campaign=branding&utm_source=github&utm_medium=samples) article for working with this sample|
2223

2324
### .NET MAUI 8 Samples
2425

src/NET_9/RatingApp/App.xaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Application
3+
x:Class="RatingApp.App"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
9+
xmlns:local="clr-namespace:RatingApp"
10+
mc:Ignorable="d">
11+
<Application.Resources>
12+
<ResourceDictionary>
13+
<ResourceDictionary.MergedDictionaries>
14+
<ResourceDictionary Source="Resources/Colors.xaml" />
15+
<ResourceDictionary Source="Resources/Styles.xaml" />
16+
</ResourceDictionary.MergedDictionaries>
17+
<!-- Additional Styles -->
18+
<x:Double x:Key="ItemSpacing">10</x:Double>
19+
20+
<Style ApplyToDerivedTypes="True" TargetType="StackBase">
21+
<Setter Property="Spacing"
22+
Value="{StaticResource ItemSpacing}" />
23+
</Style>
24+
25+
<Style x:Key="MauiLabel" TargetType="Label">
26+
<Setter Property="TextColor"
27+
Value="{AppThemeBinding Dark={StaticResource White}, Light={StaticResource Primary}}" />
28+
</Style>
29+
30+
<Style x:Key="Action" TargetType="Button">
31+
<Setter Property="BackgroundColor"
32+
Value="{AppThemeBinding Dark={StaticResource BackgroundDark}, Light={StaticResource BackgroundLight}}" />
33+
<Setter Property="TextColor"
34+
Value="{AppThemeBinding Dark={StaticResource TextDark}, Light={StaticResource TextLight}}" />
35+
<Setter Property="FontFamily"
36+
Value="{StaticResource AppFont}" />
37+
<Setter Property="FontSize"
38+
Value="{StaticResource AppFontSize}" />
39+
<Setter Property="Padding"
40+
Value="14,10" />
41+
</Style>
42+
43+
<Style x:Key="PrimaryAction"
44+
TargetType="Button"
45+
BasedOn="{StaticResource Action}">
46+
<Setter Property="BackgroundColor"
47+
Value="{StaticResource Primary}" />
48+
<Setter Property="FontAttributes"
49+
Value="Bold" />
50+
<Setter Property="TextColor"
51+
Value="{StaticResource White}" />
52+
</Style>
53+
</ResourceDictionary>
54+
</Application.Resources>
55+
</Application>

src/NET_9/RatingApp/App.xaml.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace RatingApp;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
UserAppTheme = PlatformAppTheme;
10+
}
11+
12+
protected override Window CreateWindow(IActivationState? activationState)
13+
=> new()
14+
{
15+
Page = new MainPage(),
16+
Title = "RatingApp"
17+
};
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<MauiVersion>9.0.50</MauiVersion>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageVersion Include="CommunityToolkit.Maui" Version="11.2.0" />
8+
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.3" Condition="'$(Configuration)' == 'Debug'" />
9+
<PackageVersion Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
10+
</ItemGroup>
11+
</Project>

src/NET_9/RatingApp/Imports.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// .NET MAUI Toolkit
2+
global using CommunityToolkit.Maui;
3+
global using CommunityToolkit.Maui.Behaviors;
4+
global using CommunityToolkit.Maui.Converters;
5+
global using CommunityToolkit.Maui.Views;
6+
7+
global using RatingApp;
8+
global using RatingApp.Views;
9+
10+
// Static
11+
//global using static Microsoft.Maui.Graphics.Colors;

src/NET_9/RatingApp/MauiProgram.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Microsoft.Extensions.Logging;
2+
3+
namespace RatingApp;
4+
5+
public static partial class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder.UseMauiApp<App>()
11+
.UseMauiCommunityToolkit()
12+
.ConfigureFonts(fonts =>
13+
{
14+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
15+
fonts.AddFont("OpenSans-SemiBold.ttf", "OpenSansSemiBold");
16+
});
17+
18+
#if DEBUG
19+
builder.Logging.AddDebug();
20+
#endif
21+
22+
return builder.Build();
23+
}
24+
25+
#if BCL
26+
// To resolve the warning when BCL is included in the TFMs.
27+
public static MauiAppBuilder UseMauiCommunityToolkit(this MauiAppBuilder bindable) => bindable;
28+
#endif
29+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35" />
4+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace RatingApp
6+
{
7+
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
8+
public class MainActivity : MauiAppCompatActivity
9+
{
10+
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace RatingApp
5+
{
6+
[Application]
7+
public class MainApplication : MauiApplication
8+
{
9+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10+
: base(handle, ownership)
11+
{
12+
}
13+
14+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15+
}
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<resources>
3+
<color name="colorPrimary">#512BD4</color>
4+
<color name="colorPrimaryDark">#2B0B98</color>
5+
<color name="colorAccent">#2B0B98</color>
6+
</resources>

0 commit comments

Comments
 (0)