I’ve spent some free time at work learning WPF. Even after 15 years of windows programming, it’s a bit of a learning curve. I wrote a simple app to simulate a mobile phone – it will integrate with some other code here at work. A few things I’ve learned:
- Making buttons that change their appearance when you move the mouse over them or click them
- Laying out controls in a grid
- Working with Visual Studio when the IDE doesn’t render your XAML
I wanted to have glass effect buttons and I thought that would mean using Photoshop, which I’d never used before so I installed it from our work distribution and cranked it up. Then I found a tutorial for making glass effect buttons (http://www.associatedcontent.com/article/98189/photoshop_icons_how_to_create_a_green.html). I followed that and them played around with the settings for a day or so and figured out what effect changing each setting would have. I went home and told liz how I’d used Photoshop and was now an expert in it. She laughed – you don’t know hardly anything, you could spend the rest of your life and still not know anything. I think she’s right. it’s a huge program and I’ve just scratched the surface. Anyway, I then felt the number keys should have a metallic look so found a tutorial for that (http://biorust.com/tutorials/detail/31/en/). That link may not always work, but Google “metallic pill button”. Those two sites are great on Photoshop tutorials and I’ll lean more effects from them.
I wanted a button that changed appearance when you clicked on it and found a “How To” from Josh Smith (http://www.infusionblogs.com/blogs/jsmith/archive/2006/09/27/871.aspx). Josh has now moved his blog to WordPress (http://joshsmithonwpf.wordpress.com), but I can’t find this entry there. I followed his sample and got buttons that had different graphics when you hover or click on them. My UI is now a bit messy, but this is just a tutorial so I’m too worried about that.
I wanted to have buttons that would move when you press them – probably a pixel down and right then pop back when you release the mouse. that seems a straightforward thing, but so far I’m still looking at how you’d do that.
However I have found that when you include user controls in your WPF project Visual Studio designer does not work, it failed to display your window. That’s a bit of a worry, and apparently is fixed in the new Orcas release (Mar 2007). I started to download that and after I’d got 4 of the 7 files and spent half a day getting even that far, I wimped out. That upgrade will have to wait for now.
So I’m laying out my window “blind”, which means I’m learning about grids and about borders and so on. That’s useful since I think it’s better to know whow something really works than to just blindly follow someone else’s instructions without knowing what you’re doing.
One of the WPF “rules” is that you shouldn’t be doing things this way anyway. you should create your UI in pure XAML, no images and so forth. If I have free time in the next few weeks, that will be something else to play with.
The bottom line is that I now have an application using WPF that works just like my old Windows app. It looks nicer – apart from my messy attempts at graphics design, but really I’m not sure it adds anything.
