Skip to content

Exception in oxyplot.Avalonia's StyleInclude #65

Description

@guilhermeolisi

Hey,

I'm trying to update my project to Avalonia 11, but I had some problems with the Oxyplot.Avalonia nuget package.
On the oxyplot-avalonia main page on github there is an instruction for using oxyplot with Avalonia 11 which I think is wrong, it says AvaloniaEdit in StyleInclude (see screenshot below)

image

I've read the oxyplot.Avalonia examples and they use the code below to include the style:

StyleInclude Source="avares://OxyPlot.Avalonia/Themes/Default.axaml"/>

But in my project I get the following exception in this code: No precompiled XAML found for avares://OxyPlot.Avalonia/Themes/Default.axaml (baseUri: avares://Nimloth/App.axaml), make sure to specify x:Class and include your XAML file as AvaloniaResource

I'm using the latest version of the oxyplot.avalonia nuget package, 2.1.0, and Avalonia 11.0.6

Activity

nicolasr75 commented on Jan 30, 2024

@nicolasr75

I'm on Avalonia 11.07 and also having trouble to get it working.
This is a blank project where I only added Oxyplot.Avalonia 2.1.0.

I'm also using

StyleInclude Source="avares://OxyPlot.Avalonia/Themes/Default.axaml"/>

This is the only line I have yet added and the error is:

AVLN:0004 Resource "avares://OxyPlot.Avalonia/Themes/Default.axaml" is defined as "OxyPlot.Avalonia.Themes.Default" type in the "OxyPlot.Avalonia" assembly, but expected "Avalonia.Styling.IStyle". Line 9, position 17. AvaloniaApplication1 9

Any ideas?

v3ssel commented on Mar 8, 2024

@v3ssel

Had the same issue, change package reference to 2.1.0-Avalonia11 helps me

dotnet add package Oxyplot.Avalonia --version 2.1.0-Avalonia11

lloydjatkinson commented on Mar 28, 2024

@lloydjatkinson

Even with that version and the following code I get exceptions and build errors. How did you resolve it?

    <Application.Styles>
        <StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
        <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />

        <!--  Add the line below to get OxyPlot UI theme applied.  -->
        <StyleInclude Source="resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia" />

        <!--  Add the line below to get OxyPlot UI theme applied in Avalonia 11.  -->
        <StyleInclude Source="avares://AvaloniaEdit/Themes/Simple/AvaloniaEdit.xaml" />
        <SimpleTheme />
    </Application.Styles>
Assembly "Avalonia.Themes.Default" was not found from the "avares://Avalonia.Themes.Default/DefaultTheme.xaml" source. Line 8, position 23.		

MeltyPlayer commented on Jul 11, 2024

@MeltyPlayer

Had the same issue, change package reference to 2.1.0-Avalonia11 helps me

dotnet add package Oxyplot.Avalonia --version 2.1.0-Avalonia11

+1, for anyone else who stumbles on this issue this is what fixed it for me.

RivenSkaye commented on Mar 28, 2025

@RivenSkaye

Even with that version and the following code I get exceptions and build errors. How did you resolve it?

<Application.Styles>
    <StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
    <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />

    <!--  Add the line below to get OxyPlot UI theme applied.  -->
    <StyleInclude Source="resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia" />

    <!--  Add the line below to get OxyPlot UI theme applied in Avalonia 11.  -->
    <StyleInclude Source="avares://AvaloniaEdit/Themes/Simple/AvaloniaEdit.xaml" />
    <SimpleTheme />
</Application.Styles>
Assembly "Avalonia.Themes.Default" was not found from the "avares://Avalonia.Themes.Default/DefaultTheme.xaml" source. Line 8, position 23.		

Have you tried removing the resm: line? Considering the one after lists it applies for Avalonia 11, I'd assume that one is either redundant or incompatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions