-
I created a custom class and inherited from window public class AppWindow : Window
{
} Then I created a <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:CustomControlsTst.Controls">
<!-- Add Resources Here -->
<Design.PreviewWith>
<c:AppWindow Width="400" Height="400"
CornerRadius="5"/>
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type c:AppWindow}" TargetType="c:AppWindow">
<Setter Property="Background" Value="{TemplateBinding Background}"/>
<Setter Property="Title" Value="{TemplateBinding Title}"/>
<Setter Property="SystemDecorations" Value="None"/>
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}"
BoxShadow="0 0 30 1 Gray" Margin="30">
<ContentPresenter Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary> However, neither the preview nor the debug version of the code work. If I replace |
Beta Was this translation helpful? Give feedback.
Answered by
rabbitism
Nov 5, 2024
Replies: 1 comment 1 reply
-
Change StyleKeyOverride to the type of your Window. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
cocoderus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change StyleKeyOverride to the type of your Window.
https://docs.avaloniaui.net/docs/basics/user-interface/styling/styles#style-key