Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)

我需要检查是否存在嵌入式资源。 在WPF这我相对容易,但在WP7中我得到一个MissingManifestResourceException

有效的WPF代码是:

public static IEnumerable<object> GetResourcePaths(Assembly assembly) { 
        var culture = System.Threading.Thread.CurrentThread.CurrentCulture; 
        //var resourceName = assembly.GetName().Name + ".g"; 
        var assemblyName = assembly.FullName.Split(',')[0]; 
        var resourceName = assemblyName + ".g"; 
        var resourceManager = new ResourceManager(assemblyName, assembly); 

        try { 
            var resourceSet = resourceManager.GetResourceSet(culture, true, true); 

            foreach (System.Collections.DictionaryEntry resource in resourceSet) { 
                yield return resource.Key; 
            } 
        } finally { 
            resourceManager.ReleaseAllResources(); 
        } 
    } 

我尝试用下面的代码替换它,这导致异常(在第9行)。 有没有办法在Silverlight / WP7中执行此操作?

public static IEnumerable<object> GetResourcePaths(Assembly assembly) { 
            var culture = System.Threading.Thread.CurrentThread.CurrentCulture; 
            //var resourceName = assembly.GetName().Name + ".g"; 
            var assemblyName = assembly.FullName.Split(',')[0]; 
            var resourceName = assemblyName + ".g"; 
            var resourceManager = new ResourceManager(assemblyName, assembly); 

            try { 
                var resourceSet = resourceManager.GetResourceSet(culture, true, true); 

                foreach (System.Collections.DictionaryEntry resource in resourceSet) { 
                    yield return resource.Key; 
                } 
            } finally { 
                resourceManager.ReleaseAllResources(); 
            } 
        } 

I need to check whether an embedded resource exists. In WPF this i relatively easy, but in WP7 I get a MissingManifestResourceException

The WPF code which works is:

public static IEnumerable<object> GetResourcePaths(Assembly assembly) { 
        var culture = System.Threading.Thread.CurrentThread.CurrentCulture; 
        //var resourceName = assembly.GetName().Name + ".g"; 
        var assemblyName = assembly.FullName.Split(',')[0]; 
        var resourceName = assemblyName + ".g"; 
        var resourceManager = new ResourceManager(assemblyName, assembly); 

        try { 
            var resourceSet = resourceManager.GetResourceSet(culture, true, true); 

            foreach (System.Collections.DictionaryEntry resource in resourceSet) { 
                yield return resource.Key; 
            } 
        } finally { 
            resourceManager.ReleaseAllResources(); 
        } 
    } 

I tried replacing it with the code below, which resulted in the exception (on line 9). Is there a way to do this in Silverlight / WP7?

public static IEnumerable<object> GetResourcePaths(Assembly assembly) { 
            var culture = System.Threading.Thread.CurrentThread.CurrentCulture; 
            //var resourceName = assembly.GetName().Name + ".g"; 
            var assemblyName = assembly.FullName.Split(',')[0]; 
            var resourceName = assemblyName + ".g"; 
            var resourceManager = new ResourceManager(assemblyName, assembly); 

            try { 
                var resourceSet = resourceManager.GetResourceSet(culture, true, true); 

                foreach (System.Collections.DictionaryEntry resource in resourceSet) { 
                    yield return resource.Key; 
                } 
            } finally { 
                resourceManager.ReleaseAllResources(); 
            } 
        } 

原文:https://stackoverflow.com/questions/5622317
2024-05-05 21:05

满意答案

您可以绑定到页面DIV的id(例如:div#home)。

<script type="text/javascript">
    $('div#home').live("pagecreate", function (event) {
        alert('Swipe left and right to move between the 5 pages of this lead sheet');
    });
</script>

...

<div data-role="page" id="home">

You can bind to the id for the page DIV (ex: div#home).

<script type="text/javascript">
    $('div#home').live("pagecreate", function (event) {
        alert('Swipe left and right to move between the 5 pages of this lead sheet');
    });
</script>

...

<div data-role="page" id="home">

相关问答

更多

jquery mobile alert提示

alert时候标题会显示网页所属域名的地址。这个是无法更改的,因为javascript并没有提供这个功能,这个是浏览器决定的。

警报(””);(Alert(“”); Function using PhoneGap and jQuery)

使用jQueryMobile,可以在页面加载时了解特定事件 。 你应该尝试以下方法(将它放在你的头部元素中,在身体之前): <script> $('#page3').live('pageshow', function() { alert('Page ' + $(this).attr('id') + ' about to be shown'); }); </script> 你也可以处理'pagebeforeshow'/'pagecreate'事件。 With jQueryMobile the...

jQuery Mobile和HTML5 Boilerplate(jQuery Mobile and HTML5 Boilerplate)

<script type="text/javascript"> <!-- var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", "js/jqueryMobile.js") if (screen.width <= 480) { document.getElementsByTagName("head")[0]...

jquery警报没有出现(jquery alert not appearing)

试试这样 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrap...

另一个html上的Jquery移动javascript无法正常工作(Jquery mobile javascript on another html not working)

您可以在此处找到有关此问题的所有信息 : 为什么我必须将所有脚本放到jquery mobile中的index.html 要了解这种情况,您需要了解jQuery Mobile的工作原理。 它使用ajax加载其他页面。 第一页正常加载。 它的HEAD和BODY被加载到DOM ,它们在那里等待其他内容。 加载第二页时, 只将其BODY内容加载到DOM 。 这就是为什么您的按钮显示成功但点击事件无法正常工作的原因。 在页面转换期间忽略其父HEAD相同单击事件。 这是官方文档: http : //jquer...

将外部Html合并到jQuery Mobile页面中(Incorporating External Html into a jQuery Mobile page)

如果您在容器元素上.trigger('create') ,jQuery Mobile将自动初始化容器内的任何小部件。 例如: $("#main").load('externalHtml.html').trigger('create'); 他们确实应该更好地记录这一点,但是如果您查看每种类型的窗口小部件的API事件,您将看到关于create事件的文档。 另外,请阅读本文档的顶部: http : //jquerymobile.com/demos/1.1.1/docs/api/events.html ...

jQuery mobile附加html代码(jQuery mobile appending html code)

您可以在实际附加之前检查是否存在要附加的代码。 这样,在后续访问页面时,不会添加数据: $('#page1').live('pageshow', function () { // alert("!"); if ($(this).find('p.appended_code').length === 0) { var section1 = "<p class='appended_code'>some code for page 1....

如何获得警报仅在jQuery Mobile多页面html中出现一次(How to get alert to only appear once in jQuery Mobile multiple page html)

您可以绑定到页面DIV的id(例如:div#home)。 <script type="text/javascript"> $('div#home').live("pagecreate", function (event) { alert('Swipe left and right to move between the 5 pages of this lead sheet'); }); </script> ... <div data-role="page" id=...

jQuery移动多个HTML文件(jQuery mobile multiple HTML files)

如果您从内容中的链接中删除"data-url='about.html'" ,它对我"data-url='about.html'" 。 此属性适用于页面div。 第二页(about.html)可以是一个完整的HTML页面,只要它包含正文中的当前文本即可。 jQuery Mobile工作正常,因为它将加载整个文件,然后提取页面div。 您可以将多个页面视为一种在DOM中缓存内容的方式,如果这看起来更合理! It works for me if you remove the "data-url='abo...

jquery移动页面引用和点击功能的奇怪问题(strange issue of jquery mobile page reference and click function)

您正在使用window.location.replace ,它将当前文件中的HTML替换为您链接到的文件中的HTML。 您需要使用window.location.href ,而不是转到另一页。 更多信息: http : //www.w3schools.com/jsref/obj_location.asp - 更新 - 格式与window.location.replace不同。 window.location.href = 'main.html'; 如果您仍然遇到问题而不是尝试: window.o...

相关文章

更多

Windows Phone Emoji

今天基于项目的需要,研究了一下windows phone 8里面的Emoji实现。如果大家用过wp版本 ...

《Windows phone 8 高级编程技术》(Windows phone 8 development)1.0[压缩包]

中文名: Windows phone 8 高级编程技术 英文名: Windows phone 8 ...

《Windows Phone 7应用开发指南》扫描版[PDF]

中文名: Windows Phone 7应用开发指南 作者: 张越 等著 图书分类: 软件 ...

windows phone开发中textbox控件的header属性

备注;博主windows phone学习新手,在博客园上分享自己刚刚掌握的一些学习笔记,内容简单,高手 ...

Windows Phone 获取app在商店中的版本(检查app的版本号)

public classAppVersionHelper { /// &lt;summary ...

微信 Windows Phone版原型设计 - [WP开发]

用Metro的理念(自己暂时所理解到的程度)简单的设计了一下腾讯微信的原型设计图。然后,今天去面试实习 ...

分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(12月26日-1月1日)

分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(12月26日- ...

Windows Phone版微信,在朋友圈发送仅文本内容

在朋友圈中发送照片,然后选择任意图片,编辑文字内容,然后选择删除(大减号图标),然后发送即可。 本文出 ...

《Windows Phone 7.5专题讲座之WP7入门系列》共10课时/更新完毕[压缩包]

中文名: Windows Phone 7.5专题讲座之WP7入门系列 资源格式: 压缩包 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本