WPF Buttons not displaying images - wpf

I have a strange phenomenon happening with my buttons, in my visual studio when creating a toolbar and assigning the buttons as images to the toolbar they show in the editor, but when i run the app the buttons don't show, this is illustrated below along with the code:
Image from visual studios
Running app image
Code:
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Button ToolTip="Open">
<Image Source="Icons/folder_page.png" />
</Button>
<Button ToolTip="Save">
<Image Source="Icons/page_save.png" />
</Button>
</ToolBar>
</ToolBarTray>

Do you copy your Images to the output-directory?
Have you set the Build-Action for the Images to Content and the Copy to Output Directory to 'Copy if newer'

By adding the images to the project they now display as a resource

Related

Logo image does not show up in react

In my react app, I tried displaying an image as a logo of my website in top navigation bar as follows:
I copied logo.png in the same folder as my NavBar.jsx.
Added following in NavBar
<img
src={logo}
width="30"
height="30"
/>
It gets displayed correctly when I browse http://localhost:9001/, but when I try accessing inner pages, say http://localhost:9001/courseware/course/, it shows broken image.
Then I tried to try it another way. I copied the image in public/images/logo.png and then trying displaying it as:
import logo from "./logo.png";
<img
src={`${process.env.PUBLIC_URL}/images/logo.png`}
width="30"
height="30"
/>
But now it does not show up on any page.
What I am doing wrong?
PS: I am running this app from vscode debug mode.
I think if you want to use image in your element, you have to import it before. You can not use variable in src{} without importing. Import it with complete address, then use it with the name you wrote, in src{}.

XAML and Glyphs for buttons

What's the best way to use glyphs for buttons ?
I have an WPF app which has a lot of buttons and I wonder what's the best way to use them.
I think it's about deploying the app.
Thank's
Example:
<BarButtonItem Name="buttonItem0" Content="Button Item" Glyph="pack://application:,,,/Resources/Images/icon.png" Description="Test button item" Hint="Testing glyph on button" ItemClick="notImplemented" CommandParameter="none" />
<BarButtonItemLink BarItemName="buttonItem0" />

Is there a WPF equivalent for ToolStripButton?

I'm learning WPF and have been trying to create a toolstrip. Is there a direct equivalent of the WinForms ToolStripButton or is the correct way of use just to add a normal button and format it?
I've found that Microsoft have a page that lists WinForm controls and their WPF equivalents here but that doesn't mention the toolstripbutton.
You can just put buttons inside a ToolBar and it will change the style of the buttons to make them look like a toolbar.
<ToolBar>
<Button>Save</Button>
<Button>Open</Button>
</ToolBar>
Looks like this:
If you want images in the buttons, you have to do the normal thing of modifying the content of the button.
<Button>
<Image Source="..." />
</Button>

WPF Radio button does not show in toolbar

Is there any way to force a radio button or check box to show properly in a toolbar? The circle/check box always disappears once its placed inside a toolbar.
By default, WPF overrides RadioButtons to make them look like toggle buttons. To eliminate this, place a panel inside the ToolBar and then put your RadioButton(s) in there.
<ToolBar>
<StackPanel>
<RadioButton Content="Radio Button" />
</StackPanel>
</ToolBar>

Adding an image to a button in XAML

I'm trying to add an image to a button in my silverlight 3 application but cannot get the image to appear. I added a folder, named \images, to my Silverlight application folder and an using a relative path in the Source attribute of the Image. What am I doing wrong?
<Button Width="200"
Height="200">
<Image Source="images\document.png"></Image>
</Button>
The easiest way to find out what is going on is to add an event handler for the ImageFailed event to see what URL it is trying to use.
You should probably try using forward slashes instead of back slashes, but I'm not sure if that is the real issue.

Resources