Problem using TemplatedControl #16447
-
I have created simple TemplatedControl and use it in the view, but nothing is rendered, except empty space if I set Height=20. I'm using latest Avalonia 11.1.0. <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:eCapConfigurator.Controls">
<!--
Additional resources
Using Control Themes: https://docs.avaloniaui.net/docs/basics/user-interface/styling/control-themes
Using Theme Variants: https://docs.avaloniaui.net/docs/guides/styles-and-resources/how-to-use-theme-variants
-->
<Design.PreviewWith>
<StackPanel Width="400" Spacing="10">
<StackPanel Background="{DynamicResource SystemRegionBrush}">
<controls:TemplatedControl1 />
</StackPanel>
</StackPanel>
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type controls:TemplatedControl1}" TargetType="controls:TemplatedControl1">
<Setter Property="Template">
<ControlTemplate>
<TextBlock Text="Templated Control" />
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary> Searching for the error in web brings the need for
Is the template for TemplatedControl wrong or do I have to use it some other way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Should use like this <Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="/Controls/TemplatedControl1.axaml"/>
</ResourceDictionary.MergedDictionaries>
<x:Double x:Key="SmallIconSize">16</x:Double>
<x:Double x:Key="NormalIconSize">24</x:Double>
<x:Double x:Key="LargeIconSize">24</x:Double>
</ResourceDictionary>
</Application.Resources> |
Beta Was this translation helpful? Give feedback.
Should use like this