What is the difference between wpf and silverlight application




















NET Framework. Silverlight applications are hosted within a webserver and a web page. WPF applications can be deployed as standalone applications,.

Silverlight is a subset of WPF and therefore has fewer features but is more portable. WPF can be ran in both a browser or as a WinForms style application in Windows while Silverlight can only be ran in a browser. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. What is the difference between WPF and Silverlight application? Ask Question. Asked 12 years, 8 months ago. However, the WindowsFormsHost control cannot overlap or.

Each region in an application can only be controlled by one. WPF elements within a WinForms application. Of course, in WinForms, the work must be done. More complex interoperability may be performed in WPF through the knowledge of window. While most of WPF does not implement any method for interacting with. Styles are one. Note, Microsoft is working to implement.

The BasedOn property allows a form of visual inheritance between styles. As the name states, a. Based-On styles are supported by Silverlight 3, as well as dynamic styles that allow styles to be changed on. An implicit style will set the properties of any visual element matching the TargetType. This is. In some cases, it might be necessary to remove an implicit style on a visual element. To negate. All 3D. WPF supports many 3D features including cameras, models, meshes, materials, lights,.

Silverlight 3 gains some 3D features, such as perspective projections in 3D for scaling and rotational. In addition, Silverlight 3 will support hardware acceleration for many effects for which it previously. However, it will not support the full range of 3D capabilities found in WPF.

Themes are a set of visual styles and control templates available to WPF applications and are. In addition, additional themes may be found for. In practicality, themes are defined as resource dictionaries containing implicit styles and control. In most cases, virtually every.

Themes can be created and placed within the themes subfolder off the root of the project. Skins are almost identical to themes, except that skins are geared to a specific application while. Applications are usually designed to be skinned by end-users and therefore provide a skinning.

API for designers. The only major difference is that skin resource files typically name styles. However, this is not a hard and fast.

Distinguishing between themes and skins is a nebulous area at best. The current line of thinking. WPF supports both managed and. Media and System. Both encoders writers and decoder readers are available for each of the bitmap image types. It can represent not only a. With the new SaveFileDialog class, creating and storing images for later retrieval will. Traditional client development centers on windows and forms and WPF has no issues working in.

However, the internet brought the web page, and navigational-based web. WPF attempts to bridge the divide by bringing the page-based navigation. Applications using page-based navigation typically start with the NavigationWindow element,.

The majority of paging interaction occurs through the NavigationService instance exposed by. The Navigate. Silverlight 3 will contain a new NavigationFramework that will function similarly to the page-based. The journal is an aspect of the page-based navigation system to provide history of pages visited. Pages can opt out of being stored in the journal by setting the RemoveFromJournal property to. Input gestures are a facility for defining a sequence of.

Input gestures work in conjunction with WPF comm and s. Comm and s can be associated with. Input gestures can be defined in XAML as well as in code. For example, to attach the F1 key to. A freezable object in WPF is an object deriving from the Freezable base class. It is special in that. Once frozen, the object can then be shared. Brushes, Transforms, and Geometry objects are all freezable objects; in fact the majority of. When frozen, performance.

When frozen, the system no longer needs to monitor the objects for. Once frozen, a freezable object cannot be unfrozen; however, it can be cloned. In addition, not. Finally, freezing an object that contains freezable objects will also freeze all the children.

WPF implements a data provider model for data binding and ships with two concrete data. In addition, it is possible to create. XML file. An XML data structure can be embedded into an applications resource dictionary as. To bind to this Xml snippet, use st and ard binding syntax with the XPath set appropriately. The XmlDataProvider may not be suitable for all purposes, especially when data may be already.

Though most. Net objects can already be set as a data source, the ObjectDataProvider provides. WPF provides a framework for adding validation rules to data bindings. The Binding class. ValidationRule can be loaded. Each rule is checked in turn, therefore, all the rules must pass or. Additionally, the validation engine can also be configured to h and le. To create a custom validation rule, simply derive from ValidationRule and add any custom logic.

Then, add the rule to the ValidationRules collection either in code or. By default, when an element fails its validation, WPF outlines the element with a thin red. However, by providing an ErrorTemplate, a designer can change the look- and -feel of. The following example shows how to create a validation template and apply it to a TextBox. WPF supports the. This security. A full discussion of code access. In essence, CAS defines permissions and permission groups that represent a right to access.

Code can then request permissions in which it needs to run, what. Web browser applications, however, are run with partial trust; typically using one. Some functionality is available only to the Silverlight platform solely due to the fact that it is a webbased.

A Silverlight application does not necessarily need to consume its entire hosted web page, and. In the case where the Silverlight applet. It is possible for Silverlight to call Javascript methods, have JavasScript call Silverlight methods,. To call a Silverlight method from Javascript, the Silverlight class and name must be attributed.

Silverlight supports rich media services delivered over the web. The Silverlight client supports. Silverlight can play media streamed to the client using a technique that sends data to the client. This methodology reduces b and width consumption since if. Silverlight also implements the progressive download delivery method. Unlike smoothstreaming,.

If the. Silverlight also supports a relative new adaptive streaming technology dubbed Smooth. The Smooth Streaming technology is adaptive in that the client can request pieces of data of.

In addition, the source media can be stored. The major advantages of Smooth Streaming are quick startup, no buffering, and constant. This insures a consistent, and more importantly, a smooth. A timeline marker is metadata stored directly within the media file to provide the capability to.

Within Silverlight , these timeline markers. The event can be h and led in. The code to hide the popup after a set amount of time passes will be left as an exercise to the. Deep Zoom is a technology for viewing extremely high resolution images through Silverlight. The technology allows for quicker downloads of a large image by only displaying the portion. Deep Zoom also pre-processes an image into many separate resolution images to. At run-time the Deep Zoom engine seamlessly stitches the pieces together depending upon how.

For example, an image with a resolution of 10,x10, pixels may first be displayed in a. The image downloaded to the browser would not be the entire. Sharing code between Silverlight and WPF can be a daunting task, as seen by the myriad differences.

However, with careful planning, developers can share a significant amount. Microsoft is committed to bringing Silverlight and WPF closer. Many of the differences in programming between Silverlight and WPF have been covered in the body of. However, this section compiles a list of some of the top techniques or strategies you. Custom user controls are one way to begin sharing code between WPF and Silverlight.

Controls built completely in code would work the most seamlessly, provided that. Version 2. Net Framework implemented a feature known as partial classes. Net compiler that additional implementation exists in a separate file;.

When developing for Silverlight and WPF , partial classes could be used to organize a class into. The WPF. Generally speaking, both the WPF and Silverlight partial classes should contain implementations.

This will insure that the main code base will function. New to version 3. Net Framework are extension methods. Extension methods are static. These methods. When developing for both Silverlight and WPF , developers could create two separate extension. Each project would contain their respective.

The implementation of an extension method is different between Visual Basic and C. Compiler directives are embedded comm and s to instruct the compiler how to compile a certain. This directive can be used to. Therefore, it is not possible to. One solution to reuse code in. There are several scenarios when coding for both platforms that require some forethought in. While this whitepaper outlined many of the differences and. WPF supports element-to-element binding to facilitate designing the UI when controls rely on.

However, since Silverlight 2 does not support element-to-element. Developers familiar with. For example, assume that a CheckBox control is responsible for enabling a group of controls. WPF , simple element-to-element binding can set the IsEnabled property of the parent control. However, since Silverlight supports neither element-to-element binding nor the selfpropagating.

The next version of Silverlight will support element-to-element binding. However, it may be desirable to. Several design patterns, including a new variation of the MVP. Since Silverlight does not support multi-data binding, developers needing cross-platform. Building a separate. Both Silverlight and. Taking the Person class from earlier where multi-data binding is needed for when either the first.

A corresponding ValueConverter to return the first and last names concatenated into a string in. WPF supports various triggers to obtain visual effects while Silverlight implements. Silverlight has the capability of embedding fonts in many different ways: from embedding as a.

Since adding fonts to Silverlight. In the case of a font, however, one needs to set the FontSource property to the. WPF and Silverlight provide a new paradigm for application development using the same core. However, since Silverlight runs as an application within the plug-in model of a.

Future releases of both Silverlight and WPF have been making. Almost as proof, with the upcoming release of Silverlight 3, many differences are either outright. In addition, Silverlight 3 will sport some new and interesting features see. No association with any real company, organization, product, person or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user.

Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means electronic, mechanical, photocopying, recording, or otherwise , or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarked, copyrights, or other intellectual property rights covering subject matter in this document.

Except as expressly essly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. All rights reserved. Any example companies, organizations, products, people, and events depicted herein are fictitious. Silverlight , a subset of WPF , extends the platform to the web via the add-on mechanism available in most current browsers.

As a subset of WPF , the ability to create rich Internet applications is unprecedented; however, there are some significant differences between the capabilities of Silverlight and WPF , as well as important differences in the programming features of the two technologies.

First and foremost is that Silverlight 2 is a downloadable plug-in running within a browser. In order to insure that the plug-in is a small as possible, Microsoft built a smaller version of the.

Net Framework, one that is highly optimized for size and is a small subset of the full. WPF , on the other h and , has full access to the main. The difference between the smaller, downloadable. Net Framework and the full desktop version is one of the major disparities between the two platforms.

In addition, the fact that Silverlight is rooted within the browser, and inherits the limitations of that environment, further differentiates the two platforms. In addition, this paper documents functionality implementations that may be available in only one technology or the other.

For example, WPF implements a large library of controls for document h and ling, including printing and formatting large documents. Due to minor differences in implementations of common elements, developers need to carefully plan their development in order to reuse code in both platforms. Of course, since certain functionality may not exist in one platform, developers may need to reduce the scope of the application in those cases. One last note about this whitepaper: for brevity and consistency issues, all code samples are written in C.

Net or any other. Net programming language. There are very few pieces of functionality that exist solely within the Silverlight platform. That stated, though the two platforms have their differences, much of the implementations are similar. Both platforms implement dependency properties in nearly identical ways; WPF allows for slightly more fine tuning the metadata when registering a dependency property.

The Register static method accepts a class of type PropertyMetadata that, among other things, sets the default value of the property. However, the implementation of the controls is not exactly the same in both platforms in most cases.

Microsoft is committed to bringing both platforms closer in terms of supported controls and functionality, and with each successive version the control libraries become more similar. Animation is a complex topic, so this paper will just focus on some of the rudimentary aspects of it. For instance, moving an element from left to right involves changing its Canvas. Left property through time. One way XAML implements this functionality is through linear interpolation, a method of smoothly transitioning a property from one value to another over time.

Below is a snippet of XAML showing a simple animation declaration to move a button from left to right over the course of one second.

There are many ways to initiate the animation: through triggers for WPF , the VisualStateManager for Silverlight , EventTriggers within styles, or through procedural code. The linear interpolation can be modified somewhat by adding AccelerationRatio and DecelerationRatio properties to the animation. These attributes essentially create three linear interpolations for the entire animation in order to modify the starting and stopping speeds. For example, a designer would use these attributes to have an object gradually pick up speed or stop suddenly.

Unfortunately, Silverlight does not implement these two attributes, but the effect can be duplicated using keyframe animations with linear interpolation. For more complex animations, XAML supports keyframe animations, a method of animation specifying a value at a specific point in time a keyframe. The animation system then interpolates the transition from one keyframe to the next. The method of interpolation can be as simple as a basic linear method seen before, discrete that is, no interpolation , or more complex spline interpolations.

Silverlight , unfortunately, does not have the facility to animate an object along a pre-defined path. User controls can be thought of as composite controls while custom controls are either derived from existing controls or are something completely new and derived from the Control base class itself. User Controls User controls are useful when needing to reuse a complex group of elements in multiple places within an application or across applications. The MediaPlayer class is the major element in playing video from within an application.

The MediaPlayer class wraps the functionality of Windows Media Player and therefore supports all the file formats that it does such as. The following snippet shows a method for embedding video into a XAML page: Since the MediaElement is a Framework element, it supports many options to control its look and -feel.

Tablet PCs, pressure-sensitive tablets, touch screens, and other electronic devices have the capability to create digital ink. In addition, the mouse may also be used as a stylus device, though it is generally more difficult to use in that manner.

WPF defines stylus-based input to distinguish between the traditional mouse and one of the touch-based input devices where the input mechanism could be a digital pen or even a finger. ApplicationGesture enumeration. These gestures allow a user to control a system using only the stylus to perform comm and s such as Up, Down, Cut, Paste, etc.

Finally, since WPF allows the capture of h and written text there is a facility for h and writing recognition. In a Silverlight application, it is possible to get h and writing recognition through a server-side component. As such, it implements a subset of both the. Microsoft made the decision to cut features to reduce the download footprint of the Silverlight plug-in.

Future versions of Silverlight will attempt to reduce the differences between the two platforms, and still retain a small download footprint. Microsoft will accomplish this feat by only downloading libraries that the Silverlight application actually uses. WPF applications are run on a Windows client platform, and , with the exception of browser-hosted applications, are hosted by the system. Net Framework programming stack, including the browser-hosted model.

Silverlight applications, on the other h and , run within the plug-in model of the hosted web browser. However, in an effort to minimize the download time for installing Silverlight , the entire. Net Framework runtime libraries. The differences between the two. Net Framework libraries constitute the major hurdles for developers when building applications to run in both architectures.

Shared libraries are not capable of being shared between platforms since the core referenced assemblies are different. However, this whitepaper will discuss various alternate methods for sharing similar code between the two platforms. To minimize client download size, Silverlight uses an XAP archive. A XAP archive is a zip-compressed archive of the Silverlight application, plus a manifest file describing the content.

When compiled and deployed, the text-based XAML is reconstituted into binary form for quicker processing. Technically, the XAML is not compiled, just compacted into an efficient binary format, though one can argue the semantics. In order to retrieve the Xaml of a page or control dynamically, it must be compiled as an Embedded Resource.

This will store the actual XAML as an embedded resource within the assembly. It is then possible to retrieve the XAML in code via the resource manager. Both platforms support a separate code-behind file to contain.

Net programming code to manipulate the elements and controls declared within the XAML. The code-behind model is the same one first introduced with. Net at its inception to provide a separation between procedural code and presentation. Differences begin appearing with the available UI elements available to each platform. Additional namespaces added to the root element must point to assemblies that are deployed with the application.

Triggers WPF supports a trigger mechanism to respond to certain end-user actions, such as moving the mouse over a UI element, or pressing a button.

For example, EventTriggers are triggers that respond to RoutedEvents, and only activate animations, they cannot properties on elements. DataTriggers and MultiDataTriggers are triggers that respond to changes in the underlying data bound to an element. Since DataTriggers use the Binding syntax, more robust conditions can be specified through the use of binding converters, allowing the application to reduce a range of values to a boolean value.

Additionally, the MultiDataTrigger, its syntax mirrors the MultiTrigger element, can be used to further define conditions. Silverlight , however, does not implement the trigger mechanism, but instead introduces a concept called the Visual State Manager.

Silverlight supports direct and bubbling only. No comments:. Newer Post Older Post Home. Subscribe to: Post Comments Atom.

About the Author I have more than 10 years of experience in IT industry. Linkedin Profile I am currently messing up with neural networks in deep learning. So here it is quite important that the template binding value in the XAML should be registered as dependency property in the code behind.

We have to say which type of dependency property is that, in above example the Source is the type of BitmapImage, so we have defined typeof BitmapImage. Now this is how it go, we set the value from our code behind or xaml to the source property defined above, and inturn it sets the value of the dependecy property ImageUri, which inturn sets the value in the template binding Source, as we have registered ImageUri as Source, that is presennt generic.

Here is the article on the topic:. In general, there is no easy way to migrate a project from WPF to Silverlight. They have very much in common, but strictly speaking are a different technologies.

You mentioned trust access to the host which I think rules out Silverlight unless you want to run SL4 beta. We recently went through a lot of discussion about file system access. Silverlight 3 runs in a partial trust sandbox more or less.



0コメント

  • 1000 / 1000