You've reached the internet home of Chris Sells, who has a long history as a contributing member of the Windows developer community. He enjoys long walks on the beach and various computer technologies.
Friday, Oct 6, 2006, 10:14 AM in .NET
WPF: Enabling Crimes Against Nature in a Good Way
My friend Jeff asked me to do a terrible thing yesterday: "How do I show a form in the popup window that a menu shows?" I said, "Dude! Don't do that -- write a dialog!" And that's what he did, but then, like a train wreck, I couldn't look away. It took me all of 10 minutes of very straight forward coding and here we are:
If you're familiar with WPF, data binding and data templates, this is all standard stuff. Here's the data structure:
class Person : INotifyPropertyChanged
{
string name;
public string Name
{
get { return name; }
set { name = value; Notify("Name"); }
}
int age;
public int Age
{
get { return age; }
set { age = value; Notify("Age"); }
}
public event PropertyChangedEventHandler PropertyChanged;
void Notify(string prop) { if( PropertyChanged != null ) { PropertyChanged(this, new PropertyChangedEventArgs(prop)); } }
}
The data template is also bog standard:
<DataTemplate DataType="{x:Type local:Person}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0">_Name</Label>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name}" />
<Label Grid.Row="1" Grid.Column="0">_Age</Label>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Age}" />
</Grid>
</DataTemplate>
Setting up the app itself is nothing special:
<Window ...>
<Window.Resources>
<DataTemplate DataType="{x:Type local:Person}">
...
</DataTemplate>
</Window.Resources>
<Grid>
<Menu>
<MenuItem Header="File">
<MenuItem Header="Exit" x:Name="fileExitMenuItem" />
</MenuItem>
<MenuItem Header="Form" ItemsSource="{Binding}" />
</Menu>
</Grid>
</Window>
Notice that the items that make up the menu come from a binding to the ambient data source, which we set in the code-behind:
protected override void OnInitialized(EventArgs e)
{
...
Person tom = new Person();
tom.Name = "Tom";
tom.Age = 11;
DataContext = new Person[] { tom };
}
The only thing at all tricky is that, even though we're only editing a single object in the "popdown window," it has to be in an implementation of IEnumerable so that the menu can display it (it expects items to come in a list).
That's it. You can download the RC1 WPF project here.
You might wonder why I would post such a sample, when clearly that's not a UI we want to foster on folks. The answer is simple: because WPF allows it.
The power of any platform should be judged by how well it lets you write bad code. Early versions of Visual Basic let you write really bad code -- but it worked. Likewise, WPF lets me build the worst UIs ever -- but they work. This is necessary so that UI visionaries can experiment and get to a place where they're doing something completely different from UIs of today and we like it.
Do you think the Office folks, who, for all practical purposes, have been setting UI guidelines on Windows for a decade, could use MFC or Windows Forms? No, because they're not flexible enough. Could they use WPF? Absolutely they could. And so can you.
The crayon box has lots of colors that I don't like, but in the hands of an artist, they can create beauty.
Monday, Oct 2, 2006, 11:41 AM in Fun
Teaching Kids To Do Cool Computer Stuff?
My youngest son's teacher found out I work at MS, so now he expects me to come into his class to teach them cool stuff. I'm happy to do that, but now I'm worried about putting together a cool 1-4 hours of stuff to do, e.g.
- Cool PowerPoint stuff (wowing their classmates)
- Cool Excel stuff (doing their math homework)
- Cool Web stuff (building their own web site)
- Cool Programming stuff (writing their own PC/XBox 360 games)
- Cool Hardware stuff (programming a robot)
Obviously, I'm not the first person to want to teach kids how to do cool stuff w/ their computers. Can someone point me at some activities for a classroom for of kids to do in these (or other) categories? Thanks!
P.S. My son is a 6th grader, making his class 11 and 12 year olds.
Sunday, Oct 1, 2006, 3:10 PM in .NET
Sept CTP of .NET 3.0
The CTPs are coming so fast and so furious now that I nearly missed the September 2006 .NET Framework 3.0 CTP:
- Release Notes
- .NET Framework
- SDK
- VS05 Integration for WCF and WPF
- VS05 Integration for WF
- Cider Release Notes
Enjoy!
Sunday, Oct 1, 2006, 3:01 PM in Fun
Null Pointers Don't Have To Be <i>Dull </i>Pointers
Posted without permission after reading
it in
today's paper
Sun 10/01/2006 3:01pm
Wednesday, Sep 27, 2006, 4:42 PM in The Spout
Horning in on Hanselminutes
It took a while, but I was finally able to horn in on an episode of Hanselminutes. Thanks for having me, Scott!
Friday, Sep 8, 2006, 11:31 AM in The Spout
Amazon Unbox -- what about my TV?
I don't want to download movies via Vongo or Amazon Unbox to my PC; I want to download them to my TV and smart phone! YouTube works because the videos are short, so watching them on my PV happens right now or not at all. Any movie or TV show service that doesn't let me play the result on my media center or take it with me on my phone, I just don't care. Does anyone want to watch 30+ minutes of video sitting at their desk or staring at their lap? I don't get it...
Thursday, Sep 7, 2006, 9:18 AM in .NET
.NET 3.0 RC1 Download
This one should be about done:
- .NET 3.0 RC1 Release Notes
- .NET 3.0 RC1 Framework Components
- .NET 3.0 RC1 SDK
- .NET 3.0 RC1 VS05 Tools (including Cider)
- .NET 3.0 RC1 SDK online
Enjoy!
Tuesday, Sep 5, 2006, 11:34 AM in The Spout
Congrats To Mr. Petzold on this WPF Review
In the world of Windows technical writing which has so much competition, there's rarely any money involved, one dreams for reviews like these from KarstenJ:
"Tim Sneath walked into my office the other day and laid Charles Petzold's Applications = Code + Markup on my desk. I'm only to Chapter 7 of 31 chapters and I am riveted. I already have that feeling when reading a great novel when you don't want it to end. It actually does read like a novel to me, with a narrative arch as it negotiates its methodical way through the WPF jungle of APIs."
Congrats, Charles.
Thursday, Aug 31, 2006, 7:47 PM
$366 PC scores 2.9 on the Vista-o-meter
I installed the "almost" RC1 of Vista onto my $366 PC and I've finally got sound! In addition, I've got the real transparent Aero effects and playback of my .msdvr files (Media Center recorded TV shows) over the network. The "experience" scores out at only 2.9, but only 'cuz of my crappy CPU (1.67 GHz) and the video card (although it does real-time video and Aero -- what more should it do?!?). The DVD video playback worked but not the audio, which was one of very few glitches (another was that it doesn't show video on Google videos).
I'm running Vista Ultimate, and while I can't tell what's "ultimate" about it, it feels about time to make Vista the OS on my main computer. Certainly my sons like it on their computer, which is the real test.
Wednesday, Aug 30, 2006, 3:09 PM in Fun
USB MP3 Player + SD Card = Gadget-o-licious
- USB SD/MMC MP3 Player + Card Reader + S/H: $18
- Kingston 1GB miniSD Card + S/H: $19 (at the time)
- Being able to listen to Teenage Dirtbag on the same device that I can use as a 1GB USB HD and SD, mini-SD, MMC, RS-MMC and T-FLASH reader/writer: $37 (duh -- $18 + $19 -- you thought I was going to say "priceless" didn't you?)
The sound quality ain't that great, but don't criticize the dog for being off key...
Wednesday, Aug 30, 2006, 2:49 PM in Fun
Develop Games For Your Xbox 360
The Microsoft XNA Game Studio Express (Beta) is available for download:
"XNA Game Studio Express enables individuals and small teams to more easily create video games using new, optimized cross-platform gaming libraries for Windows and Xbox 360. This beta release targets the development of games for Windows. The final version of XNA Game Studio Express will be available this holiday season and will enable development of games which target Windows and upon purchase of a XNA Creators Club subscription, the Xbox 360 as well."
Has any other console vendor every let an individual develop games?
Wednesday, Aug 30, 2006, 7:50 AM in Tools
If it can be installed, Scott's installed it
and if it's any good, we hear about it. Really, I'm just posting this link to Scott Hanselman's 2006 Ultimate Developer and Power Users Tool List for Windows here so I can find it later, but feel free to browse the list yourself, broken up into several interesting categories:
- Top 10 (+ 5) Life/Working-Changing Utilities
- A Developer's Life
- COM is Dead [ed: if only]
- XML/HTML Stuff
- Regular Expressions
- Launchers
- Stuff Scott Digs
- Low-Level Utilities
- Websites/Bookmarklets
- Tools for Bloggers
- Smart People's Utility Pages
- Alt.Lang
- Browser Add-Ins
- Things Windows Forgot
- Outlook Add-Ins and Life Organizers
- Ultimate Registry Tweaks
- Windows Explorer Integration (and other integratey things)
- Continuous Integration
- TablePC Indispensables
- ASP.NET Must Haves
- Visual Studio Add-Ins
Notice how just his list of categories is longer than most people's lists? Scott's a gem. Guaranteed you'll find something that makes your life better.
Tuesday, Aug 29, 2006, 7:51 AM
100,000 downloaders get pre-RC1 Vista
If you're interested in the "same build (5536) released last week to Technical Beta and TAP customers" (according to Shawn Van Ness), you and 99,999 of your closest friends can download the pre-RC1 of Vista.
Monday, Aug 28, 2006, 8:35 AM in Fun
Wikipedia has an open enrollment day...
Right there next to Don Box, Jeffrey Richter, Robert Scoble, Charles Petzold, Keith Brown is the Chris Sells Wikipedia page. There aren't any pictures (not this one or this one or even this one), the blog, articles and tools aren't listed and nobody's mentioned the interview questions, but it's there. I'd like to thank the academy...
Sunday, Aug 27, 2006, 2:15 PM in Fun
Fun Presentation
In massive writing avoidance mode, I found my way to Seth Godin (who I don't know from Adam) doing a great presentation on stuff that's broken at Gel 2006 (I conference I've never heard of) as a way to promote his site. I found the presentation itself at Presentation Zen, when I read about in Guy Kawasi's essay on The 10/20/30 Rule of PowerPoint, which I found on the sidebar of the Startup Success 2006, which I got to from the Churchill Club web site. I can't for the life of me remember how I got to the Churchill Club web site, but it killed a lot of time (did I mention I was in writing avoidance mode?).