Silverlight
Note This topic is specific to Silverlight 3. To learn WPF compatibility with Silverlight 4, see WPF Compatibility.
If your Silverlight application specifically targets Silverlight 3, there are a different set of WPF compatibility issues than the issues described in WPF Compatibility with Silverlight 4. This topic lists the prominent WPF and Silverlight compatibility differences for applications that target Silverlight 3.
This topic contains the following sections.
- WPF Features Not in Silverlight
- WPF Features with Limited Support in Silverlight
- Same Feature, Different Approach
- Silverlight-Only Features
- Control Support in Silverlight vs. WPF
- Other API Differences
- Related Topics
WPF Features Not in Silverlight
Commanding
WPF introduced the concept of commanding, which Silverlight 3 does not fully support. The interface ICommand exists in Silverlight 3 so that classes can migrate without complications, but there is no CommandManager implementation that does actual commanding. For more information about commanding, see Commanding Overview in the WPF documentation.
Simple Inline XAML Content
Silverlight 3 does not support simple inline XAML content. For example, you cannot specify content for a button by doing this: <Button>My button content</Button>. Instead, you must use the Content property like this: <Button Content="My button content" />.
No Printing Support or Flow Document Support
There is no printing support or Flow Document support in Silverlight 3. See Printing Overview and Flow Document Overview in the WPF documentation.
Dynamic Resources
Silverlight does not support dynamic resources. All resource references to keyed resources in XAML are static. For more information, see Resources Overview.
BitmapImage Only Available ImageSource in Silverlight
BitmapImage is the only available ImageSource in Silverlight.
Miscellaneous
In addition to the features previously listed, the following are supported in WPF but not in Silverlight:
- TileMode property for TileBrush objects.
- ValueConversion attribute.
- ITyped list, InstanceFactory, or BindingList(T).
- Electronic Documentation Management (EDM).
- MarkupExtension base class.
WPF Features with Limited Support in Silverlight
Data Binding
The basics of Silverlight and WPF data binding are the same. However, there are some data-binding features offered in WPF that are not available in Silverlight. Silverlight supports binding the DependencyProperty of a FrameworkElement to any CLR object. Silverlight does not provide any of the following:
- Datasets.
- ICustomTypeDescriptor , IListSource, or IBindingList.
- Binding directly to XML data (or XPath binding).
- BindingMode.OneWayToSource binding.
- Discrete notification for source and target updates with dedicated NotifyOnSourceUpdated or NotifyOnTargetUpdated properties (and related events) on a binding.
- No CollectionView or CollectionViewSource class.
- For example, you cannot bind CustomerList/Name to TextBox1.Text. The slash (/) syntax does not work.
- There are no master details in XAML.
Silverlight also provides value converters and some support for data validation. For more information, see Data Binding.
Triggers
WPF introduced the concept of triggers, which allowed making property changes or starting actions based on when events occur or properties change. Silverlight support for triggers is limited to using EventTrigger for the Loaded event and the BeginStoryboard action. However, functionality provided by triggers can be accomplished by using the VisualStateManager.
Styles
Creating styles is very similar in Silverlight and WPF. There are a few limitations and other considerations in Silverlight. For more information about creating styles in Silverlight, see Style and Using Controls and Dialog Boxes.
Routed Events
WPF introduced the concept of routed events, where an event can be handled by multiple handlers in the element tree instead of just the object that initiated the event. For more information about routed events, see Routed Events Overview in the WPF documentation.
Silverlight includes the concept of routed events for a small subset of events. However, Silverlight does not enable you to create a new routed event. In addition, Silverlight does not include Preview events or class-handling of routed events. Silverlight 3 does introduce a way to re-handle a routed event already marked handled, but only through code. For more information about routed events in Silverlight, see Events Overview for Silverlight.
3-D Graphics
3-D drawing support in Silverlight is limited. For more information, see 3-D Effects (Perspective Transforms).
Dependency Properties
WPF and Silverlight have similar property systems that both use the concept of a dependency property. You can define a custom dependency property, but there are some important differences. For more information, see Custom Dependency Objects and Dependency Properties.
Visual and Logical Trees
Silverlight does not include the concept of separate visual and logical trees as in WPF. In WPF, all visual elements derive from the Visual class, which does not exist in Silverlight. Silverlight does provide the VisualTreeHelper class in case you need to navigate the rendered objects in the object tree. For more information, see Silverlight Object Trees.
Freezables
Silverlight does not include Freezable objects, which allow objects to be shared across threads and can improve performance. For more information, see Freezable Objects Overview in the WPF documentation.
Same Feature, Different Approach
Subpixel Rendering
Both WPF and Silverlight allow subpixel rendering, which can result in blurry text, images, and other displayed objects when antialiasing is applied to the object. For more information about subpixel rendering, see Pixel Snapping in WPF Applications in the WPF documentation. WPF handles subpixel rendering issues by using a feature called pixel snapping, which snaps lines to the nearest device pixel. Silverlight introduces the concept of layout rounding, which rounds object dimensions to the nearest whole integer. This feature can be turned off by setting the UseLayoutRounding flag to false. For more information, see Layout Rounding.
XAML Processing
XAML processing differences between WPF and Silverlight are generally slight, but differences do exist. These are documented in a separate topic; see XAML Processing Differences Between Silverlight Versions and WPF and XAML Processing Differences Between Silverlight 3 and Silverlight 4. The information in both topics applies to the total set of XAML differences between WPF and Silverlight 3.
VisualStateManager
Silverlight introduces the VisualStateManager, which helps define and manage the visual behavior based on the control state. For example, Pressed might be defined as a button state when the button is clicked. By using VisualStateManager, you can define all the control states and the transitions between states in your control templates. For more information, see Customizing the Appearance of an Existing Control by Using a ControlTemplate. WPF and the .NET Framework 4 now also support VisualStateManager, but you may be porting from the .NET Framework 3.5 to Silverlight version 3. In this case, you may have to convert most of your Triggers behavior to a visual state model.
Silverlight-Only Features
Deep Zoom
Silverlight introduces the Deep Zoom feature, which allows zooming in and out of high-resolution images or collections of images. For more information, see Deep Zoom.
Control Support in Silverlight vs. WPF
The following table provides details of control support for Silverlight and WPF.
Control | Silverlight or WPF | Available for Silverlight |
AccessText | WPF | Not available |
AdornedElementPlaceholder | WPF | Not available |
AdornerDecorator | WPF | Not available |
AutoCompleteBox | Silverlight | |
Border | Both | Runtime |
BulletChrome | WPF | Not available |
BulletDecorator | WPF | Not available |
Button | Both | Runtime |
ButtonChrome | WPF | Not available |
Calendar | Both | Silverlight SDK |
Canvas | Both | Runtime |
CheckBox | Both | Runtime |
ClassicBorderDecorator | WPF | Not available |
ComboBox | Both | Runtime |
ComboBoxItem | Both | Runtime |
ContentControl | Both | Runtime |
ContentPresenter | Both | Runtime |
ContextMenu | WPF | Not available |
Control | Both | Silverlight SDK |
DataGrid | Both (WPF .NET Framework 4) | Silverlight SDK |
DatePicker | Both | Silverlight SDK |
Decorator | WPF | Not available |
DockPanel | Both | |
DocumentPageView | WPF | Not available |
DocumentReference | WPF | Not available |
DocumentViewer | WPF | Not available |
Ellipse | Both | Runtime |
Expander | Both | |
FixedPage | WPF | Not available |
FlowDocumentPageViewer | WPF | Not available |
FlowDocumentReader | WPF | Not available |
FlowDocumentScrollViewer | WPF | Not available |
Frame | Both | |
FrameworkElement | Both | Runtime |
Glyphs | Both | Runtime |
Grid | Both | Runtime |
GridSplitter | Both | Silverlight SDK |
GridViewColumnHeader | WPF | Not available |
GridViewHeaderRowPresenter | WPF | Not available |
GridViewRowPresenter | WPF | Not available |
GroupBox | WPF | Not available |
GroupItem | WPF | Not available |
HeaderedContentControl | Both | |
HeaderedItemsControl | Both | |
HyperlinkButton | Silverlight | Runtime |
Image | Both | Runtime |
ImplicitStyleManager | Both | |
InkCanvas | WPF | Not available |
InkPresenter | Both | Runtime |
ItemsControl | Both | Runtime |
ItemsPresenter | Both | Runtime |
Label | Both | |
Line | Both | Runtime |
ListBox | Both | Runtime |
ListBoxChrome | WPF | Not available |
ListBoxItem | WPF | Runtime |
ListView | WPF | Not available |
ListViewItem | WPF | Not available |
MediaElement | Both | Runtime |
Menu | WPF | Not available |
MenuItem | WPF | Not available |
MultiScaleImage | Silverlight | Runtime |
NavagationWindow | WPF | Not available |
NumericUpDown | Silverlight | |
Page | Both | Silverlight SDK |
PageContent | WPF | Not available |
PageFunction | WPF | Not available |
PasswordBox | Both | Runtime |
Path | Both | Runtime |
Polygon | Both | Runtime |
Polyline | Both | Runtime |
Popup | Both | Runtime |
ProgressBar | Both | Runtime |
RadioButton | Both | Runtime |
Rectangle | Both | Runtime |
RepeatButton | Both | Runtime |
ResizeGrip | WPF | Not available |
Ribbon | WPF | Not available |
RibbonWindow | WPF | Not available |
RichTextBox | WPF | Requires Silverlight 4 |
ScrollBar | Both | Runtime |
ScrollChrome | WPF | Not available |
ScrollContentPresenter | Both | Runtime |
ScrollViewer | Both | Runtime |
Separator | WPF | Not available |
Slider | Both | Runtime |
StackPanel | Both | Runtime |
StatusBar | WPF | Not available |
StatusBarItem | WPF | Not available |
SystemDropShadowChrome | WPF | Not available |
TabControl | Both | Silverlight SDK |
TabItem | Both | Silverlight SDK |
TabPanel | WPF | Not available |
TextBlock | Both | Runtime |
TextBox | Both | Runtime |
Thumb | Both | Runtime |
TickBar | WPF | Not available |
ToggleButton | Both | Runtime |
ToolBar | WPF | Not available |
ToolBarOverflowPanel | WPF | Not available |
ToolBarPanel | WPF | Not available |
ToolBarTray | WPF | Not available |
ToolTip | Both | Runtime |
Track | WPF | Not available |
TreeView | Both | |
TreeViewItem | Both | |
UniformGrid | WPF | Not available |
UserControl | Both | Runtime |
ViewBox | Both | |
Viewport3D | WPF | Not available |
VirtualizingStackPanel | WPF | Not available |
WebBrowser | WPF | Not available |
Window | WPF | Not available |
WindowsFormsHost | WPF | Not available |
WrapPanel | Both |
Other API Differences
Below are listed some of the API differences between Silverlight and WPF.
API | Silverlight or WPF | Available for Silverlight |
MediaSampleAttributeKeys | Silverlight | Runtime |
MediaSourceAttributesKeys | Silverlight | Runtime |
MediaStreamAttributeKeys | Silverlight | Runtime |
MediaStreamDescription | Silverlight | Runtime |
MediaStreamSample | Silverlight | Runtime |
MediaStreamSource | Silverlight | Runtime |
MediaStreamSourceDiagnosticKind | Silverlight | Runtime |
MediaStreamType | Silverlight | Runtime |
No comments:
Post a Comment