It's been a while since the May CTP of Avalon went out the door. We called it "Beta 1 RC" whatever that means -- I rather expected a true "Beta 1" would soon follow, but apparently the doc folks are still catching up -- it's beginning to look like we'll fork a build for the PDC (based on much newer bits!) before "Beta 1" sees light of day. Oh well, would a CTP by any other name not smell as sweet?
Back in March, I promised new and better things for Tablet PC application developers targeting Avalon. So, I guess I'll go ahead and start blogging about it...
The big news in Beta 1 (aka the May CTP) is that InkCanvas and its associated object model are now all part of the mainline Avalon assemblies, PresentationCore and PresentationFramework -- TabletCore and TabletFramework no longer exist!
<!-- No special assembly refs or namespace mappings needed --> <Grid xmlns="http://schemas.microsoft.com/winfx/avalon/2005"> <InkCanvas Background="LinearGradient 0,0 1,1 Ivory Beige" /> </Grid>
This makes life with InkCanvas a whole lot easier -- no special Mapping PI's are needed, unless you wish to set a property (like DefaultDrawingAttributes) whose type isn't one mapped in by the XAML parser by default. The following XAML demonstrates how to get at this property, by mapping in the System.Windows.Ink namespace:
<!-- Define namespace mapping req'd for DrawingAttributes type --> <?Mapping XmlNamespace="system-windows-ink" ClrNamespace="System.Windows.Ink" Assembly="PresentationCore"?> <Grid xmlns="http://schemas.microsoft.com/winfx/avalon/2005"> <InkCanvas Background="LinearGradient 0,0 1,1 Ivory Beige"> <InkCanvas.DefaultDrawingAttributes> <ink:DrawingAttributes xmlns:ink="system-windows-ink" Color="Purple" StylusTip="Ellipse" Width="5" Height="9" /> </InkCanvas.DefaultDrawingAttributes> </InkCanvas> </Grid>
InkCanvas vs. InkPicture, InkOverlay, InkCollector?
Developers experienced with the traditional Tablet PC platform (COM or WinForms) will no doubt wonder how InkCanvas compares to (take your pick) InkPicture, InkOverlay, or InkCollector. The short answer: it's like InkPicture, inasmuch as it's a ready-made framework element designed to be dropped into your app... however (long answer coming) its behavior is more akin to an InkOverlay with AttachMode property set to InFront. Why?
Avalon is fundamentally different from Win32 in its support for overlapping sibling elements. Indeed, the inability to render overlapping child elements with non-rectangular shape and/or partial transparency, flicker-free, is one of the motivating factors to ditch the Win32 model in favor of something new like Avalon. (Ian G covers this in great detail here.)
This changes the way one must think about things like InkCollector and InkOverlay. In Win32, any given point on the screen belonged to exactly one window -- so you could attach an InkOverlay to a specific HWND, and ink would be collected there -- and only there -- not over any child windows. If you wished to collect ink over the top of child windows, you could set InkOverlay's AttachMode property to InFront, which would effectively create a transparent overlay window over the top of all the child windows, and collect ink over all of them.
But the flexiblity of Avalon composition allows InkCanvas to behave both ways (or even in some combination of the two) based simply on the logical arrangement of child and sibling element in the XAML tree: we collect and render ink over child elements, but not over sibling elements (if they're higher in the z-order). So, to get an experience more like the COM/WinForms default InkOverlay, simply position your would-be child elements as siblings of InkCanvas, somewhere later in the tree:
<Grid xmlns="http://schemas.microsoft.com/winfx/avalon/2005"> <InkCanvas Background="LinearGradient 0,0 1,1 Ivory Beige"/> <!-- This stackpanel of buttons is a sibling to InkCanvas (not a child) but overlapping it, higher in z-order, so that ink is collected and rendered behind --> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="15"> <Button>Ink</Button> <Button>Highlight</Button> <Button>Erase</Button> <Button>Select</Button> </StackPanel> </Grid>
PDC, Beta 2 and Beyond
"InkCanvas is great, but I want to develop my own ink collection and custom rendering" you may say.
"What about handwriting recognition?" you may ask.
Again, this is where I must leave you hanging -- we've made extensive changes to the real-time stylus plugin model, post Beta 1, and the Ink Analysis team is busy finalizing work on the new handwriting reco SDK. The details of how this will plug into our Avalon ink platform are still being hashed out. Stay tuned!
