Published articles on other web sites*

Published articles on other web sites*

Introducing PDF Viewer for Silverlight/WPF

Introducing PDF Viewer for Silverlight/WPF:
The long-awaited 2012 Q1 with the first official version of RadPdfViewer is already a fact! This is also the first release of the control for WPF, so don’t forget to check it out in the demos if you have missed it: WPF and Silverlight.
A big “Thank You” to all who tried using RadPdfViewer for Silverlight when it was still in a beta stage for providing such a valuable feedback on the control! We have come a long way with your help and hope that you will enjoy the improvements that the first official version brings out.

For the past few months after we first introduced RadPdfViewer as Beta, we have managed to extend the list of supported PDF features in order to be able to show correctly intrinsic PDF files like the ones normally used in LOB applications. The ameliorations include a wider set of image formats and an extensible architecture for plugging in custom filters. The text rendering system was also rethought and improved to ensure

ScrollToBottom extension method in ScrollViewer - Silverlight 4

ScrollViewer is one among the commonly used Silverlight control. When you develop Silverlight application, at some time, you'll come across using ScrollViewer. Using ScrollViewer is straightforward in most of the cases. In some scenarios (like displaying chat history messages, stock history update), we might want to bind values to elements inside the ScrollViewer and then scroll to the bottom in order to make the latest message appear in the visible region.

ScrollToBottom() is one among the several extension methods available for ScrollViewer which helps us to achieve scrolling vertically to the end of the ScrollViewer content. While using this ScrollToBottom() method some developers won't see the ScrollViewer scrolls upto the bottom. So, why it is like that what need to be done to make it work? Let us dive into the implementation of ScrollToBottom() method and find out the solution.

Snippet 1: (ScrollToBottom() implementation)

public static void ScrollToBottom(this ScrollViewer viewer)
   if (viewer == null)
       throw new ArgumentNullException("viewer");


As most of us might guess, it scrolls the veritical offset to the

Unauthorized access exception when value set for property using Secondary Thread - Silverlight

Thinking about threading in Silverlight 4, we choose between the two options
  1. Background worker
  2. Managing thread manually
Most of the time-consuming operations will be handled using the Background worker without blocking the UI. It ultimately executes in a separate thread. The main functions and events to know in Background worker are DoWork, RunWorkerCompleted and RunWorkerAsync. As the name specifies we need to add the event handler for DoWork event for doing the background operation. Add the handler for RunWorkerCompleted to receive the operation completed notification. RunWorkerAsync method is to start the operation. The main thing to note is that we should not access directly access the UI objects from the DoWork event.

Also there are times where we need to manage the threads manually. Since Silverlight runs in a Single threaded apartment (STA) application model and the default is the UI thread, accessing the UI objects from other thread leads to cross thread exception. Knowing this fact I worked with a secondary thread and updated a property in my ViewModel. In that scenario I got an exception and digging into the inner exception found out the cross thread exception. For understanding I've created a sample scenario that raises exception.

Snippet 1

Prism/WPF/Silverlight - setting ItemsControl height and width to full view using DockPanel style

Prism/WPF/Silverlight - setting ItemsControl height and width to full view using DockPanel style:

Figure 2 is the MainRegionTopContentBottom view that Prism will inject three views into (top, content and bottom). When the view is inserted into the MainRegion ItemsControl of figure 1 below the MainRegionTopContentBottom view is compressed vertically - we want it to fill the entire MainWindow.

Figure 1.

Binding Events to Methods in the Silverlight MVVM View Models


This article introduces a simple method to bind UI events to the corresponding methods in the MVVM view models in Silverlight applications.


In order to fully conform to the MVVM design pattern in Silverlight, we may want to move the event handling functions into the view models. Generally speaking, we have two types of UI components and two types of UI events in Silverlight applications.
  • UI controls like a Button have a property called Command. We can create a command property in the view model to handle the click event of the button by binding this command property in the view model to the button control's command property in the XAML. For detailed information about the command bindings, you can take a look at my recent article, "Data and Command Bindings for Silverlight MVVM Applications".
  • Unfortunately though, most of the UI events like "MouseEnter", "MouseLeave", and "SizeChanged", etc. do not have the corresponding Commands, we are unable to implement the ICommand interface to handle these events in the MVVM view models.
This article is to introduce a method to bind these events to the corresponding methods in the view models in Silverlight applications, so we can implement all the event handling functions in the view models, thus minimizing the code-behind files of the XAML views.

Creación de Prototipos de Proyectos para Windows Phone.

Este post lo escribi originalmente en mi blog personal el dia 08/08/2011

Cada vez que nos sentamos delante de nuestro ordenador, cada vez que hablamos con nuestro grupo de trabajo o con nuestros compañeros, o porque no cuando queremos mostrar ese proyecto tan molón a nuestro gerente, deberíamos de apoyarnos en un prototipo del mismo. Para ello estos recursos son de lo mejor que podemos usar.

Lápiz y Papel.

Como muy bien dice mi amigo Yeray, a nosotros los programadores esto del “Pinta y Colorea”, se nos da fatal pero no se porque razón buscamos rápidamente un lápiz y un papel para expresar nuestros esquemas o nuestras pantallas, en vez de ir al ordenador y garabatear algo con el Paint, por ejemplo. En fin para todo aquel que se sienta mas cómodo con un bolígrafo en la mano puede descargarse estas plantillas: