A sample game of sliding puzzles.
Record_MauiSlidePuzzleDemoClip_AdobeExpress.mp4
Details
- MauiSlidePuzzle/
- Controllers/
- CustomViews/
- Models/
- Resources/
- Fonts/
- Images/
- Puzzles/
- Raw/
- Puzzles/
- MainPage.xaml
- MainPage.xaml.cs
- MauiProgram.cs
- MauiSlidePuzzle.csproj
- PuzzleResourceHelper.cs
- uml/
- How to use EmbeddedResources
- How to use SkiaSharp and SKCanvasView
- What the MVC (Model-View-Controller) pattern is
- How to add fonts and use image fonts
- How to write MIT license credits
- How to use non-default constructors in xaml
- How to use VisualState
- How to pass Json data to the constructor (Json constructor)
In the .csproj file, add EmbeddedRecource tags like
<ItemGroup>
...
<EmbeddedResource Include="Resources\Images\Puzzles\*" />
...
<EmbeddedResource Include="Resources\Raw\Puzzles\*" />
...
</ItemGroup>
Then, in a code, you can access the contents of a specified embedded resource via a resource ID (ex. MauiSlidePuzzle.Resources.Images.Puzzles.myshapes.png).
To use the view controls from SkiaSharp library, you should tell the maui app to use SkiaSharp in MauiProgram.cs:
var builder = MauiApp.CreateBuilder();
builder
.UseSkiaSharp(true)
.UseMauiApp<App>()
...
Without this statement, you will encounter the error with the unhundled exception such as,
Microsoft.Maui.Platform.HandlerNotFoundException: 'Handler not found for view SkiaSharp.Views.Maui.Controls.SKCanvasView.'
New fonts need to be added during the builder process:
builder
...
.ConfigureFonts(fonts =>
{
...
fonts.AddFont("ionicons.ttf", "Ionicons");
});
Then, the name (ex. Ionicons) is available as the value of FontFamily attribute.