I am creating an app using avalonia which has some UI stuff in another assembly because of re-usability. Within this additional assembly, i want to have a Resource.xml file which is referenced by the application project and other projects. It contains styles etc.
Content:
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Style x:Key="normal_button" Selector="Button.normal_button">
<Setter Property="Margin" Value="0" />
<Setter Property="Height" Value="25" />
<Setter Property="MinWidth" Value="75" />
</Style>
</ResourceDictionary>
Error:
Unable to find suitable setter or adder for property Content of type Avalonia.Styling:Avalonia.Controls.ResourceDictionary for argument Avalonia.Styling:Avalonia.Styling.Style, available setter parameter lists are: ...
What am i doing wrong? Are there some entries in the .csproj file necessary?
Avalonia styles can't be used from resource dictionaries. You need Styles
as a root of your shared file and StyleInclude
for inclusion.
e. g. https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog/SideBar.xaml
https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog/App.xaml#L18