`

How to use embedded Resource in WPF

    博客分类:
  • WPF
wpf 
阅读更多

NOTE: do not confuse the embedded resource and the Resource in WPF. Embedded Resource is an old term that is used in Windows Form application, while the Resource is used in WPF.

 

Please see "Embedded and Resource" for more details.

 

 

Suppose that you have this layout of files 



 

 and you have one View that will load the Views, you can use the Pack uri to do this.

 

Suppose that the project name is called "TRecsSupportModule", you can do this:

 

 

 

          Uri uri = new Uri("/TRecsSupportModule;component/resource/style/MergedStyles.xaml", UriKind.RelativeOrAbsolute);

 
          StreamResourceInfo info = Application.GetResourceStream(uri);
          System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
          ResourceDictionary page = (ResourceDictionary)reader.LoadAsync(info.Stream);
          this.Resources.MergedDictionaries.Add(page);
 

 

You can specify the Uri as follow (in which case, you don't need to provide the UriKind enum)

 

 

 

Uri uri = new Uri("pack://application:,,,/TRecsSupportModule;component/mergedstyles.xaml");
 

If the resource is not coming from some dependency assemblies, you can ignore the ReferenceDll part, and the Uri can be written as such.

 

 

Uri uri = new Uri("/resource/style/MergedStyles.xaml", UriKind.RelativeOrAbsolute);
 

And you may ignore the leading '/'.

 

 

Uri uri = new Uri("resource/style/MergedStyles.xaml", UriKind.RelativeOrAbsolute);
 


When you do this, you might set the xaml file /TRecsSupportModule;component/Resource/Style/MergedStyles.xaml (Build Action: Resource), as compared agains the (BuildAction: Page), which may not work.

  • 大小: 9.9 KB
分享到:
评论

相关推荐

    How+to+Use+Ceedling+for+Embedded+Test-Driven+Development.pdf

    In the second example we look at mocking, and learn how to use it simulate our hardware. All the tests in these examples compile and run on your host PC (with GCC), with no target hardware needed.

    Programming Embedded Systems in C and C++

    However, if you have some programming experience and are familiar with C or C++, you're ready to learn how to write embedded software. The hands-on, no-nonsense style of this book will help you get ...

    Programming Embedded Systems in C and C++.chm

    In addition to learning how to use C and C++ more effectively, you'll also benefit from the detailed explanations and source code solutions to common embedded software problems. Among the advanced ...

    Design Patterns for Embedded Systems in C

    本书《Design Patterns for Embedded Systems in C》作为嵌入式软件工程工具箱,作者Bruce Powell Douglass博士基于丰富的嵌入式软件工程经验,详细介绍了在嵌入式系统编程中使用C语言时可以运用的设计模式。...

    WPF_嵌入字体_EmbeddedFont

    WPF_嵌入字体_EmbeddedFont

    GNU/Linux Rapid Embedded Programming

    You will gain a strong foundation in using embedded systems by learning how to program the device driver and access the peripherals. You will also learn how to read and write data from/to the ...

    Embedded Linux Primer

    Christopher Hallinan offers solutions for the specific technical issues you’re most likely to face, demonstrates how to build an effective embedded Linux environment, and shows how to use it as ...

    Building Embedded Linux Systems, 2nd

    There's a great deal of excitement surrounding the use of Linux in embedded systems -- for everything from cell phones to car ABS systems and water-filtration plants -- but not a lot of practical ...

    Embedded.Systems.Introduction

    This book, now in its 5th edition, is the first in a series of three books that teach the fundamentals of embedded systems as applied to the ARM® Cortex™-M family of microcontrollers. This first ...

    Prentice.Hall.PTR.Embedded.Linux.Primer.A.Practical.Real.World.Approach.Sep.2006.chm

    Christopher Hallinan offers solutions for the specific technical issues you're most likely to face, demonstrates how to build an effective embedded Linux environment, and shows how to use it as ...

    WPF 内嵌 Xilium.CefGlue 浏览器

    在IT行业中,尤其是在Windows Presentation Foundation (WPF)应用开发中,有时我们需要在应用程序内部集成一个浏览器组件,以便用户能够浏览网页内容或者实现某些基于Web的功能。`Xilium.CefGlue`就是这样一个库,它...

    Learning.Embedded.Linux.using.the.Yocto.Project.1784397393

    You'll be given an overview of the available Yocto Project components, how to set up Yocto Project Eclipse IDE, and how to use tools such as Wic and Swabber that are still under development....

    Embedded.Firmware.Solutions

    Embedded Firmware Solutions: Development Best Practices for the Internet of Things is the perfect introduction and daily-use field guide--for the thousands of firmware designers, hardware engineers, ...

    Handbook of Real-Time and Embedded Systems

    use 7-zip to unzip By Insup Lee, Joseph Y-T. Leung, Sang H. Son Publisher: Chapman & Hall/CRC Number Of Pages: 800 Publication Date: 2007-07-23 ISBN-10 / ASIN: 1584886781 ISBN-13 / EAN: ...

Global site tag (gtag.js) - Google Analytics