How to load images xaml in WPF having build action embedded resources - wpf

How to load images xaml in WPF having build action embedded resources without changing build action of this image.
"<BitmapImage UriSource="pack://application:,,,/Assets/Images/clock_6.png" x:Key="clock_6"/>"
I tried above but throwing "cannot locate resource" exception.

Related

Can't able to use Scriban reference dll in WPF Application (.NET Framework)

I am using Scriban reference dll of version 5.5.0. I am trying to add this reference file in my WPF application or XAML file used application while adding it shows error in the XAML file InitializeComponent() as [Error CS0103 The name 'InitializeComponent' does not exist in the current context]
Error Highlighted Image attached

RadRibbonWindow is not loading application icon from embedded resource

Recently I have changed my WPF application Root window from Window to RadRibbonWindow and this RadRibbonwindow is not loading application Icon from embedded resources. What do I need to do, to make RabRibbonWindow load an icon "ico" from resources automatically? My all other Windows are loading Icon from embedded resources automatically.
in your header:
navigation:RadWindowInteropHelper.Icon="icon.ico"
from this example https://www.telerik.com/support/kb/wpf/window/details/how-to-use-radwindow-as-main-window
and the file icon.ico is in the root folder.

Custom Font in Silverlight OOB

Can anyone give me a hand on how to use Custom fonts in a Silverlight app in OOB? It works in the browser correctly.
Furthermore, the font is working and referenced correctly as the designer renders what I am after, but when running the app it is ignored.
Thanks heaps
Edit :
Trying to emulate a Mutlimeter display (thus OOB)
FontFamily="/BNA;component/Fonts/Fonts.zip#Crystal"
Font Properties Build Action = "Resource", Copy to Output Directory = "Copy Always"
Got it sorted, had to embed in to the client app side using
FontFamily="/BNA;component/Crysta.ttf#Crystal" and setting the Font as a Resource

how to set startup uri property to another window in folder in wpf project

In my wpf project i have created a folder called practice, in that folder i added a window, now i want to run that window, so in app.xaml file i set the startup uri to foldername.window.xaml but it is saying build action property is not set to resource.
for that i setted build action property to resource. Now this time that it is showing error message initialized componenet doesn't exist in the current context.
Can you tell me what properties we need to set when we create separate folders in wpf project and that folders contains windows or pages. and How to access those pages in other pages or in App.Xaml file startupUri Property.
When you have folders in your project structure, you should use a "/" not a ".", so it's foldername/window.xaml.
(I hope it's not actually called window.xaml by the way. That's a confusing name for a type in a WPF project, because there's a built in type called Window.)
Setting the build action to Resource will make matters worse: not only were you using the wrong name, you've now changed the build action to the wrong one for XAML. The correct build action for a .xaml file is usually Page. (App.xaml is an exception to that rule.) The Page build action causes the page to be compiled into a binary representation (known as BAML), and that binary format can then be loaded either by the call to InitializeComponent in the codebehind, or through Application.LoadComponent.
Setting the build action to Resource will just embed a copy of the XAML source directly in the project, which won't help you - you can't work with XAML in that form if you want to have a codebehind file. (Not in WPF, anyway. It's different in other XAML-based frameworks such as WinRT.)
Since Page is the default build action for a newly-added window, you don't actually need to set any properties at all. You just need to use / for folder boundaries.
If the XAML is inside any Folder the startup url will be defined as below.
This is how it will defined.

Can't get pack Uri to work

I've got a WPF application I'm building. The solution contains a WPF control library project called CustomControls. There's a folder under the CustomControls project folder called Layouts. There's an XML file in that folder called OnscreenLayout.xml. The Build Action property for this file is set to Embedded Resource.
I'm trying to load that file into a stream in the code behind and pass the stream on to a method of a third party library class. The code in question looks like this:
OnscreenKeyboard.DefaultLayout = FPS.VirtualKeyboard.KeyboardLayout.Create(
App.GetResourceStream(
new Uri( #"/CustomControls;component/Layouts/OnscreenLayout.xml",
UriKind.Relative ) ).Stream );
When this code runs, it throws an IOException with the message
Cannot locate resource 'layouts/onscreenlayout.xml'.
I've even tried using this string for the Uri:
#"pack://application:,,,/CustomControls;component/Layouts/OnscreenLayout.xml"
But no joy. What am I doing wrong?
Edit: I have even tried changing the build action for the file from "Embedded Resource" to "Resource" and it still doesn't work.
Thanks
Tony
Only Content and Resource build actions are valid for resource files used in WPF application.
Please avoid other build actions such as Embedded Resource - this will work as well with appropriate API, but it is not favored by WPF.

Resources