CSLA for Silverlight and binding to a property

CSLA for Silverlight and binding to a property

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


nobby_trussin posted on Thursday, September 24, 2009

Hi,
I am developing a Silverlight application using CSLA for SL but have run into a problem with binding so was wondering if someone would be able to help.

I am trying to bind to a list that has already been retrieved and is exposed as a property in a SharedLists class like follows:

public class SharedLists
{
private ReadOnlyTestList _TestList;
...
public ReadOnlyTestList TestList
{
get
{
return _TestList;
}
}
...
}

So I am looking for some example XAML that would allow me to bind to the SharedLists.TestList property. Is it possible to do this or am I going about it the wrong way? The examples on Lhotka.net all seem to want to call a factory method to retrieve the data.

Thanks and kind regards

Daniel Brannan

sergeyb replied on Thursday, September 24, 2009

If you put your class into resources on the page, default constructor will be invoked on SharedLists as part of instantiation. I think this would conflict with your design. If you still want to do it, you can or you can assign it in code.

Sergey Barskiy
Principal Consultant
office: 678.405.0687 | mobile: 404.388.1899

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

-----Original Message-----
From: nobby_trussin [mailto:cslanet@lhotka.net]
Sent: Thursday, September 24, 2009 8:39 AM
To: Sergey Barskiy
Subject: [CSLA .NET] CSLA for Silverlight and binding to a property

Hi,
I am developing a Silverlight application using CSLA for SL but have run into a problem with binding so was wondering if someone would be able to help.

I am trying to work out how to bind to a property rather than a Factory method using a CSLADataProvider. The examples I downloaded from lhotka.net all seem to use the following pattern where a Factory Method is called to retrieve the data.

FactoryMethod="GetTestList">


So from my understanding, this XAML tells the data provider to call the GetTestList() method on the ReadyOnlyTestList class and bind to the result.

However, I am trying to bind to a list that has already been retrieved and is exposed as a property in a SharedLists class like follows:

public class SharedLists
{
private ReadOnlyTestList _TestList;
...
public ReadOnlyTestList TestList
{
get
{
return _TestList;
}
}
...
}

So I am looking for some example XAML that would allow me to bind to the SharedLists.TestList property. Is it possible to do this or am I going about it the wrong way?

Thanks and kind regards

Daniel Brannan

Copyright (c) Marimer LLC