简体   繁体   English

MvvmCross资源加载器插件

[英]MvvmCross resource loader plugin

I try to load a XML resource with the MvxResourceLoader Plugin available over nuget. 我尝试通过nuget提供的MvxResourceLoader插件加载XML资源。

Steps I made: 我所做的步骤:

  1. Downloaded the Plugin to the PCL and the Windows Phone Project. 将插件下载到PCL和Windows Phone项目。
  2. Injected the plugin into my viewmodel. 将插件注入到我的viewmodel中。 (_loader) (_loader)
  3. Added this line: 添加了这一行:

    _loader.GetResourceStream("Assets/Suggestions.xml", delegate(Stream stream) {...}); _loader.GetResourceStream(“ Assets / Suggestions.xml”,委托(流流){...});

  4. Added resource to my Windows Phone project under the correct path and set to Resource. 在正确的路径下将资源添加到Windows Phone项目中,并设置为“资源”。

Result: 结果:

The stream is always null. 流始终为空。 Tried also different Versions of the path. 尝试了路径的不同版本。

It's hard to tell what your exact situation is, but there are a couple of working demos which use the Resource plugin - and you could compare your projects against these (although these may still be stuck in Winph7 to Winph8 handover so may need some love...): 很难说出您的确切情况,但是有几个使用Resource插件的工作示例-您可以将您的项目与这些示例进行比较(尽管这些项目可能仍停留在Winph7到Winph8的交接中,因此可能需要一些帮助。 ..):

Also there's some documentation available on: https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#wiki-resourceloader 也可以在以下网站上找到一些文档: https : //github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#wiki-resourceloader

For WindowsPhone, GetResourceStream is implemented in https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/ResourceLoader/Cirrious.MvvmCross.Plugins.ResourceLoader.WindowsPhone/MvxWindowsPhoneResourceLoader.cs#L19 - which loads the content as: 对于Windows Phone,在https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/ResourceLoader/Cirrious.MvvmCross.Plugins.ResourceLoader.WindowsPhone/MvxWindowsPhoneResourceLoader.cs#L19中实现GetResourceStream内容为:

var streamInfo = System.Windows.Application.GetResourceStream(new Uri(resourcePath, UriKind.Relative));

So, do your resources load when just using this System.Windows call? 因此,仅在使用此System.Windows调用时会加载您的资源吗? If they do, then the plugin should work too. 如果他们这样做,那么插件也应该工作。

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

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