简体   繁体   English

使用加载指示器进行WPF应用程序

[英]Using a Loading Indicator for WPF application

I'm relatively new to WPF and I would like to add a loading indicator. 我是WPF的新手,我想添加一个加载指示器。 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. 我找到了https://github.com/100GPing100/LoadingIndicators.WPF ,它有一些不错的预制加载指示器,我为它安装了NuGet包,但是我很难将它们实现到我的窗口。

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. 无法解析资源“LoadingIndicatorDoubleBounceStyle”。

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. 从我在其他网站上看到的,我正确地将它添加到ResourceDictionary ...而我假设通过安装NuGet包,我已经定义了资源。 I can still run the application but the indicator is missing. 我仍然可以运行该应用程序,但缺少指标。 What am I missing? 我错过了什么?

Thank you 谢谢

That key exists in the Styles.xaml file. 该密钥存在于Styles.xaml文件中。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM