enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
1.19k stars 142 forks source link

Can't use Uranium StyleResource #459

Closed BinaryAssault closed 1 year ago

BinaryAssault commented 1 year ago

Using the latest pre-release UI, using the code below, I get an exception

Error occurs here https://github.com/enisn/UraniumUI/blob/488e467413007e2be606ba74227fe8a218496012/src/UraniumUI/Resources/StyleResource.xaml#L23

<?xml version="1.0" encoding="UTF-8" ?>
<Application
    x:Class="Test.App"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:Test"
    xmlns:u="http://schemas.enisn-projects.io/dotnet/maui/uraniumui">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/Styles/Colors.xaml" />
                <ResourceDictionary Source="Resources/Styles/Styles.xaml" />

                <u:ColorResource />
                <u:StyleResource/> <!-- Error comes from style resource -->
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
image
enisn commented 1 year ago

Can you try passing your existing color resource as ColorsOverride ?

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary x:Name="appColors" Source="Resources/Styles/Colors.xaml" />
    <m:StyleResource ColorsOverride="{x:Reference appColors}" />
</ResourceDictionary.MergedDictionaries>

https://enisn-projects.io/docs/en/uranium/latest/themes/material/ColorsAndStyles#changing-colors

BinaryAssault commented 1 year ago

That worked, thanks!