Skip to content

Commit

Permalink
fix: Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
workgroupengineering committed Nov 16, 2023
1 parent 43b4664 commit 9c57e43
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
36 changes: 17 additions & 19 deletions templates/csharp/templatedcontrol/NewTemplatedControl.axaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:AvaloniaAppTemplate.Namespace">
<Design.PreviewWith>

<StackPanel Width="400" MinHeight="400">
<Design.PreviewWith>
<StackPanel Width="400" Spacing="10">
<ThemeVariantScope RequestedThemeVariant="Default">
<controls:NewTemplatedControl />
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:NewTemplatedControl />
</StackPanel>
</ThemeVariantScope>
<ThemeVariantScope RequestedThemeVariant="Light">
<controls:NewTemplatedControl />
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:NewTemplatedControl />
</StackPanel>
</ThemeVariantScope>
<ThemeVariantScope RequestedThemeVariant="Dark">
<controls:NewTemplatedControl />
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:NewTemplatedControl />
</StackPanel>
</ThemeVariantScope>
</StackPanel>
</Design.PreviewWith>

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="MyForegroud" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="MyForegroud" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="MyForegroud" Color="White"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<!--
If you want support Theme variant see
https://github.com/AvaloniaUI/Avalonia.Samples/tree/main/src/Avalonia.Samples/CustomControls/RatingControlSample#step-9-theme-variant
-->

<ControlTheme x:Key="{x:Type controls:NewTemplatedControl}" TargetType="controls:NewTemplatedControl">
<Setter Property="Template">
<ControlTemplate>
<TextBlock Text="Templated Control" Foreground="{DynamicResourceKey MyForegroud}" />
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ namespace AvaloniaAppTemplate.Namespace;

public class NewTemplatedControl : TemplatedControl
{
protected override Type StyleKeyOverride =>
typeof(Avalonia.Labs.Controls.ContentDialog);
}
31 changes: 15 additions & 16 deletions templates/fsharp/templatedcontrol/NewTemplatedControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:AvaloniaAppTemplate.Namespace">
<Design.PreviewWith>
<StackPanel Width="400" MinHeight="400">
<StackPanel Width="400" Spacing="10">
<ThemeVariantScope RequestedThemeVariant="Default">
<controls:NewTemplatedControl />
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:NewTemplatedControl />
</StackPanel>
</ThemeVariantScope>
<ThemeVariantScope RequestedThemeVariant="Light">
<controls:NewTemplatedControl />
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:NewTemplatedControl />
</StackPanel>
</ThemeVariantScope>
<ThemeVariantScope RequestedThemeVariant="Dark">
<controls:NewTemplatedControl />
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:NewTemplatedControl />
</StackPanel>
</ThemeVariantScope>
</StackPanel>
</Design.PreviewWith>

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="MyForegroud" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="MyForegroud" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="MyForegroud" Color="White"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<!--
If you want support Theme variant see
https://github.com/AvaloniaUI/Avalonia.Samples/tree/main/src/Avalonia.Samples/CustomControls/RatingControlSample#step-9-theme-variant
-->

<ControlTheme x:Key="{x:Type controls:NewTemplatedControl}" TargetType="controls:NewTemplatedControl">
<Setter Property="Template">
<ControlTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ open Avalonia.Controls.Primitives

type NewTemplatedControl () =
inherit TemplatedControl ()
override StyleKeyOverride
with get() = typedefof<NewTemplatedControl>

0 comments on commit 9c57e43

Please sign in to comment.