Tuesday 22 March 2011

Persisting Window State in WPF

The attached article did exactly what I needed.

The only change I made was to stop it persisting window state if the application was minimised, which is something I specifically wanted to stop with this application - but you can decide for yourself in your own applications.

Thanks Erwyn!

Wednesday 16 March 2011

Jumplists!

Well, I guess they had to call them something.

Jumplists are the lists of links and tasks that appear when you right-click an application's icon in the Windows 7 taskbar.

Today I learned how to manipulate that list. I used the link above, as well as the MSDN article.

Fun stuff! Nice to embed yourself more into an OS to impress the users ;)

Thursday 3 March 2011

Refresh WPF controls just like Winforms

Remember the bad old days with forcing repaints on your Winforms applications? I was forced back into that era today. I was updating the source of an Image on a WPF window, and then taking a snapshot of the window immediately after. What led to a great deal of hair loss was that the image hadn't actually appeared by the time I was taking the snapshot, and thus it was like taking a photo of a vampire - it simply wasn't there, even though the moment I could see the window it actually was.

Instead of going down the lengthy route of delaying the snapshot and then nested events or callbacks, I went to Google, and more specifically, my dear friend Stack Overflow which eventually led me to here.

this.Dispatcher.Invoke(DispatcherPriority.Render, _emptyDelegate);

That _emptyDelegate:

private static Action _emptyDelegate = delegate() { };

Genius. Continued hair loss averted. Or rather, delayed until the next issue...