无法从引用程序集中的资源中加载自定义光标 [英] Cant load custom cursor from resource in referenced assembly

查看:104
本文介绍了无法从引用程序集中的资源中加载自定义光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含使用某些自定义光标的自定义控件的程序集,我想将光标作为该程序集中的资源嵌入.可以从文件名或流中加载Cursor类,因此首先我尝试使用"WPF方式"进行加载.通过将光标文件添加为"Resource"来实现.进入项目并在我的控件的静态构造函数中使用以下代码:

I have a assembly containing a custom control that uses some custom cursors and I wanted to embed the cursors as resources in that assembly. The Cursor class can be loaded either from filename or stream, so first I tried to do it "the WPF way" by adding the cursor files as "Resource" into the project and using this code in static constructor of my control:

代码段

推荐答案

尝试:

Uri uri =新的Uri("zoom.cur",UriKind.Relative);
this.Cursor =新的Cursor(App.GetResourceStream(uri).Stream);

 Uri uri = new Uri("zoom.cur", UriKind.Relative);
   this.Cursor = new Cursor(App.GetResourceStream(uri).Stream);


这篇关于无法从引用程序集中的资源中加载自定义光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆