European Silverlight 4 & Silverlight 5 Hosting BLOG

BLOG about Silverlight 5 Hosting and Its Techologies - Dedicated to European Windows Hosting Customer

European Silverlight 4 Hosting - Amsterdam :: How to Use AutoCompleteBox in Silverlight 4

clock March 14, 2012 07:44 by author Scott

In this article let us see how to use a AutoCompleteBox Control in a Silverlight application. As usual, open the visual studio and select the Silverlight project.

First let us drag a AutoCompleteBox to Stack Panel as shown below into
MainPage.xaml.

<sdk:AutoCompleteBox x:Name="CountriesNames" Width="200" />


Now we will add List to
AutoCompleteBox from MainPage.xaml.cs as shown below. In the below code, First i prepared list of type string and assigned a name "Countries" to it. Then i added strings( Countries names) to the list "Countries".

List<string> Countries = new List<string>();
             Countries.Add("India");
             Countries.Add("USA");
             Countries.Add("Japan");
             Countries.Add("UK");
             Countries.Add("Australia");
             Countries.Add("Switzerland");
             CountriesNames.ItemsSource = Countries;


At last i am binding this list "
Countries" to the "AutoCompleteBox" using its name "CountriesNames". Thats it!!! Just press F5 and see the result. The output of the above code looks like as

<image>


Note
: For the people who find it difficult to integrate the above code, I am pasting the complete code here.

MainPage.Xaml:

<UserControl x:Class="SilverlightTest1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <StackPanel Background="White">
        <StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
            <TextBlock Text="CountriesList: " Margin="5" VerticalAlignment="Center" />
            <sdk:AutoCompleteBox x:Name="CountriesNames" Width="200" />
        </StackPanel>
     </StackPanel>

</UserControl>


MainPage.Xaml.cs:

public MainPage()
{
InitializeComponent();
List<string> Countries = new List<string>();
Countries.Add("India");
Countries.Add("USA");
Countries.Add("Japan");
Countries.Add("UK");
Countries.Add("Australia");
Countries.Add("Switzerland");
CountriesNames.ItemsSource = Countries;

}

 



European Silverlight 5 Hosting - Amsterdam :: Using the DatePicker control in Silverlight 5

clock March 5, 2012 07:27 by author Scott

This article introduces the DatePicker control present in the Silverlight Toolkit and shows how to use it in Silverlight applications.

The DatePicker control enables users to select dates using a Calendar like interface. It also includes a TextBox as part of its interface so that users can enter a date instead of selecting one from the Calendar.


The DatePicker control is not part of the Silverlight runtime, it is available in the Silverlight SDK. To use a control from the Silverlight SDK, you must add a reference to the assembly and include the appropriate XML namespace mapping in XAML.


For example,


xmlns
:sdk=http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk

Let us see how to use this control.


Create a new Silverlight 5 application named SilverlightDemo.


You can see the DatePicker control in the Toolbox.




Add the DatePicker control from the Toolbox into your application between the <Grid></Grid> tags.


The XAML markup will look as follows:


<UserControl x:Class="SilverlightDemo.MainPage"

xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns
:d=http://schemas.microsoft.com/expression/blend/2008
xmlns
:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
mc
:Ignorable="d"
xmlns
:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
HorizontalAlignment
="Stretch" VerticalAlignment="Stretch">
<Grid x:Name="LayoutRoot" Background="White">

<sdk:DatePicker Height="23" HorizontalAlignment="Left" Margin="49,77,0,0" Name="datePicker1" VerticalAlignment="Top" Width="120" />

</Grid>

</UserControl>


Save, build, and execute the application. Click the calendar icon next to the Textbox in the DatePicker.




The default date format of the The DatePicker control is M/dd/yyyy. To change the format, you either use the SelectedDateFormat property which allows one of two values: Long or Short, or set the current culture of the thread to a new culture, which will also affect the date format. You can also change number of properties of this control.




Add a TextBox and a Button control to the page and configure the XAML markup as follows:


<UserControl x:Class="SilverlightDemo.MainPage"

xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns
:d=http://schemas.microsoft.com/expression/blend/2008
xmlns
:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
mc
:Ignorable="d"
xmlns
:sdk=http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk
HorizontalAlignment
="Stretch" VerticalAlignment="Stretch">
<Grid x:Name="LayoutRoot" Background="White">

<TextBox x:Name="txtDate" Height="20" Margin="49,124,182,156" Width="99"/>

<sdk:DatePicker Height="23" HorizontalAlignment="Left" Margin="49,77,0,0" Name="datePicker1" VerticalAlignment="Top" Width="120" DisplayDateEnd="11/26/2012" SelectionBackground="#FFE83333" FontFamily="Georgia" FontSize="14" DisplayDateStart="{Binding Text, ElementName=txtDate, Mode=TwoWay}" />

<Button Height="25" Margin="40,167,169,108" Width="94" Content="OK"/>

</Grid>

</UserControl>


This markup sets the start date, end date, font style, selection background color, and binds the content of the text box to the DatePicker.

Some of the commonly used properties of the DatePicker control are:

Property

Description

BlackoutDates

Retrieves or assigns a collection of dates that are blacked out or unselectable

CalendarStyle

Retrieves or assigns the style that is used when rendering the calendar

DisplayDate

Retrieves or assigns the date to be displayed

DisplayDateEnd

Retrieves or assigns the beginning date in the calendar

DisplayDateStart

Retrieves or assigns the end date in the calendar

FirstDayOfWeek

Retrieves or assigns the day that is considered the beginning of the week

IsDropDownOpen

Retrieves or assigns a value that indicates whether the drop-down Calendar is open or closed

IsTodayHighlighted

Retrieves or assigns a value that indicates whether the current date is highlighted

SelectedDate

Retrieves or assigns the selected date

SelectedDateFormat

Retrieves or assigns the format that is used to display the selected date

SelectionBackground

Retrieves or assigns the background used for selected dates

 



European Silverlight 4 Hosting - Amsterdam :: Dynamic Types to Simplify Property Change Notification in Silverlight 4 and 5

clock March 1, 2012 07:59 by author Scott

The biggest problem with data-binding is the requirement to implement the INotifyPropertyChange interface. There are dozens of solutions out there that try to simplify the process with techniques ranging from parsing lambda expressions and walking the stack frame to using IL weaving to modify classes at compile time. The most popular approach is to derive from a base class and call a base method to handle the event.

The frustration often comes from mapping data objects that don't implement the interface to view models that do. Wouldn't it be nice to have a simple, straightforward way to manage this without duplicating properties and writing tedious mapping code? It turns out there is.


For this particular problem, I started with the solution. Given a model, say, a ContactModel, I wanted to be able to do this:


public PropertyNotifier<ContactModel> Contact { get; set; }
public void SetContact(ContactModel contact)
{
   Contact = new PropertyNotifier(contact);
}


In other words, a nice type would wrap the object and expose it with full property change glory, and little effort on my part.


So, where to start? To begin with I created a simple base class that allows for property change notification. For now I'm going to ignore some of the interesting ways to actually call the notification.


public abstract class BaseNotify : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public void RaisePropertyChange(string propertyName)
    {
        var handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}


This class is really all you need to have your own MVVM framework. Next is some heavy lifting. Because the solution uses dynamic types and heavy reflection, it will not work on Windows Phone 7. It will, however, work with Silverlight 4, and there is perhaps an even more elegant solution to be derived from this work in Silverlight 5 by adding ICustomTypeProvider to the mix.


How can this create a bindable object in Silverlight 4 or 5? First, create the shell of the view model. It should create the proxy class with property change notification. It should allow you to pass in a template and have that template mirrored by the proxy. Ideally, it should be easy to get the template back out (i.e. yank out the original model to send on its way after it has been modified). Here's the start:


public class PropertyNotifier<TTemplate> : BaseNotify where TTemplate : class
{
   public TTemplate Instance { get; set; }
   public INotifyPropertyChanged NotifyInstance { get; set; }
}
   

Simple enough. Not sure if the notifier instance really deserves a public setter... but it is there for now. Now comes the fun part!


The type must be created on the fly, so it needs a dynamic assembly and module to host the type. There is no sense in creating a new one for each type, so these can be static properties that live on the notifier. There should also be a type dictionary to map the source type to the proxy type (to avoid recreating the proxy type) and a mutex to avoid collisions with the dictionary (thread safety).


private static readonly ModuleBuilder _builder;
private static readonly Dictionary<Type, Type> _types = new Dictionary<Type, Type>();
private static readonly object _mutex = new object();       

static PropertyNotifier()
{
    var assemblyName = new AssemblyName("PropertyNotifier");
    var currentDomain = AppDomain.CurrentDomain;
    var builder = currentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);

    _builder = builder.DefineDynamicModule("PropertyChangeModels");
}


If you are afraid of collisions you can give the assembly a creative name like a GUID or append random text and strings if you like. This makes it nice and readable in the debugger. The assembly is created in the current domain and the module defined to host dynamic types.


Without understanding the details of how the type is actually built, you can still wire in the constructor and put in a placeholder, like this:


public PropertyNotifier()
{
    Monitor.Enter(_mutex);
    try
    {
        if (!_types.ContainsKey(typeof (TTemplate)))
        {
            _types.Add(typeof(TTemplate), _BuildType());
        }                               
    }
    finally
    {
        Monitor.Exit(_mutex);
    }

    var type = _types[typeof (TTemplate)];          

    NotifyInstance = (INotifyPropertyChanged)Activator.CreateInstance(type);                   
}

public PropertyNotifier(TTemplate instance) : this()
{
    Instance = instance;
}


If the type has not been created, it is built. An overloaded constructor will take in an instance and then set it.


Next, assuming the type is built (we'll get into the gory details later), a few methods will help with mapping properties. First, define a delegate for the getter and setter. Then, define a dictionary of dictionaries. The key to the outer dictionary will be the type, and the inner dictionary will map the property name to the getter or setter method.


private delegate void Setter(object target, object value);

private delegate object Getter(object target);

private static readonly Dictionary<Type, Dictionary<string,Setter>> _setterCache = new Dictionary<Type, Dictionary<string,Setter>>();
private static readonly Dictionary<Type, Dictionary<string,Getter>> _getterCache = new Dictionary<Type, Dictionary<string, Getter>>();


The helper methods will inspect the type for the property information and use reflection to grab the getter or setter. They will then store these in the cache for future look ups:


private static object _GetValue(object target, string property)
{
    Monitor.Enter(_mutex);
    try
    {
        if (!_getterCache[target.GetType()].ContainsKey(property))
        {
            var method = target.GetType().GetProperty(property).GetGetMethod();
            _getterCache[target.GetType()].Add(property, obj => method.Invoke(obj, new object[] {}));
        }
    }
    finally
    {
        Monitor.Exit(_mutex);
    }

    return _getterCache[target.GetType()][property](target);               
}

private static void _SetValue(object target, string property, object value)
{
    Monitor.Enter(_mutex);
    try
    {
        if (!_setterCache[target.GetType()].ContainsKey(property))
        {
            var method = target.GetType().GetProperty(property).GetSetMethod();
            _setterCache[target.GetType()].Add(property, (obj,val) => method.Invoke(obj, new[] { val }));
        }
    }
    finally
    {
        Monitor.Exit(_mutex);
    }

    _setterCache[target.GetType()][property](target, value);
}


You can call the first with an object and the property name to get the value. Call the second with the object, the property name, and the property value to set it. Subsequent calls will not require inspection of the properties as the methods will be cached to call directly.


So the proxy still hasn't been built yet, but that's more complicated. First, get the simple stuff out of the way. When the instance is passed in, automatically wire the properties to the proxy. When the proxy is created, hook into the property change notificaton to automatically push changes back to the original instance:


private TTemplate _instance;

// original object
public TTemplate Instance
{
    get { return _instance; }
    set
    {               
        _instance = value;
        NotifyInstance = (INotifyPropertyChanged)Activator.CreateInstance(_types[typeof (TTemplate)]);

        foreach(var p in typeof(TTemplate).GetProperties())
        {
            var sourceValue = _GetValue(value, p.Name);
            _SetValue(NotifyInstance, p.Name, sourceValue);
        }

        RaisePropertyChange("Instance");
    }
}

// proxy object
private INotifyPropertyChanged _notifyInstance;

public INotifyPropertyChanged NotifyInstance
{
    get { return _notifyInstance; }
    set
    {
        if (_notifyInstance != null)
        {
            _notifyInstance.PropertyChanged -= _NotifyInstancePropertyChanged;
        }

        _notifyInstance = value;
        _notifyInstance.PropertyChanged += _NotifyInstancePropertyChanged;

        RaisePropertyChange("NotifyInstance");               
    }
}

void _NotifyInstancePropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (Instance == null)
    {
        return;
    }          

    if (_setterCache[typeof (TTemplate)].ContainsKey(e.PropertyName))
    {
        _SetValue(Instance, e.PropertyName, _GetValue(NotifyInstance, e.PropertyName));
    }
}


OK, all of the proxy and marshalling is in place. Now it's time to build the type! First step is to define the type name and set the parent so it derives from the BaseNotify object:


private static Type _BuildType()
{
    var typeBuilder =
        _builder.DefineType(string.Format("{0}Notifier", typeof (TTemplate).Name), TypeAttributes.Class | TypeAttributes.Public);

    typeBuilder.SetParent(typeof(BaseNotify));
}


Next, grab a handle to the property change method from the base class and set up a dictionary to cache the getters and setters on the template type:


var propertyChange = typeof(BaseNotify).GetMethod("RaisePropertyChange", new[] { typeof(string)});

_getterCache.Add(typeof(TTemplate), new Dictionary<string, Getter>());
_setterCache.Add(typeof(TTemplate), new Dictionary<string, Setter>());                       


Now comes the fun part, looping through the properties and caching the getters/setters (this is from the template):


foreach(var p in typeof(TTemplate).GetProperties())
            {
                var getterInfo = p.GetGetMethod();
                _getterCache[typeof(TTemplate)].Add(p.Name, obj=>getterInfo.Invoke(obj, new object[]{}));

                var setterInfo = p.GetSetMethod();
                _setterCache[typeof(TTemplate)].Add(p.Name, (obj,value)=>setterInfo.Invoke(obj, new[]{value}));
}


Each property has a private backing field, so create the field on the proxy type:


var field = typeBuilder.DefineField(string.Format("_{0}", p.Name), p.PropertyType, FieldAttributes.Private); 
              

Next, define the property.


var property = typeBuilder.DefineProperty(p.Name, PropertyAttributes.HasDefault, p.PropertyType,null);

The property needs a getter. This is where the code is a little more interesting becaues it requires emitting IL code. Fortunately, you can build a sample class and use ILDASM.EXE to disassemble it and learn what the proper op codes are. Here is the getter method:


var getter = typeBuilder.DefineMethod(string.Format("get_{0}", p.Name),
    MethodAttributes.Public |
    MethodAttributes.SpecialName |
    MethodAttributes.HideBySig,
    p.PropertyType, Type.EmptyTypes);
var getterCode = getter.GetILGenerator();

getterCode.Emit(OpCodes.Ldarg_0);
getterCode.Emit(OpCodes.Ldfld, field);
getterCode.Emit(OpCodes.Ret);

Next is the setter method. The setter method has some extra code that loads the property name and then calls the property change method. That is why the handle to the method was captured earlier.

var setter = typeBuilder.DefineMethod(string.Format("set_{0}", p.Name), 
    MethodAttributes.Public |
    MethodAttributes.SpecialName |
    MethodAttributes.HideBySig, null,
    new[] { p.PropertyType });

var setterCode = setter.GetILGenerator();

setterCode.Emit(OpCodes.Ldarg_0);
setterCode.Emit(OpCodes.Ldarg_1);
setterCode.Emit(OpCodes.Stfld, field);


// property change
// put the property name on the stack
setterCode.Emit(OpCodes.Nop);
setterCode.Emit(OpCodes.Ldarg_0);
setterCode.Emit(OpCodes.Ldstr, p.Name);
setterCode.Emit(OpCodes.Call, propertyChange);
setterCode.Emit(OpCodes.Nop);               

setterCode.Emit(OpCodes.Ret);

Now that the methods have been generated, they must be attached to the property:

property.SetGetMethod(getter);
property.SetSetMethod(setter);

That's the hard part! The easy part is to define a default constructor (calls down to the base) and create the actual type. Remember, this is the method called in the constructor so the type is returned and stored in the dictionary, then the activator is used to create the instance. Also, go ahead and set up the getter and setter cache:

typeBuilder.DefineDefaultConstructor(MethodAttributes.Public);                        

var type = typeBuilder.CreateType();           

_getterCache.Add(type,new Dictionary<string, Getter>());
_setterCache.Add(type,new Dictionary<string, Setter>());           

return type;

Believe it or not, that's what it takes to build a proxy, assuming the base class contains simple properties and no complex nested types or structures. Here's a simple template to test the proxy with:

public class ContactTemplate
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }       
}

Here's a view model that is based on the template. It uses the property notifier to wrap the properties with property change notification. It also creates a default template in the constructor just to give you some information to work with when the application runs:

public class ContactViewModel : PropertyNotifier<ContactTemplate>
{      
    public ContactViewModel()
    {
        var template = new ContactTemplate
                            {
                                Id = 1,
                                FirstName = "Jeremy",
                                LastName = "Likness"
                            };
        Instance = template;
    }      
}

Now some XAML to bind it all together:

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.DataContext>
        <ViewModels:ContactViewModel/>
    </Grid.DataContext>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <TextBlock Text="First Name: "/>
    <TextBlock Text="Last Name: " Grid.Row="1"/>
    <TextBlock Text="Edit First Name: " Grid.Row="2"/>
    <TextBlock Text="{Binding NotifyInstance.FirstName}" Grid.Column="1"/>
    <TextBlock Text="{Binding NotifyInstance.LastName}" Grid.Row="1" Grid.Column="1"/>
    <TextBox Text="{Binding NotifyInstance.FirstName,Mode=TwoWay}" Grid.Row="2" TextChanged="TextBox_TextChanged" Grid.Column="1" Width="200"/>
</Grid>

When you run the application, you'll find the property change works just fine. Now, with this helper class, anytime you need to take a simple data object and implement property change, you can just wrap it in the property notifier and bind to the InstanceNotifier property. This works perfectly well in Silverlight 4.



European Silverlight 4 Hosting - Amsterdam :: HTTP Error 404.0 - Not Found (MapRequestHandler / StaticFile) when deploying WCF Web API on IIS 7.x

clock February 15, 2012 07:12 by author Scott

If you’re deploying a WCF Web API application to your IIS 7.x you might receive a HTTP Error 404.0 (MapRequestHandler / StaticFile):



As you know, WCF Web API relies on .NET Framework 4.0.

So lets take a look into the application pool for our application:



Everything looks fine here.

So lets dig a little bit deeper – namely inspect the ISAPI Filters:



Looks like ASP.NET 4 is missing here… so lets fix it:

PS C:\Windows\Microsoft.NET\Framework64\v4.0.30319> .\aspnet_regiis.exe -i
Start installing ASP.NET (4.0.30319).
........
Finished installing ASP.NET (4.0.30319).


Now hit F5 in your browser:



(If it’s not working after installing ASP.NET 4.0.x please review the version in your application pools settings again and fix it if necessary).



European Silverlight Hosting - Amsterdam :: Data Driven Example Using Silverlight Business Application

clock February 13, 2012 07:36 by author Scott

This post discusses how to displays data from the AdventureWorks Database on to Silverlight pages. In this walkthrough you will find the page that displays the data from customer table in adventure database and allows the user to traverse the records. You need to have Visual Studio 2010 SP1 installed on your machine.

Silverlight business application contains two projects a Silverlight application and an ASP.NET Web application which hosts the Silverlight application.

To change the application string value that displaying in the page

1. Expand the assets folder and expand the resources

2. Change the application name as shown below and run the application





3. Creating a data model for the application, right click the Silverlight web application click add new item and select the ADO.NET Entity Data model as shown below



In choose model content page, click generate content from database option as shown in the below dialogue



Select the database object that you want to display the data in Silverlight pages



Customer table appear in the entity designer as shown below



Build the solution.

Adding a domain service

A domain service exposes the data model to client. You can add the domain service to the server project as shown below

Right click the ASP.NET web application  and add new item, select the domain service class from project dialogue box



Select the Customers table and Enable Editing checking boxes, and then click ok



Build the solution

Creating a Silverlight page to display data

1. In solution explorer right click the Views folder Silverlight client application, Add New Item dialogue box , select the Silverlight Category and then click the Silverlight Page template.




2.  To display the data in data grid, click the datasources and then click the Show Data Sources

The data source window displays the customer entity, drag the customer node to the designer



3. Add a navigation button to the page that we created above in Homepage as shown below

   1: <Rectangle x:Name="Divider3" Style="{StaticResource DividerStyle}"/>
   2: <HyperlinkButton x:Name="Link3" Content="Customer List"
       Style="{StaticResource LinkStyle}"
   3: NavigateUri="/Customers" TargetName="ContentFrame"/>

4.  Run the application. You will notice Customer List button in navigation bar as shown below




Europe Silverlight 5 Hosting - Amsterdam :: New Features in Silverlight 5

clock February 6, 2012 10:11 by author Scott

Microsoft's official website for Silverlight states: "Silverlight is a powerful development tool for creating engaging, interactive user experiences for Web and mobile applications. Silverlight is a free plug-in, powered by the .NET framework and compatible with multiple browsers, devices and operating systems, bringing a new level of interactivity wherever the Web works."

Silverlight has become the platform of choice for building next generation of cross-browser, cross-platform Rich Internet Applications (RIAs). The latest version – Silverlight 5 - introduces many new features that cater to business application development and media experiences.

To work with Silverlight 5, you need the following installed in your system:

·         Visual Studio 2010 with SP1

·         Silverlight 5 Tools for Visual Studio

So, what’s new?

Silverlight 5 introduces 64-bit browser support, so, you will notice faster start up times and hardware acceleration. Support for RIA Services in Silverlight is even better, with enhanced MVVM support and improved support for customization of generated code. WCF is the platform of choice for building services that can be consumed in any platform.

The MSDN states, "Windows Communication Foundation (WCF) is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments."

WCF RIA Services help you to get data from disparate sources without the need of service plumbing.

The MSDN states: "WCF RIA Services simplifies the development of n-tier solutions for Rich Internet Applications (RIA), such as Silverlight applications. A common problem when developing an n-tier RIA solution is coordinating application logic between the middle tier and the presentation tier. To create the best user experience, you want your RIA Services client to be aware of the application logic that resides on the server, but you do not want to develop and maintain the application logic on both the presentation tier and the middle tier. RIA Services solves this problem by providing framework components, tools, and services that make the application logic on the server available to the RIA Services client without requiring you to manually duplicate that programming logic."

There have also been enhancements in text and printing support. Silverlight 5 introduces vector based printing. Text clarity in Silverlight 5 is much more improved, thanks to the Pixel Snapping feature. OpenType support in Silverlight 5 is also enhanced. Silverlight 5 enables you to control media playback with remote control devices. The Digital rights management feature enhancement in Silverlight 5 allows you switch between DRM and media sources seamlessly.

Silverlight 5 also comes with an improved power awareness feature. When viewing videos in Silverlight 5, you won't be distracted with screensavers. When the video is not being viewed, the screensaver will be back in action. Silverlight 5 provides support for reduced network latency using a background thread for networking support for improved performance.

John Papa states: "Hardware Decode and presentation of H.264 improve performance for lower-power devices to render high-definition video using GPU support."

Silverlight 5 comes with improved data binding and debugging support. Data binding is the act of binding data to data controls.

The latest version of Silverlight also provides rich 3-D support. Silverlight 5 introduces accelerated 3D graphics. The Graphics Processing Unit (GPU) has been enhanced in the 3-D application programming interface (API) in Silverlight 5. The GPU provides support for accelerated graphics.

The MSDN states: "Silverlight 5 RC introduces the ability to use hardware accelerated 3D graphics in your Silverlight applications. This opens up a whole new set of scenarios that are possible in Silverlight, such as 3D drawn controls, data visualizers, 3D charts, scatter points, geographic overlays, and 3D games and simulations. This topic goes over using 3D graphics in Silverlight."

Silverlight 5 also brings Desktop capabilities to the browser for the first time.

According to John Papa: "Silverlight offers a new class of trusted applications that brings desktop capabilities to the browser for the first time. These features, when enabled via a group policy registry key and an application certificate, mean users won’t need to leave the browser to perform complex tasks."

These Desktop features in Silverlight 5 include:

·         Support for hosting HTML content as a Web Browser control in a Silverlight application

·         Read and Write files in the MyDocuments folder in your system

·         Launch Desktop applications

·         Access devices using the COM interface

·         Invoke unmanaged code

Conclusion

There are many great features in Silverlight 5 as have discussed above and if you are looking for Silverlight 5 hosting, you can host your Silverlight 5 site as low as €3.00/month with HostForLIFE.eu.

 



Press Release - Premier European HostForLIFE.eu Launches Silverlight 5 Hosting

clock February 3, 2012 06:51 by author Scott

HostForLIFE.eu was established to cater to an under served market in the hosting industry; web hosting for customers who want excellent service. HostForLIFE.eu – a cheap, constant uptime, excellent customer service, quality, and also reliable hosting provider in advanced Windows and ASP.NET technology. We proudly announces the availability of the Silverlight 5 hosting in our entire servers environment.

You can start hosting your ASP.NET MVC 3 site on our environment from as just low €3.00/month only. For more information about our new product, please visit our site at
http://www.hostforlife.eu/Silverlight-5-European-Hosting.aspx.

“Today, we are really happy to announce the release of Silverlight 5 on our hosting environment. Silverlight 5 is part of a rich offering of technologies from Microsoft helping developers deliver applications for the web, desktop, and mobile devices. I personally would like to thank the people who have assisted in completing this project.” Said CEO of HostForLIFE.eu, Anthony Johnson.

“Silverlight 5 delivers great features that allow hardware H.264 decoding, adapting it better for video content. It also sports an improved graphics stack with 3D support, using the  XNA API.  This makes Silverlight 5 a more mature and capable platform for developing rich internet application.” Said John Curtis, VP Marketing and Business Development at HostForLIFE.eu. “We believe that our Silverlight 5 provide great opportunity to web developers.”

Silverlight 5 also includes the following developer related enhancements:

- XAML Debugging with breakpoints for binding debugging
- Implicit data templates for easy UI reuse
- Double (and multi) click support
- GPU-accelerated XNA-compatible 3D and immediate-mode 2D API
- Low-latency sound effects and WAV support
- Real operating system windows and multi-display support
- Significant performance improvements, fixes and much more

For complete information about this new product, please visit our official site at
http://www.hostforlife.eu.

About us:

We are European Windows Hosting Provider which FOCUS in Windows Platform ONLY. We support Microsoft technology, such as the latest ASP.NET 4, ASP.NET MVC 3, SQL 2008/2008 R2, and much more.

Our number one goal is constant uptime. Our data center uses cutting edge technology, processes, and equipment. We have one of the best up time reputations in the industry.

Our second goal is providing excellent customer service. Our technical management structure is headed by professionals who have been in the industry since it's inception. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



European Silverlight 4 Hosting :: UserControls and the dreaded “name already exists in the tree”

clock January 27, 2012 09:45 by author Scott

I was doing some work with Silverlight the other week which involved using UserControls where the control named itself. That is, a situation such as;

<UserControl x:Name=”foo”>

<!—Content of control –>

</UserControl>

and, under unpredictable circumstances I was finding that I kept hitting a semi-random error when running my code which was something along the lines of;


“The name already exists in the tree: foo”

I spent an awfully long time on this and hence the blog post to try and perhaps save you some time in the future. I took long enough on it to come up with a simple repro scenario which looks something like this;



and so in words I have a ListBox which displays instances of UserControl1 and that control is just a StackPanel which contains 2 instances of UserControl2 and that control happens to name itself in its definition.

I found that if I ran this application a few times then sometimes it would work fine and sometimes it would fail with the dreaded exception and so I asked internally whether that was expected and it was confirmed as a bug in the Silverlight 4 runtime which has been fixed in Silverlight 5.

In my particular case, I could work around the bug anyway because I was naming that user control in order to use it for some bindings and the workaround I used was to create those bindings from code instead.



European Silverlight 5 Hosting :: Get the Data From Database, Update it and Then Save it Back to Database

clock January 10, 2012 09:40 by author Scott

Lets start by updating the Code Behind of the Mainage.xaml .

Step 1:

Add a event handler for RowEditEnded .

This would give me the updated values of the Row . With this I would be able to update the update the cell and commit it. This event would help me trace the updated values . This event handler is to be added in the constrcutor of the Mainpage.xaml .

articleDataGrid.RowEditEnded += new EventHandler<DataGridRowEditEndedEventArgs>(articleDataGrid_RowEditEnded);


Step 2:

Implement the event handler for RowEditEnded .

I simply put the code to update the article and saving the context in the block .

void
articleDataGrid_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
{
   
try
    {
        if (e.EditAction == DataGridEditAction.Commit)
        {

            articleId = ((Article)e.Row.DataContext).ArticleID;

            Article art = (from article in context.Articles
                          where article.ArticleID == articleId
                          select article).First();

            art.ArticleID = ((Article)e.Row.DataContext).ArticleID;
            art.AuthorID = ((Article)e.Row.DataContext).AuthorID;
            art.Body = ((Article)e.Row.DataContext).Body;
            art.Title = ((Article)e.Row.DataContext).Title;


            context.SubmitChanges();

            MessageBox.Show("Article was sucessfully Updated"); 

        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Updating Article failed :" + ex.Message);
    }

}

Step 3 :

Make sure you load the context in the Constructor of the MainPage class .

context.Load(context.GetArticlesQuery());

We are done. Run the App. Modify the Body or the Title . The Field would be sucessfully updated .



So we are done with Updation . I still need to add the validation to this .

Lets add validation then .

For this example we will go for basic validation . Just go ahead and add a Required attribute to the Domainservice Metadata that was generated .

Your Final Metadata class (DataDomainService.metadata.cs ) would look like as follows :

DataDomainService.metadata.cs

namespace SL2wayWCFRia.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;


    // The MetadataTypeAttribute identifies ArticleMetadata as the class
   
// that carries additional metadata for the Article class.
    [MetadataTypeAttribute(typeof(Article.ArticleMetadata))]
    public partial class
Article
    {
 
       
// This class allows you to attach custom attributes to properties
       
// of the Article class.
       
//
       
// For example, the following marks the Xyz property as a
       
// required property and specifies the format for valid values:
       
//    [Required]
       
//    [RegularExpression("[A-Z][A-Za-z0-9]*")]
       
//    [StringLength(32)]
       
//    public string Xyz { get; set; }
        internal sealed class
ArticleMetadata
        {


            // Metadata classes are not meant to be instantiated.
            private ArticleMetadata()
            {
            }


            [Required]
            public int ArticleID { get; set; }


            [Required]|
            public Nullable<int> AuthorID { get; set; }


            [Required]
            public string Body { get; set; }


            [Required]
            public string Title { get; set; }
        }
    }
}


Now give it a run .

Make the AuthorId field empty and press tab to move to the next field you would get a message as shown below :



European Silverlight 4 WCF Hosting :: How to Solve IIS specified authentication schemes 'Basic, Anonymous'

clock December 21, 2011 08:13 by author Scott

This is an error message that sometimes you can find it when you host your WCF site:

IIS specified authentication schemes 'Basic, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used."

To resolve this problem on an IIS 7.0 server, add the following to the web.config file to disable Basic authentication:

<
system.webServer> 
     <security> 
            <authentication> 
                <basicAuthentication enabled="false" 
/>
            </authentication> 
     </security> 
</system.webServer> 

Note that Anonymous authentication can also be disabled using:

<anonymousAuthentication enabled="false" />

If your site is hosted on an IIS 6.0 server, please contact technical support to disable appropriate authentication on the application containing the WCF service.

OR

You can ask your provider to disable Anonymous authentication for you on IIS. Good luck.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in