(This silliness assumes you haven't jumped into the beauty that is WPF development. It also assumes you're running Vista. If you aren't, why not? If you have a good reason, I'm betting you'll get help installing .NET Framework 3.0. on XPSP2)
- Go here
- Click on Visual C#
- Login with your Windows Live ID
- Download and click on all of the nessesary buttons
- Marvel at the small (~30 MB) download (if you don't get the data stuff).
- Type "Visual" in Vista's start menu.
- Marvel at the cool search feature
- Pick Microsoft Visual C# 9.0 Express Edition
- Marvel at our crazy long product names
- Pick "New Project..." from the start menu. (Ctrl+Shift+N to be super fast)
- Pick WPF Application.
- Marvel at the visual designer for WPF. (Thanks Cider team.)
- Open up the Toolbox and find the ListBox under Common Controls.
- Draw out a ListBox on the Window.
- Marvel at the XAML updating right away.
- Notice the auto-generated name for your ListBox: listBox1.
- Open up Window1.xaml.cs
- Paste the following below InitializeCompontent();
var foo = from a in Directory.GetDirectories(@"C:\") select new{a, a.Length};
listBox1.ItemsSource = foo.ToList();
- Marvel at:
-the use of "var" -- mmm...implicit types
-from/select in C# -- mmm...Linq goodness
-new {a, a.Length} -- mmm...anonymous types
.ToList() -- mmm...extension methods - Hit F5
WPF Goodness + VS "Orcas" design-time Goodness + Linq goodness = happiness
mmm...

2 comments:
Hey, Kevin,
I tried following your steps, but I did not achieve happiness ;-). I got to where I do "New Project..." and pick "WPF Application", but when I click OK, I get:
The project file "[real long path]\Foo.csproj" cannot be opened. The project type is not supported by this installation.
I did this on Vista. The machine had .NET 3.0 on it before I installed, in case that matters. I didn't get any errors during installation.
Thanks,
Eric
I'm new to Linq and the new language features, but to me as an enthusiastic C# (and Java) developer, I'm not keen on the syntax in your example. It looks kind of obscure like Perl or Python can sometimes. I'm all for concise syntax but not at the expense of clarity...
Post a Comment