Linked In Twitter RSS

Virtualization in Silverlight 4 RC

31. March 2010  · Comments (0)
Here is my new article about Virtualization in Silverlight 4 RC.

WCF net.tcp protocol in Silverlight 4

11. December 2009  · Comments (0)
Here is my new article about WCF net.tcp protocol in Silverlight 4  link

Skinning and Styling Silverlight Controls

11. November 2009  · Comments (0)

I have a new article on about skinning and styling Silverlight Controls on Silverlightshow. Check it out on link

Silverlight 3 FireStarter LiveMeeting Event September 17th

8. September 2009  · Comments (0)

This summer’s biggest blockbuster technology event is coming to Redmond, WA on the 17th of September. 

Register to attend the Silverlight-3 FireStarter event on Thursday, the 17th of September. We have a stellar speaker line up from the Microsoft roster. We will have Scott Guthrie keynote the event followed by presentations from Tim Heuer, Brad Abrams, Karl Shifflett and others...

 At this event we will focus on three areas:

 What’s latest and greatest in with the latest release of Silverlight

 What’s happening in the world of Expression 3, and

 Give you a run down on .NET RIA Services, Toolkit, etc. 

 

Time

Session

Speaker

8:45 – 9:00 AM

Event Kick off

Mithun Dhar

9:00 – 10:00 AM

Keynote

Scott Guthrie

10:00 – 11:00 AM

Key Silverlight Scenarios

Tim Heuer

11:00 – 11:15 AM

Break

 

11:15 AM – 12:15 PM

Expression 3 Overview (Includes Behaviors)

Adam Kinney

12:15 – 1:00 PM

Lunch Break (Provided by Microsoft)

 

1:00 – 1:30 PM

Sketch Flow

Janete Perez

1:30 – 2:30 PM

Toolkit & Controls

Justin Angel/Shawn Oster

2:30 – 3:30 PM

RIA Services

Brad Abrams

3:30 – 3:45 PM

Break

 

3:45 – 4:30 PM

Building Silverlight UIs with XAML Power toys

Karl Shifflett

4:30 – 5:00 PM

Q & A Panel

All Speakers

 

Registrations:

Source:
http://blogs.msdn.com/mithund/archive/2009/08/12/silverlight-3-firestarter-thursday-september-17th-2009-attend-redmond-wa-or-online-must-register.aspx

RIA Services July 2009 preview major changes

11. July 2009  · Comments (0)

1) DomainContext class changed significantly

One of improvements is adding support for Asynchronous Domain Operations. DomainContext supports three kinds of domain operations : Query, Submit and Invoke .

I have example where I call Load method of DomainContext and the asynchronous Load call returns a LoadOperation instance immediately or you can add your custom code on load completed:

 LoadOperation<Customers> load=this.context.Load(this.context.GetCustomersQuery());

          load.Completed += new EventHandler(load_Completed);

          this.dgGrid.ItemsSource = load.Entities;

 

2) DomainDataSource API Changes

Don’t break designer anymore. Minor paging problems are also solved.

Previously :

_domainDataSource.LoadMethodName = "GetCustomers";

 _domainDataSource.LoadParameters =new System.Windows.Data.ParameterCollection();

Now :

_domainDataSource.QueryName = "GetCustomers";

 _domainDataSource.QueryParameters =new System.Windows.Data.ParameterCollection();

 

Silverlight 3 databinding improvements with ElementName allows developers to bind one UIElement to another in XAML instead of having to write event handlers.

So now I bind DomainDataSource with my DataPager like this :

 Source="{Binding Data, ElementName=_domainDataSource}"

 I have attached some demo project bellow to show this.

 

3) New project type called .NET RIA Services Class Library

This project is used to simplify creation of N-Tier RIA services applications.

Picture1

When you choose to create .NET RIA Services Class Library it generates to class library projects

one for server and and for client side. Client side middle tier project you reference from your Silverlight app and server side middle tier you reference from your server side project. Project structure looks like this :

Picture2

 

When you add Entity context and DomainContext to .NET RIA Services Class Library project for server side and build project, MS Build will generate client side proxy for you in generated code folder on client side class library project.

Advantages of  middle tier class libraries are that they can be reused in other applications but shared code (specifically *.shared.cs ) in the class libraries is not propagated to the silverlight client during code generation.

 

4) No more need for add [Shared] metadata attribute

and much more changes….

Demo for paging with new DomainDataSource looks like this :

 

RiaServicesPagingDemo.rar

Launch event Silverlight 3 and Expression

10. July 2009  · Comments (0)

Watch http://www.seethelight.com/ for launch of Silverlight 3 RTW and Expression Blend 3 RC.

For download infomation about Silverlight 3 and Blend visit :

http://geekswithblogs.net/tkokke/archive/2009/07/09/silverlight-3-downloads.aspx

.NET Ria services presentation at Kulendayz 2009

15. June 2009  · Comments (0)

I was one of presenters at Microsoft community conference Kulendayz 2009 in Beli Manastir. I have presented there .NET Ria services. Here is my powerpoints and demos:

  .Net Ria Services.pptx (768.70 kb)

  Demos.rar (7.34 mb)

Most of content I have referenced from Nikhil's and Brad's presentation from Mix this year.



Integrating silverlight 3 polling duplex with unity container

2. May 2009  · Comments (0)

These days everybody are using IOC container so I tried to integrate SL 3 Beta(MIX09) Sample chat application that represent how to work with polling duplex with Unity Ioc container. That sample chat application is available for download on codeplex.

After looking how to integrate Unity with Wcf I have founded few nice examples. All those examples are pretty much same.

To integrate Unity with Wcf we must create UnityServiceHostFactory and in markup of service say that service use that factory.

Polling duplex however has also DuplexServiceFactory. So how I integrate those two factories?

I have created all classes needed for UnityServiceHostFactory in UnityServiceHostFactory.cs file such as UnityServiceHost, UnityInstanceProvider and UnityServiceBehavior.

To make example more interesting I have also create IExample interface to inject this interface in service contructor like this:

public ChatService(IExample example)

        {

            examp = example;

            //Set up a stock update every 5 seconds

            this.stockTimer = new Timer(

                new TimerCallback(StockUpdate),

                null, 0, 5000);

        }

void StockUpdate(object o)

        {

            StockTickerMessage stm = new StockTickerMessage();

            //change this message to use method in interface

 

            stm.stock = "MSFT";

            stm.stock += examp.GetMessage();//calling method from injected interface

            stm.price = new System.Random().Next(20, 50);

            PushToAllClients(stm);

        }

In StockUpdate method in ChatService class in have called method GetMessage from Example class:

class Example : IExample

    {

        public string GetMessage()

        {

            return "Example";

        }

    }

In DuplexServiceFactory I have changed CreateServiceHost to use Unity container.

 protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)

        {

 

            UnityServiceHost host = new UnityServiceHost(serviceType, baseAddresses);

            UnityContainer unity = new UnityContainer();

            host.Container = unity;

 

 

            unity.RegisterType<IExample, Example>();

 

 

      

 

            CustomBinding binding = new CustomBinding(

              new PollingDuplexBindingElement(),

              new BinaryMessageEncodingBindingElement(),

              new HttpTransportBindingElement());

 

            host.Description.Behaviors.Add(new ServiceMetadataBehavior());

            host.AddServiceEndpoint(typeof(IUniversalDuplexContract), binding, "");

            host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

 

            return host;

        }

Now if I run my sample application I get error:

“The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.”

Reason for this is because my Polling duplex class is decorated as singleton class

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

    public abstract class DuplexService : IUniversalDuplexContract

    { 

and ServiceDescription.CreateImplementation and is hard-coded to look for a parameterless constructor.

But I want to make contructor injection so my service class must have contructor with parameter.

I have been remove [ServiceBehavior(InstanceContextMode=InstanceContextMode.SIngle)] and let Unity to return singleton instance of DuplexService class.

So I have put in web config file some code that Unity will use to return Singleton instance of DuplexService.

<section name="unity"
type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,
                  Microsoft.Practices.Unity.Configuration" />
<unity>
<containers>
<container>
<types>
<type type="Microsoft.Silverlight.Cdf.Samples.Duplex.IUniversalDuplexContract,ChatWebApp"
mapTo="Microsoft.Silverlight.Cdf.Samples.Chat.ChatService,ChatWebApp"
>
<lifetime type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
    Microsoft.Practices.Unity" />
</type>
</types>
</container>
</containers>
</unity>

After that I have consumed code from web config in my application.

  UnityServiceHost host = new UnityServiceHost(serviceType, baseAddresses);

            UnityContainer unity = new UnityContainer();

            host.Container = unity;

 

 

            unity.RegisterType<IExample, Example>();

 

 

            UnityConfigurationSection section;

            section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

            section.Containers.Default.Configure(unity);

I have tested this by calling IUniversalDuplexContract cont1 = unity.Resolve<IUniversalDuplexContract>() twice and comparing hash of two instances.

Hash was exactly same.That means that  Unity returns singleton instance of ChatService class.

I hope this will help.

Demo project : DuplexWithUnity.rar

ItemClick event on Silverlight ItemsControl

16. March 2009  · Comments (2)

Recently I have been playing with Rik Robinson’s project called Silverlight 2 Scroller. You can read more about this control on this address :

http://www.wintellect.com/CS/blogs/rrobinson/archive/2009/01/22/yngwie-malmsteen-syndrome-silverlight-2-scroller-revisited.aspx

After looking at ItemsControl I have realize that you probobly want to implement click event when user click on your item in ItemsControl.ItemsControl is widely used in Silverlight.I have little modify project above to implement that click event.

Proccess is simple.I have created delegate that reference to method witch have ItemControlEventArgs parameter.I have also created ItemControlEventArgs class that inherits from EventArgs class and inside this class I have add property that represents Item data that is shown inside my  user control.

 public delegate void ItemClickDelegate(ItemControlEventArgs e);

        public class ItemControlEventArgs:EventArgs

        {

            public Employee ItemEmployee{get;set;}   

        }

        public event ItemClickDelegate ItemClicked;

One problem is that PresentationFrameworkCollection class does not have string indexer implemented, so we can’t write something like this :

(sender as Grid).Children["NameOfControl"]

If you have your own user control that use ItemsControl you probably have grid or stackPanel as your container control.I have implement on Grid_MouseLeftButtonDown event some code that iterate trough collection controls and find controls with particular names.

        private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)

        {

            //clicked Employee

            Employee emp = new Employee();

            //iterate trough collection of children controls in grid to get emp info

            foreach (UIElement element in

            (sender as Grid).Children)

            {

                if (element != null)

                {

                    if (element.GetType() == typeof(System.Windows.Controls.StackPanel))

                    {

                        foreach (UIElement childrenElement in (element as StackPanel).Children)

                        {

                            Type childType = childrenElement.GetType();

                            if (childType == typeof(System.Windows.Controls.TextBlock))

                            {

                                if ((childrenElement as TextBlock).Name == "FullName")

                                {

                                    emp.FullName = (childrenElement as TextBlock).Text;

                                }

                                else if ((childrenElement as TextBlock).Name == "Title")

                                {

                                    emp.Title = (childrenElement as TextBlock).Text;

                                }

                                else if ((childrenElement as TextBlock).Name == "Age")

                                {

                                    emp.Age = Convert.ToInt32((childrenElement as TextBlock).Text);

                                }

                            }                 

                        }

                    }

 

                    //image property we don't use for anything

                        emp.ImagePath = "";

                }

 

            }

            ItemControlEventArgs args=new ItemControlEventArgs();

            args.ItemEmployee=emp;

            ItemClicked(args);

        }

After that on page where I use my user control I have event ItemClicked

 SilverlightScroller:ScrollerControl x:Name="theScrollerControl" 

            Margin="0,50,0,0" HorizontalAlignment="Center" VerticalAlignment="Top"

            ScrollTime="250" Width="940" Height="620" ItemClicked="item_Clicked"

and on codebehind I can get my itemData:

 private void item_Clicked(ScrollerControl.ItemControlEventArgs e)

        {

            MessageBox.Show(

            e.ItemEmployee.FullName + " " + e.ItemEmployee.Title + " " +

            e.ItemEmployee.Age.ToString() + " " + e.ItemEmployee.ImagePath);

        }

You can look picture bellow.

Proba1

MouseLeftButtonDown event in StackPanel and Grid don’t fire every time

15. March 2009  · Comments (0)

Recently I have been playing with silverlight and I came into a situation where MouseLeftButtonDown event is not triggered every time.It is only triggered when I click on child control inside container.

One way to fix this is to set background color of container to something.In my example I set my background color of grid control to transparent.

<Grid Height="100" Width="Auto" MouseLeftButtonDown="Grid_MouseLeftButtonDown" Background="Transparent">

Now if you click anywhere inside grid control MouseLeftButtonDown event is triggered.