Answer the question
In order to leave comments, you need to log in
How to get an image from resources?
Hello. I'm making a button with an icon. I placed a png image in property.resources and I want to display it on a button.
Here is the button code
<Button Name="saveButton" Style="{StaticResource dialogButtonControl}" Click="saveButton_Click">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Сохранить" Style="{StaticResource imagedButtonTextBlock}" Grid.Column="1"/>
<Image Grid.Column="0">
<Image.Source>
<BitmapImage UriSource="/ConfigWPF;component/Resources/saveButton.Image.png"/>
</Image.Source>
</Image>
</Grid>
</Button>
Answer the question
In order to leave comments, you need to log in
Try specifying the full path to the resources as a Uri of type pack .
Sometimes, when pictures are not in the assembly that is being run, the application cannot find them in resources.
The full path will look something like this:
component - part of the path, points to resources.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question