Marquee de Sells: Chris's insight outlet via ATOM 1.0 csells on twitter

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.




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.

0 comments




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.

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.

0 comments




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:

Enjoy!

0 comments




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

0 comments




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!

0 comments




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...

0 comments




.NET 3.0 RC1 Download

This one should be about done:

Enjoy!

0 comments




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.

0 comments




$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.

0 comments




USB MP3 Player + SD Card = Gadget-o-licious

The sound quality ain't that great, but don't criticize the dog for being off key...

0 comments




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?

0 comments




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:

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.

0 comments




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.

0 comments




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 blogarticles and tools aren't listed and nobody's mentioned the interview questions, but it's there. I'd like to thank the academy...

0 comments




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?).

0 comments




2275 older posts       360 newer posts