Tips for Dealing with New and Missing Windows 8 XAML Controls
Although the Windows 8 XAML platform brings back a lot of the controls that exist in WPF and Silverlight, and adds some completely new ones, there are some controls that you might find missing and wonder what to do. In this article we cover a list of some of these controls, along with some suggested ways to cope with their loss.
Both WPF and Silverlight include a Calendar control that can be used to select dates, but also display additional content for special days. This control is missing in Windows Runtime, but luckily there is an open source version in Silverlight Toolkit and I ported it to Windows 8, so you can grab it from CodePlex here.
It has been argued that the DataGrid does not fit well into touch-centric Metro design applications and ListViews should be used instead; however, there might still be cases where a DataGrid would work best and some component vendors already make it available for a fee.
This control is used for selecting dates, and both WPF and Silverlight versions allow users to pick a date from a calendar. You could implement something similar based upon the Calendar control mentioned above, or you can port the version for Windows Phone from the Silverlight Toolkit, which provides a large view of a date where you can swipe through days, months or years to select a date. You can get a commercial version from one of the popular component vendors that is similar to the Windows Phone version.
The DockPanel harkens back to the Windows Forms times where docking was one of the primary means of laying out controls, and it is still used for applications with a customizable UI, such as Visual Studio. It does not seem to fit the Metro design language too well; however, should you find the need to use it, there is a version in the Silverlight Toolkit that you could port to Windows 8.
This control is not in Silverlight or WPF, but it is in the HTML stack for Windows 8, so I thought I would mention it. The XAML stack has a Popup control, which does provide the base support of what Flyout does. In case you want a control with built-in support for simple Cartesian coordinates positioning, you can find one implemented in the Callisto library.
The GridSplitter is also arguably not suitable for touch interfaces, and in many cases can be substituted by using a ScrollViewer or a GridView to enable you to look at different parts of your UI. Should you find a real need for it however, there is a CustomGridSplitter control in the WinRT XAML Toolkit that works the same way a GridSplitter does in WPF or Silverlight, but it is styled to be a bit wider and touch friendly.
There is no InkCanvas class in Windows 8, but you could use the InkRecognizer class to capture inking and simply convert the captured strokes into paths to add to a Canvas panel and additionally get support for recognition.
The old style menus are already in decline in the desktop world, slowly replaced with ribbon controls, and Windows 8 goes even further by giving you app bars and setting charm that go away completely when not needed. In case there are still cases when it feels like one would be useful and neither the app bar buttons or the settings charm commands work for you, Tim Heuer provides a Menu control in his Callisto library here.
Deep Zoom support is not available on Windows 8 yet, but with some work you might be able to port the WPF implementation from Code Project or use VirtualSurfaceImageSource and implement it in DirectX.
There are times when you need to enter a numeric value and the provided Slider control is not enough. For example, you may want to display the value all of the time, use different formatting or just be able to copy and paste the value. There is no built-in control like that provided, but the WinRT XAML Toolkit does provide one that you could use or extend that can also be dragged in a similar way to the value controls in Expression Blend.
The WPF and Silverlight TabControl serve a similar purpose to Pivot or Panorama controls on Windows Phone – to extend the number of controls available beyond the dimensions of the screen and easily switch between pages of these controls. In Windows 8 XAML none of these controls are available, and instead you can either use a GridView with groups or a FlipView (you can add headers to the FlipView by using a StackPanel with RadioButtons styled with TextRadioButtonStyle or a ListBox bound to the same ItemsSource as the FlipView and with their SelectedItem properties bound two ways).
There is no TreeView available. The recommended way to implement this feature is to do what the file pickers do with the folder trees: display contents of one tree level on a screen at a time and allow them to navigate toward the root or the leaves.
Viewport3D, D3DImage, DrawingSurface
These classes enable rendering 3D content in WPF and Silverlight applications using very different methods (respectively: XAML-centric object model for 3D primitives, ImageSource class for Direct3D9 integration and a control rendered with XNA). Windows 8 XAML takes yet another approach with three different methods for three different scenarios, all based upon DirectX 11.1 integration. Using DirectX also has the benefit of enabling high performance, high quality 2D rendering and using pixel shaders with Direct2D.
- SurfaceImageSource is an ImageSource that you can use in an ImageBrush or an Image control to render content with DirectX to a limited section of the screen.
- VirtualSurfaceImageSource extends SurfaceImageSource with support for very large rendered surfaces, such as very high resolution images, maps etc.
- SwapChainBackgroundPanel is a panel used for highest performance, full screen scenes rendered with DirectX that have some XAML-based controls overlaid on top.
WrapPanel is not available, but VariableSizedWrapGrid is, it is a bit similar and could be substituted in many cases. Otherwise, porting the WrapPanel from Silverlight Toolkit might be a simple solution.
There are quite a few controls missing from the new Windows 8 XAML platform, but as you can see, commercial component vendors as well as the open source community are quickly filling the gap. Some controls can and should be replaced with alternatives native to Windows 8. There are a few cases where you need to do some more work to achieve what you could with say Silverlight, but everything you need is still within reach.
Safari Books Online has the content you need
Below are some Windows 8 books to get you started, or you can check out all of the Windows 8 books and training videos available from Safari Books Online.
If you are not a subscriber, start your Safari Books Online free trial.
|Building Windows 8 Applications with C# and XAML shows you how to build immersive, responsive touch apps for Windows 8 tablets, computers, and other devices! Top Microsoft MVP and Wintellect consultant Jeremy Likness shows how to leverage your existing C#, XAML, WPF, or Silverlight skills with new Visual Studio 12 tools and best practices to build incredibly powerful Windows 8/WinRT apps!|
|Get a head start on building apps for Windows 8. With a series of examples, Getting Started with Windows 8 Apps takes you through the process of creating complete touch-enabled apps that respond to native sensors. Through the course of the book, you’ll learn how to work with the Windows Runtime application model while building a Bing Image Search app.|