【问题标题】:Resource.xaml in AvaloniaAvalonia 中的 Resource.xaml
【发布时间】:2020-01-14 12:58:13
【问题描述】:

我正在使用 avalonia 创建一个应用程序,由于可重用性,该应用程序在另一个程序集中有一些 UI 内容。在这个附加程序集中,我想要一个 Resource.xml 文件,该文件被应用程序项目和其他项目引用。它包含样式等。

内容:

<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>

错误:

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: ...

我做错了什么? .csproj 文件中是否有一些必要的条目?

【问题讨论】:

    标签: xaml avaloniaui avalonia


    【解决方案1】:

    Avalonia 样式不能从资源字典中使用。您需要 Styles 作为共享文件的根目录,并需要 StyleInclude 才能包含。

    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

    【讨论】:

      猜你喜欢
      • 2017-05-19
      • 2022-01-04
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 1970-01-01
      相关资源
      最近更新 更多