We enable design time data generation in both WPF and Silverlight. The model is the same either way - you implement a DesignTime_Create() method in your business class that generates this data.
The data portal detects that it is running in design time and invokes that method instead of doing normal data portal processing.
You guys never cease to impress me – I’ll give that
a whirl today.
How does it work with filtering down to child objects?
Do I need to call the children myself of will that happen if I
just create 5 new child objects and add them to a list?
Or can I put the DesignTime_Create in my listBO and add them
there?
Ie) ParentBO /w ChildListBO
From: RockfordLhotka
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 7:57 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
We enable design time data generation in both WPF and Silverlight. The model
is the same either way - you implement a DesignTime_Create() method in your
business class that generates this data.
The data portal detects that it is running in design time and invokes that
method instead of doing normal data portal processing.
The data portal only invokes the root object. It is your
responsibility to create a mock-up of the object graph as you wish.
I should point out that I’m not real happy with the method
signature right now, as it returns a value. I think it should be a static void
method like the other data portal methods, and that’ll probably change in
3.6.2.
Rocky
From: Jack Addington
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 9:20 AM
To: rocky@lhotka.net
Subject: RE: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
You guys never cease to impress me – I’ll give that
a whirl today.
How does it work with filtering down to child objects?
Do I need to call the children myself of will that happen if I
just create 5 new child objects and add them to a list?
Or can I put the DesignTime_Create in my listBO and add them
there?
Ie) ParentBO /w ChildListBO
From: RockfordLhotka
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 7:57 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
We enable design time data generation in both WPF and Silverlight. The model
is the same either way - you implement a DesignTime_Create() method in your
business class that generates this data.
The data portal detects that it is running in design time and invokes that
method instead of doing normal data portal processing.
If you let me know when you modify it, I’ll be happy to try the
implementation.
From: Rockford Lhotka
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 8:31 AM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
The data portal only invokes the root object. It is your
responsibility to create a mock-up of the object graph as you wish.
I should point out that I’m not real happy with the method signature
right now, as it returns a value. I think it should be a static void method
like the other data portal methods, and that’ll probably change in 3.6.2.
Rocky
From: Jack Addington
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 9:20 AM
To: rocky@lhotka.net
Subject: RE: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
You guys never cease to impress me – I’ll give that a whirl
today.
How does it work with filtering down to child objects?
Do I need to call the children myself of will that happen if I
just create 5 new child objects and add them to a list?
Or can I put the DesignTime_Create in my listBO and add them
there?
Ie) ParentBO /w ChildListBO
From: RockfordLhotka
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 7:57 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
We enable design time data generation in both WPF and Silverlight. The model
is the same either way - you implement a DesignTime_Create() method in your
business class that generates this data.
The data portal detects that it is running in design time and invokes that
method instead of doing normal data portal processing.
Rocky,
I couldn’t get this to work in Silverlight. I had to
add a public constructor because the designtime didn’t pick up anything
in the #if !SILVERLIGHT … #endif directives.
But that didn’t seem to help. Is there a way to deb
From: Jack Addington
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 9:46 AM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
If you let me know when you modify it, I’ll be happy to
try the implementation.
From: Rockford Lhotka
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 8:31 AM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
The data portal only invokes the root object. It is your
responsibility to create a mock-up of the object graph as you wish.
I should point out that I’m not real happy with the method
signature right now, as it returns a value. I think it should be a static void
method like the other data portal methods, and that’ll probably change in
3.6.2.
Rocky
From: Jack Addington
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 9:20 AM
To: rocky@lhotka.net
Subject: RE: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
You guys never cease to impress me – I’ll give that
a whirl today.
How does it work with filtering down to child objects?
Do I need to call the children myself of will that happen if I
just create 5 new child objects and add them to a list?
Or can I put the DesignTime_Create in my listBO and add them
there?
Ie) ParentBO /w ChildListBO
From: RockfordLhotka
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 7:57 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
We enable design time data generation in both WPF and Silverlight. The model
is the same either way - you implement a DesignTime_Create() method in your
business class that generates this data.
The data portal detects that it is running in design time and invokes that
method instead of doing normal data portal processing.
Silverlight does require a public constructor on all business
objects.
Also, Silverlight requires that the DesignTime_Create() method
be public.
Finally, to my knowledge, Visual Studio doesn’t invoke the
data binding infrastructure when working with a Silverlight form in the
designer. Blend does though. So in VS you’ll only get design time data
for WPF forms, not Silverlight. But in Blend you should get design time data in
both environments.
Rocky
<UserControl.Resources>
<csla:CslaDataProvider x:Key="ObjectInfoListDataProvider"
ManageObjectLifetime="True"
IsInitialLoadEnabled="False"
ObjectType="Epm.Library.ProgramObject.ObjectInfoList, Epm.Library"
FactoryMethod="GetObjectInfoList" />
</UserControl.Resources>
<Border BorderThickness="1,1,1,1"
CornerRadius="10,10,10,10"
Padding="2"
BorderBrush="AliceBlue">
<Grid x:Name="LayoutRoot"
DataContext="{Binding Source={StaticResource ObjectInfoListDataProvider}, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
<ListBox x:Name="ObjectList" ItemsSource="{Binding Mode=OneWay}" VerticalAlignment="Stretch" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
<TextBlock Text="{Binding Mode=OneWay, Path=CalcObjectName}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding Mode=OneWay, Path=CalcSourceName}" Foreground="#FFBF2D2D" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="20"/>
<TextBlock Text="{Binding Mode=OneWay, Path=CalcObjectSortedName}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding Mode=OneWay, Path=ObjectType}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding Mode=OneWay, Path=ObjectStatus}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding Mode=OneWay, Path=LastRefreshDateString}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding Mode=OneWay, Path=NextScheduledPeriodText}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding Mode=OneWay, Path=CalcObjectName}" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
</UserControl>
Silverlight design time data only works in Blend from what I can
tell. It doesn’t appear that the VS designer creates instances of
Silverlight resources, and so there’s nothing to trigger the creation of
any design time data.
Not that I’m ruling out there being a bug in how CslaDataProvider
does this – the whole thing is largely guesswork on our part, because
there is no formal concept of design time data for XAML at all – we’re
literally making this stuff up as we go until Microsoft formalizes the concept
(hopefully in VS 2010 and Blend 3).
In other words, we noticed that the Blend designer actually
creates instances of types defined as resources. We used this knowledge to
trigger creation of design time data.
And the WPF designer in VS does the same thing.
But it doesn’t appear (from my testing) that the
Silverlight designer in VS creates instances of the objects. And if VS doesn’t
create an instance, then there’s really nothing CSLA can do –
because I’m surely not going to write my own designer :)
Rocky
.NET can only load an assembly into an appdomain once –
and there’s no way to unload an assembly. It may be that Blend is loading
the DLL and then it is stuck in memory even if a newer version comes along.
Microsoft really needs to get a more comprehensive story in
place around this. But then the whole designer issue needs major improvement –
I’m hoping for VS 10 and B3 to address a lot of these things.
Rocky
From: Jack
[mailto:cslanet@lhotka.net]
Sent: Friday, April 24, 2009 4:46 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: CLSADataProvider in Silverlight -
Design Time Data
It is in blend that I am *trying* to get some data to
see. I have noticed with playing with the WPF example that I have to
open/close Blend to pick up changes to the underlying BO. If I make
certain changes then the DesignTime data just disappears until I reload Blend.
Rocky,
I'm trying to emulate this example: http://www.silverlightshow.net/items/First-Look-at-Using-Expression-Blend-with-Silverlight-2.aspx
I can get to the part where I create a object (ROLB) in the Data
tray but if I try to then drag it over to create/bind to a list then I get an
exception. If I create/bind to a grid then I get no error (you binding as
dataContext) but if I choose list and bind to ItemsSource I get an
exception. It tells me that it "Cannot find type Csla.Wpf.PropertyStatus
... The assembly used when compiling might be different than that used when
loading and the type is missing..."
Any thoughts?
Thanks
jack
From: Rockford Lhotka [mailto:cslanet@lhotka.net]
Sent: April-24-09 4:09 PM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] RE: RE: CLSADataProvider in Silverlight -
Design Time Data
.NET can only load an assembly into an appdomain once –
and there’s no way to unload an assembly. It may be that Blend is loading
the DLL and then it is stuck in memory even if a newer version comes along.
Microsoft really needs to get a more comprehensive story in
place around this. But then the whole designer issue needs major improvement
– I’m hoping for VS 10 and B3 to address a lot of these things.
Rocky
From: Jack [mailto:cslanet@lhotka.net]
Sent: Friday, April 24, 2009 4:46 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: CLSADataProvider in Silverlight -
Design Time Data
It is in blend
that I am *trying* to get some data to see. I have noticed with playing
with the WPF example that I have to open/close Blend to pick up changes to the
underlying BO. If I make certain changes then the DesignTime data just
disappears until I reload Blend.
To get full designer support in Blend it is my understanding
that you must put Csla.dll into the GAC. This is because, as I mentioned in a
previous post, a DLL can be loaded into an appdomain only once – but it
actually goes beyond that. If a DLL is loaded into two appdomains, it is
treated as a different DLL in each appdomain, with the exception of the
DLL being loaded from the GAC.
This is a limitation of .NET, and the way Blend uses different
appdomains to load/unload assemblies in the designer.
So in short, install Csla.dll into the GAC and that should help.
Rocky
I don't have expression blend nor am I working with a designer so this reply may not be helpful to you....
I have been working with CSLALight for about a month and the productivity tip below outweighs any benefit of design time data (at the moment).
http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx
Yeah, that is really amazing – I echo-blogged it when the
post came out – totally revolutionizes my view on working with XAML in VS.
Rocky
From: davido_xml
[mailto:cslanet@lhotka.net]
Sent: Friday, February 13, 2009 10:34 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] CLSADataProvider in Silverlight - Design Time
Data
I don't have expression blend nor am I working with a designer so this reply
may not be helpful to you....
I have been working with CSLALight for about a month and the
productivity tip below outweighs any benefit of design time data (at the
moment).
http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx
Copyright (c) Marimer LLC