SilverLight Client Object

SilverLight Client Object

Old forum URL: forums.lhotka.net/forums/t/7337.aspx


SouthSpawn posted on Friday, July 24, 2009

If I wanted to manually create an object on the SL client.

I am struggling with the syntax on how to do it.
 
I am not sure what I pass in for the "callback" param from a syntax standpoint.
 
I thought I could do something like this.
 
EventHandler<Csla.DataPortalResult<MyClass>> myClsCallback

MyClass variable;
 
variable = MyClass.NewMethod(myClassCallback)

Delegates are my strong suit.
 
Any thoughts?

NOTE: I am doing this, because I have an ItemsControl control and a Chart Control on my page.
For some reason, it is only binding the chart control and not the ItemsControl.

It's like after it binds once, it can't bind anymore.

sergeyb replied on Friday, July 24, 2009

I’d just use lambdas:

MyClass.NewMethod((o,e) +

{

            MyClass thing = e.NewObject;

            … do stuff

});

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: SouthSpawn [mailto:cslanet@lhotka.net]
Sent: Friday, July 24, 2009 2:03 PM
To: Sergey Barskiy
Subject: [CSLA .NET] SilverLight Client Object

 

If I wanted to manually create an object on the SL client.


I am struggling with the syntax on how to do it.

 

I am not sure what I pass in for the "callback" param from a syntax standpoint.

 

I thought I could do something like this.

 

EventHandler<Csla.DataPortalResult<MyClass>> myClsCallback


MyClass variable;

 

variable = MyClass.NewMethod(myClassCallback)

Delegates are my strong suit.

 

Any thoughts?



sergeyb replied on Friday, July 24, 2009

I meant

MyClass.NewMethod((o,e) =>

{

            MyClass thing = e.NewObject;

            … do stuff

});

 

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Friday, July 24, 2009 4:17 PM
To: Sergey Barskiy
Subject: RE: [CSLA .NET] SilverLight Client Object

 

I’d just use lambdas:

MyClass.NewMethod((o,e) +

{

            MyClass thing = e.NewObject;

            … do stuff

});

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: SouthSpawn [mailto:cslanet@lhotka.net]
Sent: Friday, July 24, 2009 2:03 PM
To: Sergey Barskiy
Subject: [CSLA .NET] SilverLight Client Object

 

If I wanted to manually create an object on the SL client.


I am struggling with the syntax on how to do it.

 

I am not sure what I pass in for the "callback" param from a syntax standpoint.

 

I thought I could do something like this.

 

EventHandler<Csla.DataPortalResult<MyClass>> myClsCallback


MyClass variable;

 

variable = MyClass.NewMethod(myClassCallback)

Delegates are my strong suit.

 

Any thoughts?

 



Brad replied on Saturday, July 25, 2009

There are two callback syntaxes which I have started using (granted, I've only been looking at Silverlight/CSLA for a couple of days).

MyClass.NewMethod((o,e) =>
{
this.DataContext = e.Object;
});

or:

Where you want to load:
MyClass.NewMethod(BindMyClass);

Then create the BindMyClass method:
private void BindMyClass(object sender, Csla.DataPortalResult e)
{
this.DataContext = e.Object;
}

Note that you would probably want to add some error handling, as it's quite possible that there may be exceptions thrown during normal running (dropped connections, etc).

Hope this helps!
-Brad

Copyright (c) Marimer LLC