Saturday, February 12, 2011

Road test: Custom WPF Frames

After reading kirupa's tutorial on custom windows, I thought I'd revisit the counter app I made last week. Actually, I found several tutorials when I was googling creating custom title bars. But kirupa's tutorial proved to be the most useful out of all of them. Anyhow, here is the end result:

I had to code my own functions for minimising, maxmising, closing and dragging the window. (To enable dragging, I had to code the event handler for the label's MouseLeftButtonButtonDown event) It was rather nice having a decent looking window for a change. :D In case you're wondering how I got the rounded rectangle, I had to create a control template which "overwrote" the default styling for the window.  Below is the code that I used to get said window.

I had to remember to specify the ContentPresenter, otherwise the controls wouldn't show up.

Now that I've got the hang of custom windows, I think I will have a go at one of my more complicated project ideas.

No comments:

Post a Comment