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

+1
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

+55
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

+18
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+
}
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

+11
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

+29
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+
}
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>
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+
}
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+
}
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Foundation;
2+
3+
namespace RatingApp
4+
{
5+
[Register(nameof(AppDelegate))]
6+
public class AppDelegate : MauiUIApplicationDelegate
7+
{
8+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>UIDeviceFamily</key>
6+
<array>
7+
<integer>1</integer>
8+
<integer>2</integer>
9+
</array>
10+
<key>UIRequiredDeviceCapabilities</key>
11+
<array>
12+
<string>arm64</string>
13+
</array>
14+
<key>UISupportedInterfaceOrientations</key>
15+
<array>
16+
<string>UIInterfaceOrientationPortrait</string>
17+
<string>UIInterfaceOrientationLandscapeLeft</string>
18+
<string>UIInterfaceOrientationLandscapeRight</string>
19+
</array>
20+
<key>UISupportedInterfaceOrientations~ipad</key>
21+
<array>
22+
<string>UIInterfaceOrientationPortrait</string>
23+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
24+
<string>UIInterfaceOrientationLandscapeLeft</string>
25+
<string>UIInterfaceOrientationLandscapeRight</string>
26+
</array>
27+
<key>XSAppIconAssets</key>
28+
<string>Assets.xcassets/appicon.appiconset</string>
29+
</dict>
30+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyAccessedAPITypes</key>
6+
<array>
7+
<dict>
8+
<key>NSPrivacyAccessedAPIType</key>
9+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
10+
<key>NSPrivacyAccessedAPITypeReasons</key>
11+
<array>
12+
<string>C617.1</string>
13+
</array>
14+
</dict>
15+
<dict>
16+
<key>NSPrivacyAccessedAPIType</key>
17+
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
18+
<key>NSPrivacyAccessedAPITypeReasons</key>
19+
<array>
20+
<string>35F9.1</string>
21+
</array>
22+
</dict>
23+
<dict>
24+
<key>NSPrivacyAccessedAPIType</key>
25+
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
26+
<key>NSPrivacyAccessedAPITypeReasons</key>
27+
<array>
28+
<string>E174.1</string>
29+
</array>
30+
</dict>
31+
<!--
32+
The entry below is only needed when you're using the Preferences API in your app.
33+
<dict>
34+
<key>NSPrivacyAccessedAPIType</key>
35+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
36+
<key>NSPrivacyAccessedAPITypeReasons</key>
37+
<array>
38+
<string>CA92.1</string>
39+
</array>
40+
</dict> -->
41+
</array>
42+
</dict>
43+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using ObjCRuntime;
2+
using UIKit;
3+
4+
namespace RatingApp
5+
{
6+
public class Program
7+
{
8+
// This is the main entry point of the application.
9+
static void Main(string[] args)
10+
{
11+
// if you want to use a different Application Delegate class from "AppDelegate"
12+
// you can specify it here.
13+
UIApplication.Main(args, null, typeof(AppDelegate));
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using Microsoft.Maui;
3+
using Microsoft.Maui.Hosting;
4+
5+
namespace RatingApp
6+
{
7+
class Program : MauiApplication
8+
{
9+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
10+
11+
static void Main(string[] args)
12+
{
13+
var app = new Program();
14+
app.Run(args);
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest package="com.companyname.ratingapp" version="1.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
3+
<profile name="common" />
4+
<ui-application appid="com.companyname.ratingapp" exec="RatingApp.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
5+
<label>RatingApp</label>
6+
<icon>appicon.xhigh.png</icon>
7+
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
8+
</ui-application>
9+
<shortcut-list />
10+
<privileges>
11+
<privilege>http://tizen.org/privilege/internet</privilege>
12+
</privileges>
13+
<dependencies />
14+
<provides-appdefined-privileges />
15+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<maui:MauiWinUIApplication
2+
x:Class="RatingApp.WinUI.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:maui="using:Microsoft.Maui"
6+
xmlns:local="using:RatingApp.WinUI">
7+
8+
</maui:MauiWinUIApplication>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.UI.Xaml;
2+
3+
// To learn more about WinUI, the WinUI project structure,
4+
// and more about our project templates, see: http://aka.ms/winui-project-info.
5+
6+
namespace RatingApp.WinUI
7+
{
8+
/// <summary>
9+
/// Provides application-specific behavior to supplement the default Application class.
10+
/// </summary>
11+
public partial class App : MauiWinUIApplication
12+
{
13+
/// <summary>
14+
/// Initializes the singleton application object. This is the first line of authored code
15+
/// executed, and as such is the logical equivalent of main() or WinMain().
16+
/// </summary>
17+
public App()
18+
{
19+
this.InitializeComponent();
20+
}
21+
22+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23+
}
24+
}

0 commit comments

Comments
 (0)