public MainWindow() { InitializeComponent(); try { Stream stream = File.Open("Background.jpg", FileMode.Open); BitmapImage imgsrc = new BitmapImage(); imgsrc.BeginInit(); imgsrc.StreamSource = stream; imgsrc.EndInit(); imgBackground.Source = imgsrc; } catch (IOException) { } _viewModel = TryFindResource(ViewModelProviderKey) as SpinnerViewModel; }