Jump to content

Why does this crash my wpf window?


Phenomenal

Recommended Posts

Fixed it... feel free to lock the thread.

 

I am trying to write a launcher application (just for fun) however whenever I try to load the background from a file the application wont open (line 3 is the cause of the issue).

My code is:

var BackgroundDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(),"\\Background.png");
            this.Title = ConfigurationManager.AppSettings["WindowName"];
            this.Background = new ImageBrush(new BitmapImage(new Uri(BackgroundDirectory)));

and I have placed Background.png in the release folder (configuration is set to release). Any help would be majorly appreciated!

 

Solution:

var BackgroundDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(),"Background.png");
            this.Title = ConfigurationManager.AppSettings["WindowName"];
            this.Background = new ImageBrush(new BitmapImage(new Uri(BackgroundDirectory)));

should work however I chose to just use strings instead... 

string BackgroundDirectory = Directory.GetCurrentDirectory + "//Background.png"

 

Link to comment
Share on other sites

1 hour ago, PhenomenalDev said:

Fixed it... feel free to lock the thread.

 

I am trying to write a launcher application (just for fun) however whenever I try to load the background from a file the application wont open (line 3 is the cause of the issue).

My code is:


var BackgroundDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(),"\\Background.png");
            this.Title = ConfigurationManager.AppSettings["WindowName"];
            this.Background = new ImageBrush(new BitmapImage(new Uri(BackgroundDirectory)));

and I have placed Background.png in the release folder (configuration is set to release). Any help would be majorly appreciated!

You should actually provide the solution if you figured it out.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...