• Blog
  • Info Support
  • Career
  • Training
  • International Group
  • Info Support
  • Blog
  • Career
  • Training
  • International Group
  • Search
logo InfoSupport
  • Latest blogs
  • Popular blogs
  • Experts
      • Alles
      • Bloggers
      • Speakers
  • Meet us
  • About us
    • nl
    • en
    • .NET
    • Advanced Analytics
    • Agile
    • Akka
    • Alexa
    • Algorithms
    • Api's
    • Architectuur
    • Artificial Intelligence
    • ATDD
    • Augmented Reality
    • AWS
    • Azure
    • Big Data
    • Blockchain
    • Business Intelligence
    • Cloud
    • Code Combat
    • Cognitive Services
    • Communicatie
    • Containers
    • Continuous Delivery
    • CQRS
    • Cyber Security
    • Dapr
    • Data
    • Data & Analystics
    • Data Science
    • Data Warehousing
    • Databricks
    • DevOps
    • Digital Days
    • Docker
    • eHealth
    • Enterprise Architecture
    • Hacking
    • Infrastructure & Hosting
    • Innovatie
    • Integration
    • Internet of Things
    • Java
    • Machine Learning
    • Microservices
    • Microsoft
    • Microsoft Bot Framework
    • Microsoft Data Platform
    • Mobile Development
    • Mutation Testing
    • Open source
    • Pepper
    • Power BI
    • Privacy & Ethiek
    • Python
    • Quality Assistance & Test
    • Quality Assurance & Test
    • Requirements Management
    • Scala
    • Scratch
    • Security
    • SharePoint
    • Software Architecture
    • Software development
    • Software Factory
    • SQL Server
    • SSL
    • Start-up
    • Startup thinking
    • Stryker
    • Test Quality
    • Testing
    • TLS
    • TypeScript
    • Various
    • Web Development
    • Web-scale IT
    • Xamarin
    • Alles
    • Bloggers
    • Speakers
Home » Silverlight 3 new features, pitfalls and oddities
  • Silverlight 3 new features, pitfalls and oddities

    • By Alex van Beek
    • .NET 12 years ago
    • .NET 0 comments
    • .NET .NET
    Silverlight 3 new features, pitfalls and oddities

    Well, this is my first blog post at this community, and I’m not even going to introduce myself, because that’s what the “About” link on the right is for [:)]. So without further delay, let’s get started with my first post!

    When Silverlight 3 was released, i decided to get to know the new features by building an application which needed all of them. In the Flex courses, students would build a somewhat large application called FStop, which is an application to manage and upload photo’s. In the past i tried to port this to Silverlight 2, but some things just couldn’t be done, like saving a photo to the user’s file system in a location of his / her choosing. Now with the release of Silverlight 3, i decided to try it again and i succeeded to implement the whole FStop application with all of it’s features in Silverlight. While building this application i noticed a few oddities / pitfalls related to the new Silverlight features and i decided to share them here. What follows is list of new Silverlight features with the oddities / pitfalls (if any) related to them.

    Navigation Framework

    • Default behavior of the Navigation Framework, more specifically the Frame class, is to instantiate and load every page over and over when someone navigates to that page. Even when using the Back button in the browser to return to a previously visited page. If a Page only needs to be loaded once, you can set the NavigationCacheMode property on the Page class to “Required”. Default value is “Disabled”. This property works together with the CacheSize property of the Frame class. Notice that the OnNavigatedTo method always fires, independent of the NavigationCacheMode property.
    • When you put code to force the bindings to update in the OnNavigatedTo Method, controls won’t transition to the Invalid state (or you won’t see that they transition to the Invalid state), which means that you don’t get any visual feedback about data validation. This code should be placed in the Loaded event instead.

    SaveFileDialog

    • The SaveFileDialog class has a method “GetStream()” to get a Stream to the location the user has chosen, which you can use to write any kind of data. What’s weird about this stream is that you can use it to write data in a multi threaded application, with other words, you can use the Write methods from different threads than the UI thread. But if you use this Stream in a “using” statement to automatically dispose it from a different thread than the UI thread, you WILL get an exception. It seems that you can write from any thread you like, but the stream needs to be disposed from the UI thread. You can use the RunWorkerCompleted event from the BackgroundWorker class for this.

    WritableBitmap class

    It’s nice that we can finally make snapshots from components and change pixel data of images, but what if we want to save the changed data to the client using the SaveFileDialog from above? When you just write the pixels from the WritableBitmap to a stream, it’s not in a format any program will recognize. Silverlight doesn’t have any kind of Image encoders (yet), in the mean time you can use this excellent post to save images from the WritableBitmap to a .PNG file.

    Application Library Caching

    • To use this feature, you need to create a “AssemblyName.extmap.xml” file in the same folder as the assembly you would like to cache. Next to that, the assembly needs to be signed. If you have met both of these conditions, you can just use the “Reduce XAP Size” option from the project properties in Visual Studio. Visual Studio will create .zip files containing the assemblies in the correct location and update your manifest file. Most of the standard Silverlight 3 assemblies already come with an “extmap.XML” file, but creating those files for your own assemblies or the Silverlight Toolkit (which is an excellent candidate for caching) can be time-consuming. Luckily,  there is a tool which can do this for us, you can find it here.
    • I experimented a bit, creating DLL’s that were 90mb+ (simply embedding large resources) and enable caching on them . What the runtime seems to do is, first download the initial XAP, which is faster because the DLL’s aren’t included. So the Silverlight plugin progress indicator flies to 100 percent. Then it stays at 100 percent while all the external assemblies are downloaded. When this is complete the initial UI of your application shows. It doesn’t matter whether you actually use the assemblies at that time, all assemblies are downloaded when the progress indicator for the initial XAP reaches 100 percent. This way, it is certain that all required assemblies have been loaded, the disadvantage is, you really can’t show any custom progress indication while downloading the assemblies in the background, even worse, your application is unresponsive. It would have been nice if the default progress indication of the Silverlight plugin would somehow show that it was busy downloading assemblies, because just staying at 100%, makes it look like the application has frozen.

    Share this

Alex van Beek

View profile

Related IT training

Go to training website

Related Consultancy solutions

Go to infosupport.com

Related blogs

  • Innovative patterns in software quality management

    Innovative patterns in software quality management Tom van den Berg - 1 month ago

  • Developing a Service Fabric service using another host

    Developing a Service Fabric service using another host Tim van de Lockand - 5 months ago

  • Adding a package to your private WinGet.RestSource feed…

    Adding a package to your private WinGet.RestSource feed… Léon Bouquiet - 10 months ago

Related downloads

  • Beslisboom voor een rechtmatig ‘kopietje productie’

  • Klantreferentie: Remmicom zet wetgeving om in intellige…

  • Klantreferentie RDW: Samenwerken voor veilig en vertrou…

  • Klantreferentie BeFrank: Strategische IT voor een innov…

  • Wie durft te experimenteren met data in de zorg?

Related videos

  • mijnverzekeringenopeenrij.nl

    mijnverzekeringenopeenrij.nl

  • Winnaar | Innovation Projects 2017

    Winnaar | Innovation Projects 2017

  • Explore | Info Support & HAN & Poliskluis

    Explore | Info Support & HAN & Poliskluis

  • LifeApps bij HagaZiekenhuis

    LifeApps bij HagaZiekenhuis

  • Info Support | Bedrijfsfilm

    Info Support | Bedrijfsfilm

Nieuwsbrief

* verplichte velden

Contact

  • Head office NL
  • Kruisboog 42
  • 3905 TG Veenendaal
  • T +31 318 552020
  • Call
  • Mail
  • Directions
  • Head office BE
  • Generaal De Wittelaan 17
  • bus 30 2800 Mechelen
  • T +32 15 286370
  • Call
  • Mail
  • Directions

Follow us

  • Twitter
  • Facebook
  • Linkedin
  • Youtube

Newsletter

Sign in

Extra

  • Media Library
  • Disclaimer
  • Algemene voorwaarden
  • ISHBS Webmail
  • Extranet
Beheer cookie toestemming
Deze website maakt gebruik van Functionele en Analytische cookies voor website optimalisatie en statistieken.
Functioneel
Altijd actief
De technische opslag of toegang is strikt noodzakelijk voor het legitieme doel het gebruik mogelijk te maken van een specifieke dienst waarom de abonnee of gebruiker uitdrukkelijk heeft gevraagd, of met als enig doel de uitvoering van de transmissie van een communicatie over een elektronisch communicatienetwerk.
Voorkeuren
De technische opslag of toegang is noodzakelijk voor het legitieme doel voorkeuren op te slaan die niet door de abonnee of gebruiker zijn aangevraagd.
Statistieken
De technische opslag of toegang die uitsluitend voor statistische doeleinden wordt gebruikt. De technische opslag of toegang die uitsluitend wordt gebruikt voor anonieme statistische doeleinden. Zonder dagvaarding, vrijwillige naleving door uw Internet Service Provider, of aanvullende gegevens van een derde partij, kan informatie die alleen voor dit doel wordt opgeslagen of opgehaald gewoonlijk niet worden gebruikt om je te identificeren.
Marketing
De technische opslag of toegang is nodig om gebruikersprofielen op te stellen voor het verzenden van reclame, of om de gebruiker op een website of over verschillende websites te volgen voor soortgelijke marketingdoeleinden.
Beheer opties Beheer diensten Beheer leveranciers Lees meer over deze doeleinden
Voorkeuren
{title} {title} {title}