AvaloniaUI / avalonia-docs

https://docs.avaloniaui.net/docs/welcome
64 stars 211 forks source link

MergeResourceInclude Not Mentioned In Docs; ResourceInclude Example Not Working #521

Open scarryaa opened 4 months ago

scarryaa commented 4 months ago

Hi, I may have found a slight issue with the docs. Apologies if this has been reported before or is a non-issue, but I couldn't find it already mentioned when I searched.

The issue is on this page, under Include and merge resources: https://docs.avaloniaui.net/docs/guides/styles-and-resources/resources#include-and-merge-resources

The docs mention how to set up a separate Resource File and include it:

<Styles.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceInclude Source="/Assets/AppResources.axaml"/>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Styles.Resources>

However, this was not working for me, and unfortunately I'm not exactly sure why, since it worked in the past. What did work for me was the following, using MergeResourceInclude instead:

      <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <MergeResourceInclude Source="/Resources/Fonts.axaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

Perhaps this should be mentioned in the docs somewhere?

Also, my Avalonia version is 11.1.0-rc2, so apologies if there may be some changes that I don't know about, since the docs appear to be on 11.0.x.

Thanks!

maxkatz6 commented 4 months ago

This ResourceInclude example should work, syntax is correct. Something wrong might be with file path, but error info could have help.

MergeResourceInclude Not Mentioned

It wasn't included, as it's rather a lower-level feature we don't recommend using, unless you exactly know what it is.