S
S
Sapun4ik2014-12-01 17:27:01
WPF
Sapun4ik, 2014-12-01 17:27:01

How to assign Source in WPF?

Good time of the day. Prompt please,
in Windows Forms it is possible to appropriate Source to PictureBox thus:
Properties.Resources._0;
where "_0" is the name of the image loaded from Resources
How to do it in WPF only to image

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Papin, 2014-12-06
@i_light

You need to include the namespace in the XAML headers, something like this:

<UserControl x:Class="..."
   ...
   xmlns:res="clr-namespace:<namespace_проекта>.Properties"
   ...

And then you can use the values ​​from the resources, something like this:
(however, it may not work this way and you will need to use an ImageBrush or something else, we only use string resources in our project).
Actually, you can google "wpf using resx in xaml".

S
Sapun4ik, 2014-12-06
@Sapun4ik

Thank you very much, the issue has been resolved. Wrote a small method that returns me a BitmapImage without any problems =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question