Archives

Archives / 2009
  • Using the WebBrowser control and debug a Silverlight Out-of-browser (OOB) application in VS 2010

    Yesterday I played with the WebBrowser control shipped with Silverlight 4. I was trying to create a little RSS Reader for Silverlight 4, only to try out some of the new features. The WebBrowser control have two methods to display a web page, the Navigate and the NavigateToString. The Navigate takes an URI, the NavigateToString takes a string with for example HTML to be diplsyed inside of the WebBrowser window. In my case I didn’t want to use the Navigate, instead the NavigateToString so I could just grab some RSS feeds and get the body of a post and pass it to the WebBrowser control. First of all I notice that the WebBrowser control will only work in a Out-of-browser application, if we try to use it in a browser we will se the following:

  • Silverlight 4 and Asynchronous Validation with INotifyDataErrorInfo

    During this week I helped a company with the design of a RIA with Silverlight. In the existing Web and Window Forms application they have a form where the users can enter an account id (or was it a customer id ;)). When they leave the TextBox they did a check if the account id already exists or not. They use their own way of showing the validation message. Now in the new application they want to use the red boxes showed up in Silverlight when a validation fails. In Silverlight 3 the validation only showed up if the bounded property of a TextBox thrown an exception in the set method. It’s not easy to manually trigger the nice red validation message box for a specific control outside the set method of a bounded property. Every call to the service layer from the Client should be asynchronous and in that way the callback can’t trigger the validation error box. With Silverlight 4 it’s now possible to notify when a validation fails when an async. method is completed. This is thanks to the INotifyDataErrorInfo interface. This interface can be used to notify the UI when an validation fails, and that can be done outside the set method of a property, for example in a async. callback method. The INotifyDataErrorInfo has the following members:

  • WCF RIA Services – What you need to know when creating DTO/Presentation Model

    Note: This is based on the WCF RIA Services Beta, so the code in this post can change in a future release of the framework.

    When defining DTO or a “Presentation Model” (Not the Presentation Model pattern by Martin Fowler, a model suited for presentation purpose, not all entities are) there are things you may want to now. The following is an simple DTO:

  • WCF RIA Services and DTO with association

    This post will be short, I notice that some people are asking about how to send an object graph which will include an association to other objects. First of all, be careful with the distribution of an object graph, wrong design can affect performance in a way that to much data is passed over the wire.

    Here is an simple Order class, this class has OrderRows:

  • Silverlight 4 Commanding enables ViewModels

    One feature out of many really great feature shipped with Silverlight 4 Beta, is Commanding. With Commanding we can use the MVVM (Model View View Model) Pattern. Commanding is something that WPF has and preview Silverlight doesn’t. Commanding can only be used on ButtonBase controls and Hyperlink control at the moment, and will only be executed by the Click event. In this post I’m going to show how you can use the new Commanding feature and create use the MVVM pattern in Silverlight 4. Here is my simple UI:

  • Is WCF RIA Services ready for the Enterprise?

    Today Microsoft released the WCF RIA Services Beta, it’s now on top of WCF and by default uses binary data end points and data contract serialization. By using binary data end points we will get better performance and make the data sent over the wire smaller (The other preview versions uses pure JSON). WCF RIA Services is a great framework for Rapid Application Development (RAD) of 2-tier applications. Based on the new changes to the WCF RIA Services it’s defiantly ready for the Intranet and small applications, but how about the Enterprise. First of all if you uses the Entity Framework or Linq to SQL Domain Services, it’s not ready for the Enterprise and will never be, IMO, because when we use it it distribute DAL types to the client. They are useful for small data driven applications. BUT! WCF RIA Services with the DTO (Data Transfer Object) support will make it closer to be ready for the Enterprise, but is that enough?

  • How to create a Module based Silverlight application (Part 1)

    When building RIA (Rich Internet Application) with Silverlight, it’s important to make sure the Silverlight application is loaded as fast as possible. Users don’t like to see a splash screen for several seconds or minutes, they want an application to start directly. One way to make a Silverlight app load fast, is by minimizing the XAP file, this can be done by not adding to much images, videos or other files to the Silverlight application project. If we have a large application, we can also split the application into small “modules”, for example assemblies or .XAP files. We can then load them on demand when they are needed. The base application can be kept small and be the core engine for the other modules. In this first part of my blog post I will add some examples how we can split our Silverlight applications into modules, and load them on demand asynchronous. The next part will be about how to use MEF (Managed Extensibility Framework) to create module bases Silverlight application.

  • .NET 4.0 is so Lazy

    With .NET 4.0 there is a new class added to the System namespace called Lazy<T>. This class is what the name says, lazy. Here is an example where Lazy is used:

  • Fluent-API to add ActionFilters to Controllers – ASP.NET MVC Part 2

    I’m working with my Fluent-API for adding Action Filters to Controllers and Action Methods. In my previous post, I created a new instance of each Action Filter and add it to an Action Method or Controller. Based on how the Action Filters are often implemented they don’t or shouldn’t keep any state, so in that case I don’t need to create a new instance of the same Action Filter with the same configuration for each Action Method I want to add it to. I also want to have an option to have a better overview of which Action Filter is added to which Controllers and Action Methods. I have added to methods, AddFilterToControllers and AddFilterToActions:

  • Distributing domain entities over the wire

    When we design our domain entities we don’t have a presentation layer or database in mind. The domain entities are core business objects located on the server or client side based of what kind of application we are building. Domain entities aren’t designed for distribution. When we realize that we need a distribution, we shouldn’t distribute the entities, instead collect the data we need to distribute and create a data transfer object (DTO) instead. Have the network in mind, a domain entity aren’t designed with a network in mind and of that reason not suitable for distribution. When we create our domain entities, they aren’t designed for presentation purpose, they are designed to fulfill business needs. You should be careful when you start thinking about returning a domain entity to the View when using a patterns like MVC, instead use DTO or a ViewModel, because once again the domain entities aren’t designed with presentation in mind, and aren’t often suitable for presentation purpose. It’s often better to map them to a DTO or ViewModel, objects that are suitable for presentation purpose or passed over the wire.

  • Some features I love in VS 2010

    This post will not be so long, I want to write a little about some Visual Studio 2010 features I love. First of all the changes made to C# is great, the default value on parameters rocks! When I implement Frameworks, I often ended up with something like this:

  • Create an automatic scrollable image slider in Silverlight

    I guess someone will send me an comment and say something like: “Why not simply use XXXX, why write your own control” ;) I know there are a lot of controls out there that will do stuff for me, but I want to know how they are created, and try to create my own solution to learn more etc.

  • ASP.NET AJAX 4.0 Preview 5 – Working with Converters and the new CDN

    In this blog post I’m going to show you how you can use the new Converter feature during data binding, to make this post more special I have used the new Microsoft AJAX CDN (Content Delivery Network), so I don’t need to have the AJAX 4.0 script on my server. The example code I use in this post, will use the ASP.NET AJAX DataView and also Microsoft ADO.NET Data Services to retrieve data from the server. My fantasy isn’t so special good, but I decided to make a little “rental” application, where I will use ASP.NET AJAX to simply show a list of cars and the current rental status. The status of a rental car will be sent to the client as a string and can be of the following values, Approved, Not Approved and Pending. The little app I’m building for this post, will show the rental status as different colors for the user.

  • Silverlight and scaling

    I have tried so many different ways to scale a Silverlight app while resizing the browser. When I almost got everything to work, the Grid control start to behave really strange, start to clip my app. Why should it be so hard to get scaling to work, why not just add a property to the Silverlight host, scaling=”enable”, and it will automatically scale our Silverlight app. After some time I got everything to work perfectly and thought maybe some other people would be interested in how to create a Silverlight app that can scale, so here is my solution. This post will ONLY focus on scaling the whole Silverlight host content with the ScalingTransform feature, to make the app fit into any kind of resolution. The code is tested on Silverlight 3.0.

  • Keep the first “empty” Item in a listbox when using ASP.NET AJAX 4.0 Preview 5 and Observer

    I got a question as a comment on my previous post about the new features and changes to ASP.NET AJAX 4.0 Preview 5. I hope I understood the question right ;) It was about using a listbox and add an empty item at the top of the list, and keep it there when adding new items to an array that is bounded to the list, and by using the Observer feature. Maybe some more have or will have the same question, so I decided to write a blog post about it.

  • Different ways to keep state when building RIA with Silverlight

    When building RIA with Silverlight, we will have some state issues we need to take care of. A Silverlight app by default is running in a browser, the browser have 3 bad buttons, Refresh, back and forward. If a user will press the Refresh button, the whole Silverlight app will be restarted. Same if they navigate from a Silverlight app with the back and forward buttons. If we build a RIA, our app will mostly hold the state for us on the client-side to reduce the number of round trip to the server etc. Lets assume a user will work with customer data. A user want to update the customer and information related to the customer. After 10 minutes of changes, the user suddenly by mistake refresh the page and all the data will be lost. So what we need to do when building RIA, is to remember the Refresh, back and forward buttons. This blog post will cover some of the Silverlight 3.0 features we can use to hold state and handle the Refresh, back and forward issues. This is something that I will also take up in my new updated Silverlight 3.0 course at Cornerstone (Where I work as an instructor, mentor, coach and consultant).

  • How SubmitChanges works in .NET RIA Servies

    Now I’m back from my 4 week long vacation. I have spend a lot of time with my new apartment, took about 2 month to get most of it ready, I still have a lot of things to do, but all the painting and stuff are done :) I got a question on my e-mail regarding .NET RIA Services and the Business Application project’s UserRegistartionService. It was about the AddUser method in the Service and when and where it’s called. I thought it would be great to write a post about it.

  • Moved to a new apartment

    I haven't blog for a while, the reason to this is that I moved to a new apartment three month ago, and have spend a lot of time with some decoration and finding new furniture etc. I have also been really busy with work until my vacation. I still have one week left out of four.

  • Will .NET RIA Services be the Silver Bullet!

    I have spend some time on the Silverligth.net forum and in the .NET RIA Services thread.. and just created a replay on a post about RIA Architecture and design.. I have some concerns regarding to how developers are using .NET RIA Services etc.. maybe it’s not a big deal.. but I will try to share my concerns and made a copy of my replay and created it as a blog post. I look forward to your comments. To get basic understanding about about my view of a RIA Architecture and also .NET RIA Servers, I prefer you read my two other blog post before you read this blog post.

  • RIA Architecture with Silverlight in mind

    Rich Internet Application (RIA) is an interesting topic. More and more business apps are moving into to the cloud, and more and more will have better User Experience (Ux). According to Gartner Research, nearly 60 percent of all new application development will include RIA technology by 2010. Today we can use different technologies to build a RIA, for example, AJAX, Flash and Silverlight etc. When it comes to AJAX we will soon reach the top of what we can do with it, because of the limitation of HTML, Client-side scripts and the browsers etc. That makes Silverlight and Flash more interesting regarding to me. But what is RIA? RIA It’s an internet applications that looks and feels like desktop applications, it also provide most of the maintainability and deployment benefits of Web applications. A RIA client can have state, so to increase User Experience, the user can work with data for a while until it will be passed down to the server for processing. Because the client side of a RIA can have state and work with data for a while, it’s extra important to have concurrency in mind. Some other users can have changed the data during the time we have worked with our copy. When developing RIA Clients we need to have several things in mind, for example a RIA is often running within an execution container in the Browser, so people can hit the refresh button or use the back and forward buttons, which can be reload the whole app and the current state can be gone. When we creates a large RIA, we can’t let users wait for hours until the application is loaded and started, so we need to load views etc on demand, and split them into small “modules”. Developing a RIA is not like developing a stateless ASP.NET app.

  • I’m going to talk about Silverlight 3.0 and .Net RIA Services

    For my Swedish readers. If you are interested to see some of the new features in Silverlight 3.0 and also the .Net RIA Services and out-of-‘browser feature, I’m going to talk about it on Developer Summit in Stockholm 15-16 April. I’m responsible for the Web track and there are be sessions about ASP.Net 4.0 AJAX, Dynamic Data, Building Web sites with Entity Framework etc. You can find more about the web sessions here: http://www.cornerstone.se/sv/ExpertZone/developersummit/2009/Startsida/Webb/

  • HTML is so 1990

    Yesterday I was on a meeting with some people from Microsoft and other companies working with social media and communication etc. We talked about the future of the web. I have developed web applications since 1995 or something like that and I’m so tired of is HTML, CSS and client-side script. During the last years people have done incredible web application with technology like AJAX to increase user experience. But HTML, Client-side script and the Browser we are using have limitations, it takes time to build application with rich and good user experience, some stuff are impossible to do because of a limitation both in the HTML, CSS, Client-side script and browser to create Rich Internet Applications. We need a new solutions, a new better way to build applications, and we have two “tools” we can use today to create richer web/internet applications, Flash and Silverlight.

  • on Twitter

    For some month ago I just created a Twitter account, and suddenly some poeple found me.. I didn't told anyone that I was on Twitter because I didn't know if I'm going to use it. But now when I got some fre followers I suddenly had to write something ;)

  • MasterPage and Silverlight

    I have seen several post about how to implement MasterPage in Silverlight 2.0, most of the posts are about using “fixed” UserControls and dynamically change the content of a control in code-behind. Here is another solution where a Template will be used instead.

  • How the Presentation Model could look like when using Silverlight 2.0 (Part 4)

    I have created a small framework only for fun and to have a programming task ;) The framework I have created (not yet 100% completed) is similar to Prism, Caliburn and Silverlight.FX. So this is not a framework that should replace those other framework, it still only a hobby project to see if I managed to create a similar one. I will still write about it in this Part 4 of my Presentation Model series. The goal with the framework is to leave the code-behind alone and focus on a separate class and declare everything in the XAML. The following is an example of a class (a Presentation Model):

  • User Input Validation in Silverlight 2.0

    There are different ways of getting data from a Silverlight application, in this blog post I will focus on using WCF. When we use WCF we define DataContract which will be used between the client and the server. It’s relative easy to create a DataContract, here is an example of a contract:

  • Improvements in the .Net Community

    It’s amazing how fast the .Net Community have improved it self the last year. More and more developers and architects start to see how important it is to deliver high quality. More and more are interested in design patterns and principles like S.O.L.I.D. They are also interested in how to keep the code they write clean. I have done some work to validate companies design and architecture decisions, and I have notice that more and more companies want this kind of “validation” from someone outside the company, because they start to see that if they use the wrong design or architecture, they are going to pay a lot of more money than if they had the right architecture from the beginning. The cost about getting a validation is so cheap regarding to how much money they need to spend on rewriting or maintaining, or handling problems when they use the wrong architecture. I will say that companies are smarter now than before ;)