Late last year I came across WPF when I was working on a work project. I found out pretty soon that WPF wasn't suited to that particular project, as the WPF framework doesn't have an equivalent of the DataGridView (not that I know of anyhow). So I ended up using Windows Forms.
Now that I'm not studying anymore, I've got a bit more time to experiment. I'm trying to make a simple calculator in WPF. Not the most original of ideas, I know. But its one of the safer options for learning a new language that I know of.
This is what the calculator looks like at the moment. One thing I'm loving about work with WPF is no messy "designer" code that one gets with Windows Forms applications. The only "behind the scenes" code one will ever deal with when working with WPF is the XAML code itself. Having the GridPanel also makes designing a consistent layout a lot easier because I don't have to fiddle around with the C# code as much. The downside to this that I've discovered so far is that one cannot add controls programmatically like in Windows Forms (i.e. via C#). I think I can see one reason why WPF wouldn't support controls being added programmatically: you can't have oddly-sized controls (see picture) if you're adding your form controls with an for loop.
In case you're wondering how I got the buttons to "fill" the cell, I simply didn't specify a height and width and just set the Grid.Row and Grid.Column property for the button. In the case of the "0" button, I also set the button's Grid.ColumnSpan property to 2.
Anyhow, back to the programming lab for me.
No comments:
Post a Comment