Jummi
Jummi

Reputation: 123

Using a Loading Indicator for WPF application

I'm relatively new to WPF and I would like to add a loading indicator. I found https://github.com/100GPing100/LoadingIndicators.WPF which has some nice pre-made loading indicators and I installed the NuGet Package for it but I'm having a hard time implementing them to my window.

So I added

<Window ...
    xmlns:loadin="clr-namespace:LoadingIndicators.WPF;assembly=LoadingIndicators.WPF"
    ...
>

Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingDoubleBounce.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

But when I try to add one of the loading indicators to my grid I get an error on the dynamic resource

<Grid x:Name="TagLoadingIndicator" Panel.ZIndex="1">
    <loadin:LoadingIndicator SpeedRatio="{Binding SpeedRatio}" IsActive="{Binding IsDoubleBounceActive}" Style="{DynamicResource LoadingIndicatorDoubleBounceStyle}"/>
</Grid>

The error I get is

The resource "LoadingIndicatorDoubleBounceStyle" could not be resolved.

From what I saw in other websites, I am adding it to the ResourceDictionary correctly... And I'm assuming that by installing the NuGet package, I have the resource already defined. I can still run the application but the indicator is missing. What am I missing?

Thank you

Upvotes: 4

Views: 3454

Answers (1)

Lockdowne
Lockdowne

Reputation: 484

That key exists in the Styles.xaml file. So add a reference to it in your resources.

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingDoubleBounce.xaml"/>
            <ResourceDictionary Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
 </Window.Resources>

Upvotes: 6

Related Questions