|
||||||||||||||||||||
|
AutoCompleteBox An AutoCompleteBox generally looks like a textbox but it can be styled to look like a ComboBox.
The AutoCompleteBox has an ItemsSource property which can be set to the collection of valid values from which the user is permitted to choose. The AutoCompleteBox can even use a Web Service call to generate a context sensitive list of alternatives to present to the user. One example illustrated in the Silverlight Toolkit Sample Collection (discussed below) involves a Web Service call to Microsoft Live Search. In either case, once the user begins to type, a list of acceptable options appears in a drop down list. This list can be styled in any fashion that you prefer. Using multiple elements in the drop down list, as shown in the following screenshot, can be accommodated by setting the ItemTemplate property with a DataTemplate containing multiple XAML elements.
Not only can the AutoCompleteBox facilitate user selection from a fixed list of valid responses but it can also reduce the user's required typing if the IsTextCompletionEnabled property is set to True (the default). This option affords the familiar down arrow and tab completion procedure. The AutoCompleteBox supports three different SearchMode options: Contains, StartsWith (the default) and StartsWithCaseSensitive. If the SearchMode property is set to Contains, matching text in the drop down list of acceptable alternatives can be styled to highlight the user entered text. Theming
Each theme is essentially a large XAML file containing custom modifications of the default styles and templates for many of the Silverlight controls: Button, Slider, etc. Although the raw XAML for the individual themes is available in a collection of resource dictionaries, developers normally would simply use the pre-built assemblies containing a specific theme. You can apply a theme to anything from a single control up to your entire application element tree. Since the theme classes are ContentControls, you apply them by making the target element(s) the content of a theme instance. The theming system is implemented using the new ImplicitStyleManager (ISM) static class. ISM mimics the implicit styling behavior built into WPF, but not yet directly implemented in Silverlight. Essentially ISM walks an element's tree of logical descendents applying a given set of styles. Since the style of a Silverlight element can only be set once in an element's lifetime, if you want to change themes dynamically at runtime, you need to recreate a fresh copy of the element tree or subtree to which the theme is applied. Another characteristic of ISM is that it will not apply a style inside any nested UserControls that it encounters. This is demonstrated in the theming screenshot, above, where in each case the nested UserControl retains its blue border and gold background. This is because the nested UserControl lives in its own separate namescope outside the logical tree to which ISM is applying styles. Although the UserControl is in the parent's visual tree, it is not in its logical tree. If desired, one way to apply theming to a nested UserControl would be to set an additional theming container around the nested UserControl. The Silverlight Toolkit Help File and Sample Collections As most experienced developers well know, one of the most efficient techniques for writing code is to mark up a good piece of sample code to tailor it to the specifics of the current task. For this reason, the authors of the Silverlight Toolkit have included a very large set of sample applications.
This sample collection includes a lot of explanatory text in addition to extensive code examples. The sample collection is exposed both in the form of a compiled Silverlight application and as a multi-project Visual Studio solution. The compiled application is the most convenient format for learning about the various controls as the application is structured to explain each of the key elements for included controls. For additional details not described by the compiled application, one can refer to the underlying project. Overall, the sample collection represents an enormously useful structure for learning about and using the Silverlight Toolkit controls. There is also a second collection of samples in the Silverlight Toolkit, this one devoted to charting samples.
The charting sample collection is organized in the same manner as the sample collection for the other Silverlight Toolkit controls. There exists another important resource for Silverlight charting, namely the ChartBuilder application available from David Anson's Blog. This application affords a structure which allows you to experiment with different properties of the various Silverlight Toolkit charts. With live feedback, you can change a value and see exactly what impact this change has on your chart.
Notice too how the textbox in the lower right corner of the ChartBuilder application (below the chart itself), contains the XAML which corresponds to the property value selections which you have made. Once you have designed the chart in the manner that you want, you can copy and paste the generated XAML into your own application. Summary None of the controls contained in the first release of the Silverlight Toolkit are yet in release to web (RTW) condition. A key goal of the Silverlight Toolkit is to make unfinished controls available to Silverlight developers at an early stage in order to solicit comments, suggestions and bug reports. The hope is that this will result in both a shorter development cycle and better quality controls. While some of the controls in the Silverlight Toolkit are not particularly exciting (e.g. Label, NumericUpDown) others such as those highlighted in this article (TreeView, Charting and AutoCompleteBox) are actually very impressive. In addition, the Silverlight Toolkit includes theming support which can be very easily applied to all or any portion of Silverlight content. Links * This article was commissioned by and prepared for Microsoft Corporation. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
|
||||||||||||||||||||
|
Cal Schrotenboer is a C# developer with experience in building Windows Forms
application front ends for SQL Server databases. He also teaches programming classes at Foothill College in Los Altos Hills, California and Microsoft Network Administration (MCSE) classes at Mission College in Santa Clara. Cal maintains a WPF blog at www.WPFLearningExperience.com. His outside interests include travel
and photography (www.travelswithcal.com).
| ||||||||||||||||||||
|
Alan Cobb is an independent consultant specializing in .NET programming in C# for Silverlight and WPF. He has been a consultant for over 20 years in using Microsoft systems and languages, doing contract work for clients including Oracle and Microsoft. Alan has a Silverlight/WPF technical blog at www.alancobb.com/blog.
|
||||||||||||||||||||
|
||||||||||||||||||||
|
|