Skip to content

Commit

Permalink
Add a default template for the surfaces
Browse files Browse the repository at this point in the history
Fixes #296
  • Loading branch information
mattleibow committed Dec 4, 2024
1 parent b51fc91 commit 6be893b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class SKSurfaceView : TemplatedView
private SKCanvasView? canvasView;
private SKGLView? glView;

internal SKSurfaceView()
public SKSurfaceView()
{
ResourceLoader<Themes.SKSurfaceViewResources>.EnsureRegistered(this);

DebugUtils.LogPropertyChanged(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SkiaSharp.Extended.UI.Controls"
xmlns:skia="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls"
x:Class="SkiaSharp.Extended.UI.Controls.Themes.SKSurfaceViewResources">

<!-- the control template for SKSurfaceView -->
<ControlTemplate x:Key="SKSurfaceViewControlTemplate">
<skia:SKCanvasView x:Name="PART_DrawingSurface" />
</ControlTemplate>

<!-- the explicit style that allows for extension -->
<Style x:Key="SKSurfaceViewStyle" TargetType="local:SKSurfaceView">
<Setter Property="ControlTemplate"
Value="{StaticResource SKSurfaceViewControlTemplate}" />
</Style>

<!-- the implicit style that applies to all controls -->
<Style TargetType="local:SKSurfaceView"
ApplyToDerivedTypes="True"
BasedOn="{StaticResource SKSurfaceViewStyle}" />

</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SkiaSharp.Extended.UI.Controls.Themes;

public partial class SKSurfaceViewResources : ResourceDictionary
{
public SKSurfaceViewResources()
{
InitializeComponent();
}
}

0 comments on commit 6be893b

Please sign in to comment.