<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Okoboji: a lake, a mythical university, Kevin Moore's blog : PDC05</title><link>http://blogs.msdn.com/okoboji/archive/tags/PDC05/default.aspx</link><description>Tags: PDC05</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>PDC: demos, posters, pictures</title><link>http://blogs.msdn.com/okoboji/archive/2005/09/18/pdc-demos-posters-pictures.aspx</link><pubDate>Sun, 18 Sep 2005 23:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:470941</guid><dc:creator>okoboji</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/okoboji/comments/470941.aspx</comments><wfw:commentRss>http://blogs.msdn.com/okoboji/commentrss.aspx?PostID=470941</wfw:commentRss><description>
&lt;p&gt;I got back yesterday from the PDC. It was a great trip. As promised, I’m posting the demo code for my talk.&lt;br&gt;&lt;br&gt;This zip contains each stage of my ColorPicker demo:&lt;br&gt;0) A simple UserControl that uses standard CLR properties and INotifyPropertyChanged&lt;br&gt;1) A conversion of 0) to use DependencyProperty and Binding&lt;br&gt;2) A conversion of 1) to be a Control with a simple template&lt;br&gt;2.1-2.3) Examples of different custom templates.&lt;br&gt;&lt;br&gt;&lt;i&gt;Same control, different templates.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;As I mentioned in my talk, make sure you check out the SDK for &lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/wcp_conceptual/html/c52dde45-a311-4531-af4c-853371c4d5f4.asp" mce_href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/wcp_conceptual/html/c52dde45-a311-4531-af4c-853371c4d5f4.asp"&gt;guidelines for building stylable controls&lt;/a&gt; and &lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/wcp_conceptual/html/ecb97ed4-e659-48a4-a1e0-893309569f2f.asp" mce_href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/wcp_conceptual/html/ecb97ed4-e659-48a4-a1e0-893309569f2f.asp"&gt;more information about external control libraries with embedded default styles&lt;/a&gt; (written by &lt;a href="http://notstatic.com/" mce_href="http://notstatic.com/"&gt;Robby&lt;/a&gt; and me respectively). &lt;br&gt;&lt;br&gt;&lt;a href="http://notstatic.com/" mce_href="http://notstatic.com/"&gt;Robby&lt;/a&gt; and I had fun designing our team t-shirt and poster. If you're looking for a cool desktop (or if you want to print your own poster) I've included a big PNG and a PDF (I will have to work to post an XPS or my team will probably hunt me down.)&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Here’s (most of) the team after the last presentation. We had a great time.&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=470941" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/okoboji/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/PDC05/default.aspx">PDC05</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Custom Panel: TreeMapPanel</title><link>http://blogs.msdn.com/okoboji/archive/2005/09/15/custom-panel-treemappanel.aspx</link><pubDate>Thu, 15 Sep 2005 21:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:463500</guid><dc:creator>okoboji</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/okoboji/comments/463500.aspx</comments><wfw:commentRss>http://blogs.msdn.com/okoboji/commentrss.aspx?PostID=463500</wfw:commentRss><description>
&lt;p&gt;TreeMaps have been all the rage. I figured it would be cool to see how easy it would be to build such a thing in WPF.&lt;/p&gt;

&lt;p&gt;It turns out that getting started in pretty easy. There are a number of implementations of TreeMaps around. I found a Java one that looked like a good place to start. After a bunch of editing and debugging I had an algorithm that worked pretty well. The trick was fitting it into the Panel paradigm in WPF.&lt;/p&gt;

&lt;p&gt;The model for Panels in WPF is attached properties. You drop in a bunch of children and then you assign Panel-specific properties. Canvas: Left and Top. Grid: Column and Row. DockPanel: Dock. Pretty simple.&lt;/p&gt;

&lt;p&gt;For TreeMapPanel the obvious property to expose was Area. A TreeMap will lay out its children so that they fill the space and their respective areas stay proportionate. That's what I did with my panel. The only thing left was to throw some data at it. Similar to my &lt;a href="http://blogs.msdn.com/okoboji/archive/2005/09/09/463324.aspx" mce_href="http://blogs.msdn.com/okoboji/archive/2005/09/09/463324.aspx"&gt;FolderPicker demo&lt;/a&gt;, I created a data object to generate a directory and file structure.&lt;/p&gt;

&lt;p&gt;&lt;font color="#ff0000"&gt;&lt;b&gt;NOTE: I hard-wired a path in Data.cs. Make sure you change it to a directory that actually exists on your computer. You may also want to pick a shallow directory (without many nested sub-directories.) My default style makes heavy use of Viewbox which gets expensive when they are nested.&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Props to my friends at UMD for the &lt;a href="http://www.cs.umd.edu/hcil/treemap-history/" mce_href="http://www.cs.umd.edu/hcil/treemap-history/"&gt;starting spot&lt;/a&gt;. Make sure if you reuse my code you stay compliant with their original license.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=463500" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/okoboji/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/PDC05/default.aspx">PDC05</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Building a folder picker in WPF</title><link>http://blogs.msdn.com/okoboji/archive/2005/09/14/building-a-folder-picker-in-wpf.aspx</link><pubDate>Wed, 14 Sep 2005 22:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:463324</guid><dc:creator>okoboji</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/okoboji/comments/463324.aspx</comments><wfw:commentRss>http://blogs.msdn.com/okoboji/commentrss.aspx?PostID=463324</wfw:commentRss><description>The &lt;a href="http://blogs.msdn.com/okoboji/archive/2005/06/02/424122.aspx" mce_href="http://blogs.msdn.com/okoboji/archive/2005/06/02/424122.aspx"&gt;last time&lt;/a&gt; I blogged about TreeView, I was still using the control I personally implemented. Now that WPF actually has a TreeView, lets talk about how to use it.&lt;br&gt;&lt;br&gt;The first thing you’ll notice is that the API for what we shipped is pretty identical to what I blogged. (Guess who wrote the spec for WPF TreeView.) Thankfully I had a brilliant developer that implemented the tough stuff like selection and keyboard navigation.&lt;br&gt;&lt;br&gt;You may notice that TreeView seems to be missing things you’ve grown to expect: explicit support for checkboxes and images. This was not an oversight. We felt that it was actually limited to provide these features explicitly when it’s so easy to add them directly. It’s the same reason Button in WPF doesn’t have Text, Image, TextAlign, ImageAlign properties. Button has a Content property that can be anything. Put in your own Panel with your own elements. We don’t need to hardwire them for you.&lt;br&gt;&lt;br&gt;So enough background. What are we building?&lt;br&gt;&lt;br&gt;Three things to look at:&lt;br&gt;&lt;br&gt;&lt;b&gt;1) Data.cs&lt;br&gt;&lt;/b&gt;You’ll notice a couple of classes: LocalDrives and SelectableDirectory. Both implement INotifyPropertyChanged. Both expose a bunch of properties. If you dig into SelectableDirectory, you’ll notice a bunch of wiring to handle and propagate changes to IsSelected. If a nested directory becomes selected the change bubbles up the directory hierarchy through recursive listeners to PropertyChanged events. These allow each level of the tree to maintain the ChildSelection property for SelectableDirectory and SelectedDirectories collection for SelectableDirectory and LocalDrives.&lt;br&gt;&lt;br&gt;Important thing here: These classes are purely data. There are no references to UI concepts. Just logic to instantiate data structures against the file system and properties and events to the data structures in sync.&lt;br&gt;&lt;br&gt;&lt;b&gt;2) Window1.xaml&lt;br&gt;&lt;/b&gt;A couple things here. First, the ObjectDataProvider in the resources section. This maps to the LocalDrives object we defined in Data.cs. Second, take a look at the UI. A TreeView and a ListBox in a Grid (which is in a ViewBox). The Grid has a DataContext defined that points to the ObjectDataProvider. The TreeView is bound to the Drives property. The ListBox is bound to the SelectedDirectories property. (They both inherit the LocalDrives DataContext defined in Grid.)&lt;br&gt;&lt;br&gt;Notice that both Drives and SelectedDirectories are collections of SelectableDirectory. By default, both TreeView and ListBox would just display these items by wrapping them in a TextBlock and with the result of ToString() as the Text. Instead, you see that both define an ItemTemplate. Where are these ItemTemplates defined? Take a look at MyApp.xaml.&lt;br&gt;&lt;br&gt;&lt;b&gt;3) MyApp.xaml&lt;br&gt;&lt;/b&gt;There are a bunch of entries in the Resources section of MyApp.xaml. First, two DataTemplates.&lt;br&gt;&lt;br&gt;The first of the DataTemplates is for the ListBox and it’s pretty straight forward. It’s defined for SelectableDirectory and simply contains a TextBlock that binds to the Path property of SelectableDirectory. No rocket science here.&lt;br&gt;&lt;br&gt;The second of the DataTemplates is for the TreeView. This is a special DataTemplate--a HierarchialDataTemplate. I first &lt;a href="http://blogs.msdn.com/okoboji/archive/2005/05/23/421273.aspx" mce_href="http://blogs.msdn.com/okoboji/archive/2005/05/23/421273.aspx"&gt;discussed&lt;/a&gt; HDT in May. I’m doing pretty much the same thing here, but this time I get a bit more sophisticated. Besides having a TextBlock bound to the Name property, I also create a CheckBox is bound to the IsSelectedProperty. The rest of the magic happens in the Triggers Section. I set up Triggers to change the FontStyle and FontWeight of the TextBlock to reflect the ChildSelection of each directory. I also use a Trigger to swap out the Template used to draw the icon Control.&lt;br&gt;&lt;br&gt;&lt;b&gt;Why is this all cool?&lt;/b&gt;&lt;br&gt;First, completely separated business logic and UI. My code handles all of the state for my directories and drives without worrying about the UI implementation. You could have thrown the data layer over the fence as a DLL to a designer and she could have developed the UI.&lt;br&gt;&lt;br&gt;Second, you don’t need checkbox or image support in TreeView. You want two checkboxes? Cool. You want three images? Fine. Want to change their orientation? No problem. Build what you want, use our controls, stay away from OnRender/OnPaint/OwnerDraw.&lt;br&gt;&lt;br&gt;Sound good?&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=463324" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/okoboji/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/PDC05/default.aspx">PDC05</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/WPF/default.aspx">WPF</category></item><item><title>4 days till the PDC. Are you excited?</title><link>http://blogs.msdn.com/okoboji/archive/2005/09/09/463269.aspx</link><pubDate>Sat, 10 Sep 2005 07:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:463269</guid><dc:creator>okoboji</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/okoboji/comments/463269.aspx</comments><wfw:commentRss>http://blogs.msdn.com/okoboji/commentrss.aspx?PostID=463269</wfw:commentRss><description>&lt;P&gt;I had my final dry-run for my talk today: &lt;A href="http://commnet.microsoftpdc.com/content/sessionview.aspx?TopicID=4ffa038b-81c0-48c9-b7d4-b50cf56e0e72"&gt;PRS431 Custom Controls in WPF&lt;/A&gt;. If you have a free slot on Friday at 10:30, stop by. Room 402.&lt;/P&gt;
&lt;P&gt;Part of the preparation for the PDC is uploading our slide decks to a common share so that they get down to LA and get on the presentation machines. When I uploaded my deck I couldn’t help but take a look through the scores of PPT files from other presenters.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;We are showing a lot of amazing technology&lt;/STRONG&gt;. Microsoft is a big company. There are amazing new features for products I didn’t know we were even working on. I was blown away just reading slide bullets. PDC could be three weeks long and you couldn’t consume all of the technology. It’s impressive.&lt;/P&gt;
&lt;P&gt;FYI: my manager has started blogging. To quote her first post, Namita has “worked on various technologies in the platform including Property engine, databinding, styling, templating, commanding and controls.”&lt;/P&gt;
&lt;P&gt;She’s an expert on a lot of technologies in WPF. Check out &lt;a href="http://blogs.msdn.com/namitag/default.aspx"&gt;her blog&lt;/A&gt; and check out &lt;A href="http://commnet.microsoftpdc.com/content/sessionview.aspx?TopicID=9e0a39c7-0f6d-42dc-aa68-e0c6cab6c3dd"&gt;her talk&lt;/A&gt; on Thursday.&lt;/P&gt;
&lt;P&gt;I’ll be posting samples for the PDC build all next week--some really exciting stuff I’ve been holding on to for a while.&lt;BR&gt;Stay tuned and if you’re going to the PDC, stop by the Presentation Lounge in LA and say hi.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=463269" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/okoboji/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/PDC05/default.aspx">PDC05</category><category domain="http://blogs.msdn.com/okoboji/archive/tags/WPF/default.aspx">WPF</category></item></channel></rss>