Wednesday 14 September 2011

Windows 8

Microsoft finally unveiled some additional details regarding new Windows 8. If you would like to watch the keynote session please have a look at

Some key conclusions (for developers) from the keynote:
  • JavaScript is becoming a first-class language (you can find few proofs below)
  • Developers will receive VS2011 and Expression Blend 5 with arrival of Windows 8

I really like new Microsoft 'no compromises' approach which means that developers will be able to use new Windows 8 tablets for everything - the most important for coding.

Wednesday 7 September 2011

Key concepts in Silverlight in comparison with WPF

In this article I would like to show you how to use some of the key Silverlight features:
  • Dependency Properties,
  • Data Bindings,
  • Commands,
  • Implicit styles,
  • Explicit styles,
  • Visual State Manager,
  • Animations,
  • Value Converters,
  • CollectionViewSource,
  • Custom Controls.

1. Dependency Properties
If you want to understand the reason and the way how DP works please visit this link. I would like to mention differences between WPF and SL DPs. When you create DP in SL you can specify PropertyMetadata but as a result you will lack coercion and validation support which can be handled in FrameworkPropertyMetadata (WPF). These two can be useful especially if you want to create advanced controls. If you cannot imagine how coercion can be useful for you I can give an example - range IP address control.

   1:  public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(CelestialBodyControl), new PropertyMetadata(double.NaN));
   3:          public double Radius
   4:          {
   5:              get { return (double)GetValue(RadiusProperty); }
   6:              set { SetValue(RadiusProperty, value); }
   7:          }

2. Data Bindings 
I describe data bindings as maximum functionality and minimum code, very useful for displaying and interacting with data. Bindings are even more useful when you use Model-View-ViewModel (MVVM) pattern because in case like that data bindings create these pipelines/streams of data between presentation layer (V) and logic behind it (VM) and no additional code is needed.

Example below shows how to use data bindings directly in your view (V)
   1:  <local:CelestialBodyControl BodyName="{Binding Name}" Radius="{Binding Radius}" AverageDistanceFromSun="{Binding AverageDistanceFromSun}" 
   2:                                                  RotationPeriod="{Binding RotationPeriod}" OrbitalPeriod="{Binding OrbitalPeriod}"/>

This example shows how to use a data binding inside a style
   1:  <TextBlock Text="{Binding Radius, RelativeSource={RelativeSource TemplatedParent}}" Foreground="White"/>

Tuesday 6 September 2011

How to list and activate services from command-line console

My colleague had this unusual problem with his computer (actually it was a virus) and he had no access to the Services console in Administrative Tools but at the same time he had to run a service. As a solution we decided to use a command-line console. Please have a look below to find out how you can do it.

To list all up and running services type: net start
To list all inactive services type: sc query type= service state= inactive
With the second command you can check the name of your inactive service and to make it running type: sc start [service name]