Patrick
Patrick

Reputation: 2593

How to set an URI from code-behind

I have seen several examples like

How to Set Image Resource URI from Code-Behind

but haven't understood.

If I have the following solution

enter image description here

enter image description here

I want to set the uri for ita.png

 Stream iconStream = Application.GetResourceStream(new Uri(?????)).Stream;
  notifyIcon.Icon = new System.Drawing.Icon(iconStream);

thanks

Upvotes: -1

Views: 358

Answers (1)

Anton Danylov
Anton Danylov

Reputation: 1491

You can use pack URI syntax described here

In your case it would be something like this:

  Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/Images/ITA.png")).Stream;
  notifyIcon.Icon = new System.Drawing.Icon(iconStream);

Upvotes: 1

Related Questions