<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">
  <channel>
    <title>Rockford Lhotka - Silverlight</title>
    <link>http://www.lhotka.net/weblog/</link>
    <description>Creator of the CSLA .NET framework</description>
    <language>en-us</language>
    <copyright>Marimer LLC</copyright>
    <lastBuildDate>Fri, 07 Dec 2012 17:23:33 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>rocky@lhotka.net</managingEditor>
    <webMaster>rocky@lhotka.net</webMaster>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=899d1465-56d6-4cc6-9de5-6eb98d97722c</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,899d1465-56d6-4cc6-9de5-6eb98d97722c.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,899d1465-56d6-4cc6-9de5-6eb98d97722c.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=899d1465-56d6-4cc6-9de5-6eb98d97722c</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The Silverlight.net web site is apparently now gone, merged into the broader msdn.com
ecosystem (where it belonged in the first place imo):
</p>
        <p>
          <a title="http://www.zdnet.com/microsoft-pulls-the-plug-on-its-silverlight-net-site-7000008494/" href="http://www.zdnet.com/microsoft-pulls-the-plug-on-its-silverlight-net-site-7000008494/">http://www.zdnet.com/microsoft-pulls-the-plug-on-its-silverlight-net-site-7000008494/</a>
        </p>
        <p>
As we’ve known now for a long time, Silverlight is “dead”. It is in support mode and
will be for a decade.
</p>
        <p>
Just like Windows Forms has been since 2005, and WPF is now as well (do you really
think Microsoft is going to divert money from WinRT to do <em>anything</em> with WPF
at this point??? If so I’ve got this beachfront property for sale…).
</p>
        <blockquote>
          <p>
            <em>As an aside, ASP.NET Web Forms also “died” in 2005, but recently got a major infusion
of money in .NET 4.5 – showing that even a “dead” technology can receive a big cash
investment sometimes – though it still isn’t clear that this will be enough to breath
any new life into Web Forms for most organizations. I suspect it is more likely that
this recent investment will just allow organizations with massive Web Forms sites
to keep them limping along for another 5-10 years.</em>
          </p>
        </blockquote>
        <p>
If a technology is defined as “dead” when its vendor stops enhancing it and starts
maintaining it while they put most of their money into the future, then I must say
that I’ve spent pretty much my entire ~25 year career working on dead technologies.
And it has been fun! <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Smile" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Silverlight-is-dead_9AEB/wlEmoticon-smile_2.png" /></p>
        <p>
Although some of us tech geeks like to jump to the next <em>potential</em> upcoming
thing, the people who actually fund software projects rarely want to accept that kind
of risk. They generally <em>prefer</em> to build applications on stable technology.
Most stable technology is “dead” or “dying” based on this idea of “live” technology
being rapidly changing and evolving.
</p>
        <p>
Obviously there’s a fine line here. 
</p>
        <p>
Target stable technology that is too old and you really are in trouble. Windows Forms
is an example of this, because its underlying technology has no migration path to
a WinRT future. Although a <em>lot</em> of organizations have massive investments
in Windows Forms, I would hope that they’d shy away from starting new development
on this extremely stable, but now too old, technology.
</p>
        <p>
Target stable technology that is new, but old enough to be stable and life is generally
pretty good. WPF and Silverlight (for smart clients, not for cross-platform RIA) are
examples of this. The reason is that these technologies (especially Silverlight) have
a good migration story to a WinRT future. A lot of organizations are investing in
WPF, and that’s good. But I’d be shocked if Microsoft invests anything in WPF going
forward – its future is the one Windows Forms has enjoyed since 2005 – stable maintenance
of the technology. <em>Perfect</em> for building critical business apps. Organizations
also have large investments in Silverlight, and as long as the intent was smart client
development (not cross-platform RIA) it seems to me that they are in the exact same
place as everyone using WPF. Arguably better, because Silverlight is much closer to
WinRT than WPF.
</p>
        <p>
          <a title="http://magenic.com/Portfolio/WhitePaperWindows8DevelopmentPlatform.aspx" href="http://magenic.com/Portfolio/WhitePaperWindows8DevelopmentPlatform.aspx">http://magenic.com/Portfolio/WhitePaperWindows8DevelopmentPlatform.aspx</a>
        </p>
        <p>
If you are using Silverlight for cross-platform rich web development, then I do agree
that the news is not good. The current alternative appears to be HTML 5, though it
is also clear that this is an expensive alternative with an unsure future. Just like
every other silver bullet to write once and run anywhere, I think you have to go into
such a venture expecting a lot of cost and pain. There’s no widely successful example
in the history of computing that indicates otherwise…
</p>
        <p>
The final option is to target “live” technologies. You know, the ones where vendors <em>are</em> dumping
huge amounts of money, and where the technology and platform are changing rapidly.
Things like HTML 5 and WinRT are examples of this. As a tech geek I <em>love</em> it
when organizations want to do this sort of thing, because the challenge is high and
we all get to learn a lot of new stuff. Of course the development costs are also quite
high because we’re getting paid to learn this new stuff. And the overall costs for
the software are high because the technology/platform isn’t stable and the app probably
needs to be rewritten (in whole or part) every few months to deal with platform changes.
</p>
        <p>
Some organizations are willing to accept the costs and inconvenience associated with
using “live” technologies. But most organizations don’t have the time or money or
risk tolerance, and are far better off targeting “dead” technologies like WPF and
Silverlight. They just need to be careful to have strategic migration plans so they
can get off those technologies before they reach the point of where Windows Forms
is today.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=899d1465-56d6-4cc6-9de5-6eb98d97722c" />
      </body>
      <title>Silverlight is &amp;ldquo;dead&amp;rdquo;</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,899d1465-56d6-4cc6-9de5-6eb98d97722c.aspx</guid>
      <link>http://www.lhotka.net/weblog/SilverlightIsLdquodeadrdquo.aspx</link>
      <pubDate>Fri, 07 Dec 2012 17:23:33 GMT</pubDate>
      <description>&lt;p&gt;
The Silverlight.net web site is apparently now gone, merged into the broader msdn.com
ecosystem (where it belonged in the first place imo):
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.zdnet.com/microsoft-pulls-the-plug-on-its-silverlight-net-site-7000008494/" href="http://www.zdnet.com/microsoft-pulls-the-plug-on-its-silverlight-net-site-7000008494/"&gt;http://www.zdnet.com/microsoft-pulls-the-plug-on-its-silverlight-net-site-7000008494/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
As we’ve known now for a long time, Silverlight is “dead”. It is in support mode and
will be for a decade.
&lt;/p&gt;
&lt;p&gt;
Just like Windows Forms has been since 2005, and WPF is now as well (do you really
think Microsoft is going to divert money from WinRT to do &lt;em&gt;anything&lt;/em&gt; with WPF
at this point??? If so I’ve got this beachfront property for sale…).
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;em&gt;As an aside, ASP.NET Web Forms also “died” in 2005, but recently got a major infusion
of money in .NET 4.5 – showing that even a “dead” technology can receive a big cash
investment sometimes – though it still isn’t clear that this will be enough to breath
any new life into Web Forms for most organizations. I suspect it is more likely that
this recent investment will just allow organizations with massive Web Forms sites
to keep them limping along for another 5-10 years.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
If a technology is defined as “dead” when its vendor stops enhancing it and starts
maintaining it while they put most of their money into the future, then I must say
that I’ve spent pretty much my entire ~25 year career working on dead technologies.
And it has been fun! &lt;img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Smile" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Silverlight-is-dead_9AEB/wlEmoticon-smile_2.png" /&gt;
&lt;/p&gt;
&lt;p&gt;
Although some of us tech geeks like to jump to the next &lt;em&gt;potential&lt;/em&gt; upcoming
thing, the people who actually fund software projects rarely want to accept that kind
of risk. They generally &lt;em&gt;prefer&lt;/em&gt; to build applications on stable technology.
Most stable technology is “dead” or “dying” based on this idea of “live” technology
being rapidly changing and evolving.
&lt;/p&gt;
&lt;p&gt;
Obviously there’s a fine line here. 
&lt;/p&gt;
&lt;p&gt;
Target stable technology that is too old and you really are in trouble. Windows Forms
is an example of this, because its underlying technology has no migration path to
a WinRT future. Although a &lt;em&gt;lot&lt;/em&gt; of organizations have massive investments
in Windows Forms, I would hope that they’d shy away from starting new development
on this extremely stable, but now too old, technology.
&lt;/p&gt;
&lt;p&gt;
Target stable technology that is new, but old enough to be stable and life is generally
pretty good. WPF and Silverlight (for smart clients, not for cross-platform RIA) are
examples of this. The reason is that these technologies (especially Silverlight) have
a good migration story to a WinRT future. A lot of organizations are investing in
WPF, and that’s good. But I’d be shocked if Microsoft invests anything in WPF going
forward – its future is the one Windows Forms has enjoyed since 2005 – stable maintenance
of the technology. &lt;em&gt;Perfect&lt;/em&gt; for building critical business apps. Organizations
also have large investments in Silverlight, and as long as the intent was smart client
development (not cross-platform RIA) it seems to me that they are in the exact same
place as everyone using WPF. Arguably better, because Silverlight is much closer to
WinRT than WPF.
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://magenic.com/Portfolio/WhitePaperWindows8DevelopmentPlatform.aspx" href="http://magenic.com/Portfolio/WhitePaperWindows8DevelopmentPlatform.aspx"&gt;http://magenic.com/Portfolio/WhitePaperWindows8DevelopmentPlatform.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
If you are using Silverlight for cross-platform rich web development, then I do agree
that the news is not good. The current alternative appears to be HTML 5, though it
is also clear that this is an expensive alternative with an unsure future. Just like
every other silver bullet to write once and run anywhere, I think you have to go into
such a venture expecting a lot of cost and pain. There’s no widely successful example
in the history of computing that indicates otherwise…
&lt;/p&gt;
&lt;p&gt;
The final option is to target “live” technologies. You know, the ones where vendors &lt;em&gt;are&lt;/em&gt; dumping
huge amounts of money, and where the technology and platform are changing rapidly.
Things like HTML 5 and WinRT are examples of this. As a tech geek I &lt;em&gt;love&lt;/em&gt; it
when organizations want to do this sort of thing, because the challenge is high and
we all get to learn a lot of new stuff. Of course the development costs are also quite
high because we’re getting paid to learn this new stuff. And the overall costs for
the software are high because the technology/platform isn’t stable and the app probably
needs to be rewritten (in whole or part) every few months to deal with platform changes.
&lt;/p&gt;
&lt;p&gt;
Some organizations are willing to accept the costs and inconvenience associated with
using “live” technologies. But most organizations don’t have the time or money or
risk tolerance, and are far better off targeting “dead” technologies like WPF and
Silverlight. They just need to be careful to have strategic migration plans so they
can get off those technologies before they reach the point of where Windows Forms
is today.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=899d1465-56d6-4cc6-9de5-6eb98d97722c" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,899d1465-56d6-4cc6-9de5-6eb98d97722c.aspx</comments>
      <category>Silverlight</category>
      <category>Windows Forms</category>
      <category>WinRT</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=0f6164fa-537a-49ed-8902-a4909ba52b6c</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,0f6164fa-537a-49ed-8902-a4909ba52b6c.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,0f6164fa-537a-49ed-8902-a4909ba52b6c.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0f6164fa-537a-49ed-8902-a4909ba52b6c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
CSLA 4 version 4.5 supports the async and await keywords across all platforms (WinRT,
.NET 4.5, .NET 4, Silverlight 5).
</p>
        <p>
You can use these async features to implement async rules in the CSLA rules engine.
Here’s one such rule:
</p>
        <blockquote>
          <p>
public class CustomRule : Csla.Rules.BusinessRule 
<br />
{ 
<br />
  public CustomRule(Csla.Core.IPropertyInfo primaryProperty) 
<br />
    : base(primaryProperty) 
<br />
  { 
<br />
    InputProperties.Add(primaryProperty); 
<br />
    IsAsync = true; 
<br />
  }
</p>
          <p>
  protected async override void Execute(Csla.Rules.RuleContext context) 
<br />
  { 
<br />
    var cmd = new LongRunningCommand(); 
<br />
    cmd = await DataPortal.ExecuteAsync(cmd); 
<br />
    context.AddInformationResult("Rule complete: " + cmd.Output); 
<br />
    context.Complete(); 
<br />
  }
</p>
          <p>
  [Serializable] 
<br />
  public class LongRunningCommand : CommandBase&lt;LongRunningCommand&gt; 
<br />
  { 
<br />
    public static readonly PropertyInfo&lt;string&gt; OutputProperty
= RegisterProperty&lt;string&gt;(c =&gt; c.Output); 
<br />
    public string Output 
<br />
    { 
<br />
      get { return ReadProperty(OutputProperty); } 
<br />
      private set { LoadProperty(OutputProperty, value);
} 
<br />
    }
</p>
          <p>
    protected new async Task DataPortal_Execute() 
<br />
    { 
<br />
      Output = "Before delay"; 
<br />
      await Task.Delay(3000); 
<br />
      Output = "After delay"; 
<br />
    } 
<br />
  } 
<br />
} 
<br /></p>
        </blockquote>
        <p>
Notice that the rule’s constructor sets the rule’s IsAsync property to true. This
tells the CSLA rules engine that the rule will be async.
</p>
        <p>
Also notice that the rule’s Execute method is marked with the async keyword, allowing
the use of the await keyword within the method. In this example, the rule uses the
data portal to asynchronously execute a command object by awaiting the ExecuteAsync
method.
</p>
        <p>
Because the rule has IsAsync true, the Execute method <em>must</em> call context.Complete
to indicate that the rule has finished processing. If you don’t call context.Complete
the CSLA rule engine will never process the rule’s result, and you’ll have a bug in
your application.
</p>
        <p>
The command object itself also uses the async keyword to implement the DataPortal_Execute
method. Notice that this method returns a Task. The server-side data portal components
are smart enough to detect when a DataPortal_XYZ method returns type Task, so the
DataPortal_XYZ method is invoked correctly.
</p>
        <p>
Within the DataPortal_Execute method I just use Task.Delay to create an artificial
delay. This represents some long-running operation such as calling a slow web service,
invoking an intensive oData query, or something like that.
</p>
        <p>
The end result is that a business object can attach this CustomRule to a property,
and the rule will run asynchronously. This is done in the business class’s AddBusinessRules
method.
</p>
        <p>
In your UI you can use helper components such as Csla.Xaml.PropertyInfo to determine
that the property is running an async rule. For example, you might use XAML like this
in WinRT:
</p>
        <blockquote>
          <p>
&lt;StackPanel Orientation="Horizontal"&gt; 
<br />
  &lt;TextBox Text="{Binding Path=Name, Mode=TwoWay}"/&gt; 
<br />
  &lt;TextBlock Text="{Binding ElementName=NameInfo,Path=RuleDescription}"
Foreground="Yellow"/&gt; 
<br />
  &lt;ProgressRing IsActive="{Binding ElementName=NameInfo,Path=IsBusy}"/&gt; 
<br />
  &lt;csla:PropertyInfo Name="NameInfo" Source="{Binding}"
Property="Name"/&gt; 
<br />
&lt;/StackPanel&gt;
</p>
        </blockquote>
        <p>
The specific XAML syntax is a little different in WPF/Silverlight because the XAML
language is more mature there than in WinRT. But the basic concept of building a rich
user experience based on an async rule is the same across all smart client platforms.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=0f6164fa-537a-49ed-8902-a4909ba52b6c" />
      </body>
      <title>Implementing an async rule in CSLA 4 version 4.5</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,0f6164fa-537a-49ed-8902-a4909ba52b6c.aspx</guid>
      <link>http://www.lhotka.net/weblog/ImplementingAnAsyncRuleInCSLA4Version45.aspx</link>
      <pubDate>Tue, 09 Oct 2012 21:59:52 GMT</pubDate>
      <description>&lt;p&gt;
CSLA 4 version 4.5 supports the async and await keywords across all platforms (WinRT,
.NET 4.5, .NET 4, Silverlight 5).
&lt;/p&gt;
&lt;p&gt;
You can use these async features to implement async rules in the CSLA rules engine.
Here’s one such rule:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public class CustomRule : Csla.Rules.BusinessRule 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; public CustomRule(Csla.Core.IPropertyInfo primaryProperty) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; : base(primaryProperty) 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; InputProperties.Add(primaryProperty); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; IsAsync = true; 
&lt;br /&gt;
&amp;#160; }
&lt;/p&gt;
&lt;p&gt;
&amp;#160; protected async override void Execute(Csla.Rules.RuleContext context) 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var cmd = new LongRunningCommand(); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; cmd = await DataPortal.ExecuteAsync(cmd); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; context.AddInformationResult(&amp;quot;Rule complete: &amp;quot; + cmd.Output); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; context.Complete(); 
&lt;br /&gt;
&amp;#160; }
&lt;/p&gt;
&lt;p&gt;
&amp;#160; [Serializable] 
&lt;br /&gt;
&amp;#160; public class LongRunningCommand : CommandBase&amp;lt;LongRunningCommand&amp;gt; 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; public static readonly PropertyInfo&amp;lt;string&amp;gt; OutputProperty
= RegisterProperty&amp;lt;string&amp;gt;(c =&amp;gt; c.Output); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; public string Output 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return ReadProperty(OutputProperty); } 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private set { LoadProperty(OutputProperty, value);
} 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; }
&lt;/p&gt;
&lt;p&gt;
&amp;#160;&amp;#160;&amp;#160; protected new async Task DataPortal_Execute() 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Output = &amp;quot;Before delay&amp;quot;; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; await Task.Delay(3000); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Output = &amp;quot;After delay&amp;quot;; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; } 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
} 
&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Notice that the rule’s constructor sets the rule’s IsAsync property to true. This
tells the CSLA rules engine that the rule will be async.
&lt;/p&gt;
&lt;p&gt;
Also notice that the rule’s Execute method is marked with the async keyword, allowing
the use of the await keyword within the method. In this example, the rule uses the
data portal to asynchronously execute a command object by awaiting the ExecuteAsync
method.
&lt;/p&gt;
&lt;p&gt;
Because the rule has IsAsync true, the Execute method &lt;em&gt;must&lt;/em&gt; call context.Complete
to indicate that the rule has finished processing. If you don’t call context.Complete
the CSLA rule engine will never process the rule’s result, and you’ll have a bug in
your application.
&lt;/p&gt;
&lt;p&gt;
The command object itself also uses the async keyword to implement the DataPortal_Execute
method. Notice that this method returns a Task. The server-side data portal components
are smart enough to detect when a DataPortal_XYZ method returns type Task, so the
DataPortal_XYZ method is invoked correctly.
&lt;/p&gt;
&lt;p&gt;
Within the DataPortal_Execute method I just use Task.Delay to create an artificial
delay. This represents some long-running operation such as calling a slow web service,
invoking an intensive oData query, or something like that.
&lt;/p&gt;
&lt;p&gt;
The end result is that a business object can attach this CustomRule to a property,
and the rule will run asynchronously. This is done in the business class’s AddBusinessRules
method.
&lt;/p&gt;
&lt;p&gt;
In your UI you can use helper components such as Csla.Xaml.PropertyInfo to determine
that the property is running an async rule. For example, you might use XAML like this
in WinRT:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;StackPanel Orientation=&amp;quot;Horizontal&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;TextBox Text=&amp;quot;{Binding Path=Name, Mode=TwoWay}&amp;quot;/&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;TextBlock Text=&amp;quot;{Binding ElementName=NameInfo,Path=RuleDescription}&amp;quot;
Foreground=&amp;quot;Yellow&amp;quot;/&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;ProgressRing IsActive=&amp;quot;{Binding ElementName=NameInfo,Path=IsBusy}&amp;quot;/&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;csla:PropertyInfo Name=&amp;quot;NameInfo&amp;quot; Source=&amp;quot;{Binding}&amp;quot;
Property=&amp;quot;Name&amp;quot;/&amp;gt; 
&lt;br /&gt;
&amp;lt;/StackPanel&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The specific XAML syntax is a little different in WPF/Silverlight because the XAML
language is more mature there than in WinRT. But the basic concept of building a rich
user experience based on an async rule is the same across all smart client platforms.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=0f6164fa-537a-49ed-8902-a4909ba52b6c" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,0f6164fa-537a-49ed-8902-a4909ba52b6c.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WinRT</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=1cfed469-df70-4f07-918f-3270372dbf81</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,1cfed469-df70-4f07-918f-3270372dbf81.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,1cfed469-df70-4f07-918f-3270372dbf81.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=1cfed469-df70-4f07-918f-3270372dbf81</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I want to summarize some of the more major changes coming to the data portal in CSLA
4 version 4.5. Some of these are breaking changes.
</p>
        <p>
I’ve done four big things with the data portal:
</p>
        <ol>
          <li>
Added support for the new async/await keywords on the client and server</li>
          <li>
Merged the .NET and Silverlight data portal implementations into a single code base
that is now common across WinRT, .NET, and Silverlight</li>
          <li>
Removed the public virtual DataPortal_XYZ method definitions from Silverlight, because
it can now invoke non-public methods just like in .NET. Also, all local Silverlight
data portal methods no longer accept the async callback handler, because they now
support the async/await pattern</li>
          <li>
Remove the ProxyMode concept from the Silverlight data portal, because the RunLocal
attribute is now available on all platforms</li>
        </ol>
        <p>
All four have some level of breaking change.
</p>
        <p>
Adding comprehensive support for async/await changes the way .NET handles exceptions.
Although I’ve worked to keep the <em>top level</em> exceptions consistent, the actual
exception object graph (nested InnerExceptions) will almost certainly be different
now.
</p>
        <p>
Merging the .NET and Silverlight data portal implementations introduces a number of
relatively minor breaking changes for Silverlight users. Though if you’ve created
custom proxy/host pairs or other more advanced scenarios you might be more affected
than others. There may also be unintended side-effects to .NET users. Some might be
bugs, others might be necessary to achieve platform unification.
</p>
        <p>
Removing the public virtual DataPortal_XYZ methods from BusinessBase and BusinessListBase
will break anyone using the local Silverlight data portal. The fix is minor – just
change the public scopes to protected. This change shouldn’t affect anyone using .NET,
or using a remote data portal from Silverlight.
</p>
        <p>
Removing the async callback parameter from all Silverlight client-side DataPortal_XYZ
methods will break anyone using the local Silverlight data portal. The fix is to switch
to the new async/await pattern. The code changes are relatively minor, and generally
simplify your code, but if you’ve made extensive use of the client-side data portal
in Silverlight this will be a pretty big change I’m afraid.
</p>
        <p>
Similarly, removing the ProxyMode concept from the Silverlight data portal is a breaking
change for people using the local Silverlight data portal. Again, the fix is pretty
simple – just add the RunLocal attribute to the DataPortal_XYZ (or object factory)
methods as you have always done in .NET.
</p>
        <p>
On the upside, the coding patterns for writing code in .NET, WinRT, and Silverlight
are now the same.
</p>
        <p>
For example, a DataPortal_Fetch method <em>on any platform</em> looks like this:
</p>
        <blockquote>
          <p>
private void DataPortal_Fetch(int id)
</p>
        </blockquote>
        <p>
or like this
</p>
        <blockquote>
          <p>
private async Task DataPortal_Fetch(int id)
</p>
        </blockquote>
        <p>
The data portal will automatically detect if your method returns a Task and it will
await the method, allowing you to use the await keyword inside your DataPortal_XYZ
methods.
</p>
        <p>
Similarly, all platforms can now write this client-side code:
</p>
        <blockquote>
          <p>
var obj = await CustomerEdit.GetCustomerAsync(123);
</p>
        </blockquote>
        <p>
or the older event-style code:
</p>
        <blockquote>
          <p>
CustomerEdit.GetCustomer(123, (o, e) =&gt; 
<br />
  { 
<br />
      if (e.Error != null) 
<br />
          throw e.Error; 
<br />
     else 
<br />
          obj = e.Object; 
<br />
  });
</p>
        </blockquote>
        <p>
Only .NET code can use the synchronous approach:
</p>
        <blockquote>
          <p>
var obj = CustomerEdit.GetCustomer(123);
</p>
        </blockquote>
        <p>
This is one of the few platform-specific concepts left in the data portal.
</p>
        <p>
What is really cool is that the client and server sync/async concepts can be mixed
(as long as you know what to expect).
</p>
        <table border="0" cellspacing="0" cellpadding="2" width="877">
          <tbody>
            <tr>
              <td valign="top" width="79">
Client method</td>
              <td valign="top" width="77">
Client platform</td>
              <td valign="top" width="141">
Server method</td>
              <td valign="top" width="10">
Server platform</td>
              <td valign="top" width="571">
Remarks</td>
            </tr>
            <tr>
              <td valign="top" width="83">
Fetch</td>
              <td valign="top" width="81">
.NET only</td>
              <td valign="top" width="141">
void DataPortal_Fetch</td>
              <td valign="top" width="10">
any</td>
              <td valign="top" width="571">
Client call is synchronous; server call is synchronous</td>
            </tr>
            <tr>
              <td valign="top" width="83">
Fetch</td>
              <td valign="top" width="81">
.NET only</td>
              <td valign="top" width="141">
Task DataPortal_Fetch</td>
              <td valign="top" width="10">
any</td>
              <td valign="top" width="571">
Client call is synchronous; server call is asynchronous; note that client will block
until the server’s work is complete</td>
            </tr>
            <tr>
              <td valign="top" width="83">
BeginFetch</td>
              <td valign="top" width="81">
any</td>
              <td valign="top" width="141">
void DataPortal_Fetch</td>
              <td valign="top" width="10">
any</td>
              <td valign="top" width="571">
Client call is asynchronous (event-based); server call is synchronous; client will
not block, and must handle the callback event to be notified when the server call
is complete</td>
            </tr>
            <tr>
              <td valign="top" width="83">
BeginFetch</td>
              <td valign="top" width="81">
any</td>
              <td valign="top" width="141">
Task DataPortal_Fetch</td>
              <td valign="top" width="10">
any</td>
              <td valign="top" width="571">
Client call is asynchronous (event-based); server call is asynchronous; client will
not block, and must handle the callback event to be notified when the server call
is complete</td>
            </tr>
            <tr>
              <td valign="top" width="83">
FetchAsync</td>
              <td valign="top" width="81">
any</td>
              <td valign="top" width="141">
void DataPortal_Fetch</td>
              <td valign="top" width="10">
any</td>
              <td valign="top" width="571">
Client call is asynchronous; server call is synchronous; client will block or not,
depending on how you invoke the client-side Task (using await or other techniques);
the client-side Task will complete when the server call is complete</td>
            </tr>
            <tr>
              <td valign="top" width="83">
FetchAsync</td>
              <td valign="top" width="81">
any</td>
              <td valign="top" width="141">
Task DataPortal_Fetch</td>
              <td valign="top" width="10">
any</td>
              <td valign="top" width="571">
Client call is asynchronous; server call is asynchronous; client will block or not,
depending on how you invoke the client-side Task (using await or other techniques);
the client-side Task will complete when the server call is complete</td>
            </tr>
          </tbody>
        </table>
        <p>
I expect all client-side data portal code to switch to the async/await versions of
the methods, and so I’ve made them the mainline path through the data portal. The
synchronous and event-based async methods use async/await techniques behind the scenes
to do implement the desired behaviors.
</p>
        <p>
There is a lot of variety in how you can invoke an awaitable method like FetchAsync.
The specific async behaviors you should expect will vary depending on how you invoke
the method. For example, there’s a big difference between using the await keyword
or the Result or RunSynchronously methods:
</p>
        <blockquote>
          <p>
var obj = await CustomerEdit.GetCustomerAsync(123);
</p>
          <p>
var obj = CustomerEdit.GetCustomerAsync(123).Result;
</p>
        </blockquote>
        <p>
The former is async, the latter is sync. The former will return a simple exception
(if one occurs), the latter will return an AggregateException containing the simple
exception. This has little to do with CSLA, and nearly everything to do with the way
the async/await and task parallel library (TPL) are implemented by .NET.
</p>
        <p>
Finally, I do need to state that the actual network transport (typically WCF) used
by .NET, Silverlight, and WinRT aren’t the same. This is because WCF in .NET is far
more flexible than in Silverlight or WinRT. And because the WCF client-side proxies
generated for Silverlight use event-driven async methods, and in WinRT the proxy is
task-based.
</p>
        <p>
The data portal hides these differences pretty effectively, but you should understand
that they exist, and as a result there may be subtle behavioral differences between
platforms, especially when it comes to exceptions and exception details. The success
paths for creating, fetching, updating, and deleting objects are identical, but there
may be edge cases where differences exist.
</p>
        <p>
All in all I am quite pleased with how this is turning out. I’ve put a massive amount
of work into the data portal for 4.5, especially around unifying the implementations
across platforms. I suspect there’ll be some issues to work through during the beta
testing phase, but the end result is a far more consistent, maintainable, and streamlined
codebase for all platforms. That will benefit all of us over time.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1cfed469-df70-4f07-918f-3270372dbf81" />
      </body>
      <title>CSLA data portal changes in version 4.5</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,1cfed469-df70-4f07-918f-3270372dbf81.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLADataPortalChangesInVersion45.aspx</link>
      <pubDate>Tue, 31 Jul 2012 04:53:23 GMT</pubDate>
      <description>&lt;p&gt;
I want to summarize some of the more major changes coming to the data portal in CSLA
4 version 4.5. Some of these are breaking changes.
&lt;/p&gt;
&lt;p&gt;
I’ve done four big things with the data portal:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Added support for the new async/await keywords on the client and server&lt;/li&gt;
&lt;li&gt;
Merged the .NET and Silverlight data portal implementations into a single code base
that is now common across WinRT, .NET, and Silverlight&lt;/li&gt;
&lt;li&gt;
Removed the public virtual DataPortal_XYZ method definitions from Silverlight, because
it can now invoke non-public methods just like in .NET. Also, all local Silverlight
data portal methods no longer accept the async callback handler, because they now
support the async/await pattern&lt;/li&gt;
&lt;li&gt;
Remove the ProxyMode concept from the Silverlight data portal, because the RunLocal
attribute is now available on all platforms&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
All four have some level of breaking change.
&lt;/p&gt;
&lt;p&gt;
Adding comprehensive support for async/await changes the way .NET handles exceptions.
Although I’ve worked to keep the &lt;em&gt;top level&lt;/em&gt; exceptions consistent, the actual
exception object graph (nested InnerExceptions) will almost certainly be different
now.
&lt;/p&gt;
&lt;p&gt;
Merging the .NET and Silverlight data portal implementations introduces a number of
relatively minor breaking changes for Silverlight users. Though if you’ve created
custom proxy/host pairs or other more advanced scenarios you might be more affected
than others. There may also be unintended side-effects to .NET users. Some might be
bugs, others might be necessary to achieve platform unification.
&lt;/p&gt;
&lt;p&gt;
Removing the public virtual DataPortal_XYZ methods from BusinessBase and BusinessListBase
will break anyone using the local Silverlight data portal. The fix is minor – just
change the public scopes to protected. This change shouldn’t affect anyone using .NET,
or using a remote data portal from Silverlight.
&lt;/p&gt;
&lt;p&gt;
Removing the async callback parameter from all Silverlight client-side DataPortal_XYZ
methods will break anyone using the local Silverlight data portal. The fix is to switch
to the new async/await pattern. The code changes are relatively minor, and generally
simplify your code, but if you’ve made extensive use of the client-side data portal
in Silverlight this will be a pretty big change I’m afraid.
&lt;/p&gt;
&lt;p&gt;
Similarly, removing the ProxyMode concept from the Silverlight data portal is a breaking
change for people using the local Silverlight data portal. Again, the fix is pretty
simple – just add the RunLocal attribute to the DataPortal_XYZ (or object factory)
methods as you have always done in .NET.
&lt;/p&gt;
&lt;p&gt;
On the upside, the coding patterns for writing code in .NET, WinRT, and Silverlight
are now the same.
&lt;/p&gt;
&lt;p&gt;
For example, a DataPortal_Fetch method &lt;em&gt;on any platform&lt;/em&gt; looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
private void DataPortal_Fetch(int id)
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
or like this
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
private async Task DataPortal_Fetch(int id)
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The data portal will automatically detect if your method returns a Task and it will
await the method, allowing you to use the await keyword inside your DataPortal_XYZ
methods.
&lt;/p&gt;
&lt;p&gt;
Similarly, all platforms can now write this client-side code:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
var obj = await CustomerEdit.GetCustomerAsync(123);
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
or the older event-style code:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
CustomerEdit.GetCustomer(123, (o, e) =&amp;gt; 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (e.Error != null) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw e.Error; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160; else 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; obj = e.Object; 
&lt;br /&gt;
&amp;#160; });
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Only .NET code can use the synchronous approach:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
var obj = CustomerEdit.GetCustomer(123);
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This is one of the few platform-specific concepts left in the data portal.
&lt;/p&gt;
&lt;p&gt;
What is really cool is that the client and server sync/async concepts can be mixed
(as long as you know what to expect).
&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="2" width="877"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="79"&gt;
Client method&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
Client platform&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
Server method&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
Server platform&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Remarks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="83"&gt;
Fetch&lt;/td&gt;
&lt;td valign="top" width="81"&gt;
.NET only&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
void DataPortal_Fetch&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Client call is synchronous; server call is synchronous&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="83"&gt;
Fetch&lt;/td&gt;
&lt;td valign="top" width="81"&gt;
.NET only&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
Task DataPortal_Fetch&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Client call is synchronous; server call is asynchronous; note that client will block
until the server’s work is complete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="83"&gt;
BeginFetch&lt;/td&gt;
&lt;td valign="top" width="81"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
void DataPortal_Fetch&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Client call is asynchronous (event-based); server call is synchronous; client will
not block, and must handle the callback event to be notified when the server call
is complete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="83"&gt;
BeginFetch&lt;/td&gt;
&lt;td valign="top" width="81"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
Task DataPortal_Fetch&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Client call is asynchronous (event-based); server call is asynchronous; client will
not block, and must handle the callback event to be notified when the server call
is complete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="83"&gt;
FetchAsync&lt;/td&gt;
&lt;td valign="top" width="81"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
void DataPortal_Fetch&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Client call is asynchronous; server call is synchronous; client will block or not,
depending on how you invoke the client-side Task (using await or other techniques);
the client-side Task will complete when the server call is complete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="83"&gt;
FetchAsync&lt;/td&gt;
&lt;td valign="top" width="81"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="141"&gt;
Task DataPortal_Fetch&lt;/td&gt;
&lt;td valign="top" width="10"&gt;
any&lt;/td&gt;
&lt;td valign="top" width="571"&gt;
Client call is asynchronous; server call is asynchronous; client will block or not,
depending on how you invoke the client-side Task (using await or other techniques);
the client-side Task will complete when the server call is complete&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
I expect all client-side data portal code to switch to the async/await versions of
the methods, and so I’ve made them the mainline path through the data portal. The
synchronous and event-based async methods use async/await techniques behind the scenes
to do implement the desired behaviors.
&lt;/p&gt;
&lt;p&gt;
There is a lot of variety in how you can invoke an awaitable method like FetchAsync.
The specific async behaviors you should expect will vary depending on how you invoke
the method. For example, there’s a big difference between using the await keyword
or the Result or RunSynchronously methods:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
var obj = await CustomerEdit.GetCustomerAsync(123);
&lt;/p&gt;
&lt;p&gt;
var obj = CustomerEdit.GetCustomerAsync(123).Result;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The former is async, the latter is sync. The former will return a simple exception
(if one occurs), the latter will return an AggregateException containing the simple
exception. This has little to do with CSLA, and nearly everything to do with the way
the async/await and task parallel library (TPL) are implemented by .NET.
&lt;/p&gt;
&lt;p&gt;
Finally, I do need to state that the actual network transport (typically WCF) used
by .NET, Silverlight, and WinRT aren’t the same. This is because WCF in .NET is far
more flexible than in Silverlight or WinRT. And because the WCF client-side proxies
generated for Silverlight use event-driven async methods, and in WinRT the proxy is
task-based.
&lt;/p&gt;
&lt;p&gt;
The data portal hides these differences pretty effectively, but you should understand
that they exist, and as a result there may be subtle behavioral differences between
platforms, especially when it comes to exceptions and exception details. The success
paths for creating, fetching, updating, and deleting objects are identical, but there
may be edge cases where differences exist.
&lt;/p&gt;
&lt;p&gt;
All in all I am quite pleased with how this is turning out. I’ve put a massive amount
of work into the data portal for 4.5, especially around unifying the implementations
across platforms. I suspect there’ll be some issues to work through during the beta
testing phase, but the end result is a far more consistent, maintainable, and streamlined
codebase for all platforms. That will benefit all of us over time.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1cfed469-df70-4f07-918f-3270372dbf81" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,1cfed469-df70-4f07-918f-3270372dbf81.aspx</comments>
      <category>CSLA .NET</category>
      <category>Microsoft .NET</category>
      <category>Silverlight</category>
      <category>WinRT</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=dac499ac-5234-4b64-99d6-e8cf768013ec</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,dac499ac-5234-4b64-99d6-e8cf768013ec.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,dac499ac-5234-4b64-99d6-e8cf768013ec.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=dac499ac-5234-4b64-99d6-e8cf768013ec</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am pleased to announce the release of CSLA 4 version 4.3. It is available from the <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA
download page</a> and from <a href="https://nuget.org/packages?q=CSLA">nuget</a>.
</p>
        <p>
This release adds support for Silverlight 5.
</p>
        <blockquote>
          <p>
            <em>Silverlight 4 is still supported. The assemblies are in a Silverlight4.zip file
in the bin folder created by the setup program in your Program Files folder or other
install location.</em>
          </p>
        </blockquote>
        <p>
Other major enhancements include:
</p>
        <ul>
          <li>
New binary serialization scheme for MobileFormatter resulting in <em>substantially</em> smaller
data flowing across the data portal from Silverlight and Windows Phone client applications.
The ProjectTracker sample application has been updated to use this new scheme – look
at the app server web.config and the SilverlightUI and WpUI app.xaml.cs files to see
how the client and server configuration is handled.</li>
          <li>
Numerous enhancements to the business rules subsystem. See the <a href="http://www.lhotka.net/Article.aspx?id=1c287e08-d428-4c27-b538-d588e3c55775">change
log</a> for more information.</li>
          <li>
Bug fixes to address some specific data portal issues. See the <a href="http://www.lhotka.net/Article.aspx?id=1c287e08-d428-4c27-b538-d588e3c55775">change
log</a> for more information.</li>
          <li>
CommandBase now supports managed properties.</li>
        </ul>
        <p>
With this version, CSLA 4 now supports the following platforms:
</p>
        <ul>
          <li>
Microsoft .NET 4</li>
          <ul>
            <li>
Windows Forms</li>
            <li>
ASP.NET Web Forms</li>
            <li>
ASP.NET asmx services</li>
            <li>
WPF</li>
            <li>
WCF services</li>
            <li>
ASP.NET MVC 3</li>
          </ul>
          <li>
Silverlight 5</li>
          <li>
Silverlight 4</li>
          <li>
Windows Phone 7.5</li>
          <li>
Mono</li>
          <ul>
            <li>
OS X</li>
            <li>
Linux</li>
          </ul>
          <li>
Mono for Android</li>
        </ul>
        <p>
The source code also includes a version of CSLA 4 that builds for WinRT (Windows 8)
Consumer Preview. This is largely untested, but does demonstrate that existing business
classes (especially those built for 3- and 4-tier deployments in Silverlight) can
be simply recompiled for use in WinRT applications. Consider this a preview of CSLA
4 version 4.5, coming later this year with support for .NET 4.5 and WinRT.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=dac499ac-5234-4b64-99d6-e8cf768013ec" />
      </body>
      <title>CSLA 4 version 4.3 release</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,dac499ac-5234-4b64-99d6-e8cf768013ec.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLA4Version43Release.aspx</link>
      <pubDate>Sun, 04 Mar 2012 21:29:03 GMT</pubDate>
      <description>&lt;p&gt;
I am pleased to announce the release of CSLA 4 version 4.3. It is available from the &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA
download page&lt;/a&gt; and from &lt;a href="https://nuget.org/packages?q=CSLA"&gt;nuget&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
This release adds support for Silverlight 5.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;em&gt;Silverlight 4 is still supported. The assemblies are in a Silverlight4.zip file
in the bin folder created by the setup program in your Program Files folder or other
install location.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Other major enhancements include:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
New binary serialization scheme for MobileFormatter resulting in &lt;em&gt;substantially&lt;/em&gt; smaller
data flowing across the data portal from Silverlight and Windows Phone client applications.
The ProjectTracker sample application has been updated to use this new scheme – look
at the app server web.config and the SilverlightUI and WpUI app.xaml.cs files to see
how the client and server configuration is handled.&lt;/li&gt;
&lt;li&gt;
Numerous enhancements to the business rules subsystem. See the &lt;a href="http://www.lhotka.net/Article.aspx?id=1c287e08-d428-4c27-b538-d588e3c55775"&gt;change
log&lt;/a&gt; for more information.&lt;/li&gt;
&lt;li&gt;
Bug fixes to address some specific data portal issues. See the &lt;a href="http://www.lhotka.net/Article.aspx?id=1c287e08-d428-4c27-b538-d588e3c55775"&gt;change
log&lt;/a&gt; for more information.&lt;/li&gt;
&lt;li&gt;
CommandBase now supports managed properties.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
With this version, CSLA 4 now supports the following platforms:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Microsoft .NET 4&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
Windows Forms&lt;/li&gt;
&lt;li&gt;
ASP.NET Web Forms&lt;/li&gt;
&lt;li&gt;
ASP.NET asmx services&lt;/li&gt;
&lt;li&gt;
WPF&lt;/li&gt;
&lt;li&gt;
WCF services&lt;/li&gt;
&lt;li&gt;
ASP.NET MVC 3&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Silverlight 5&lt;/li&gt;
&lt;li&gt;
Silverlight 4&lt;/li&gt;
&lt;li&gt;
Windows Phone 7.5&lt;/li&gt;
&lt;li&gt;
Mono&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
OS X&lt;/li&gt;
&lt;li&gt;
Linux&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Mono for Android&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The source code also includes a version of CSLA 4 that builds for WinRT (Windows 8)
Consumer Preview. This is largely untested, but does demonstrate that existing business
classes (especially those built for 3- and 4-tier deployments in Silverlight) can
be simply recompiled for use in WinRT applications. Consider this a preview of CSLA
4 version 4.5, coming later this year with support for .NET 4.5 and WinRT.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=dac499ac-5234-4b64-99d6-e8cf768013ec" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,dac499ac-5234-4b64-99d6-e8cf768013ec.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=a6abb40d-e6b4-426c-affc-4d465f288545</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,a6abb40d-e6b4-426c-affc-4d465f288545.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,a6abb40d-e6b4-426c-affc-4d465f288545.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=a6abb40d-e6b4-426c-affc-4d465f288545</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A beta release of CSLA 4 version 4.3 is now available from here:
</p>
        <p>
          <a href="http://www.lhotka.net/cslanet/download.aspx">www.lhotka.net/cslanet/download.aspx</a>
        </p>
        <p>
The big change in this beta release is that the Silverlight projects are now bound
to Silverlight 5.
</p>
        <p>
I plan to write a document describing how to undo the very few changes required to
support Silverlight 5, so if you want to back-port the code for Silverlight 4 you'll
be able to do so on your own. This document will be available within the next couple
weeks - before the 4.3 release.
</p>
        <p>
The <em>really</em> big change came in the previous alpha release: MobileFormatter
now allows much more efficient creation of the serialized byte stream, resulting in
much smaller amounts of data sent over the network between a Silverlight/Windows Phone
client and an app server. This same technology will be used in the WinRT codebase
as well.
</p>
        <p>
My plan is to release 4.3 on or before Feb 29. 
</p>
        <p>
That will allow us to branch 4.3 in svn so the primary codebase can focus on version
4.5 with support for .NET 4.5 and WinRT.
</p>
        <p>
The 4.3 release will go into maintenance mode - meaning we'll address bugs, but don't
plan any more feature changes.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=a6abb40d-e6b4-426c-affc-4d465f288545" />
      </body>
      <title>CSLA 4 version 4.3 beta available</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,a6abb40d-e6b4-426c-affc-4d465f288545.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLA4Version43BetaAvailable.aspx</link>
      <pubDate>Mon, 13 Feb 2012 18:45:40 GMT</pubDate>
      <description>&lt;p&gt;
A beta release of CSLA 4 version 4.3 is now available from here:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;www.lhotka.net/cslanet/download.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The big change in this beta release is that the Silverlight projects are now bound
to Silverlight 5.
&lt;/p&gt;
&lt;p&gt;
I plan to write a document describing how to undo the very few changes required to
support Silverlight 5, so if you want to back-port the code for Silverlight 4 you'll
be able to do so on your own. This document will be available within the next couple
weeks - before the 4.3 release.
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;really&lt;/em&gt; big change came in the previous alpha release: MobileFormatter
now allows much more efficient creation of the serialized byte stream, resulting in
much smaller amounts of data sent over the network between a Silverlight/Windows Phone
client and an app server. This same technology will be used in the WinRT codebase
as well.
&lt;/p&gt;
&lt;p&gt;
My plan is to release 4.3 on or before Feb 29. 
&lt;/p&gt;
&lt;p&gt;
That will allow us to branch 4.3 in svn so the primary codebase can focus on version
4.5 with support for .NET 4.5 and WinRT.
&lt;/p&gt;
&lt;p&gt;
The 4.3 release will go into maintenance mode - meaning we'll address bugs, but don't
plan any more feature changes.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=a6abb40d-e6b4-426c-affc-4d465f288545" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,a6abb40d-e6b4-426c-affc-4d465f288545.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=2209426d-e18d-42cb-af81-5ea1a8417284</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,2209426d-e18d-42cb-af81-5ea1a8417284.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,2209426d-e18d-42cb-af81-5ea1a8417284.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2209426d-e18d-42cb-af81-5ea1a8417284</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have posted an alpha version of CSLA 4 version 4.3.0 for download from the <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA
download page</a>.
</p>
        <p>
Although Jonny has been extremely busy with a number of bug fixes and some feature
changes, I think the biggest change in this alpha release is a major optimization
of the <a href="http://www.lhotka.net/weblog/CSLALightObjectSerialization.aspx">MobileFormatter</a>.
</p>
        <p>
MobileFormatter is used to serialize object graphs on Silverlight and Windows Phone.
It is used by the data portal, and n-level undo (if you use that feature).
</p>
        <p>
Until now, I have recommended that you use compression on the byte stream that flows
over the data portal, because the XML created by the MobileFormatter is often quite
large. It compresses efficiently, and we’re quite efficient about what we put into
the byte stream, but it is just plain big.
</p>
        <p>
Sergey did some really nice work for version 4.3, allowing the use of alternate reader/writer
objects so the data can be serialized into something other than XML. Specifically,
he created binary reader and writer objects that are around 70% more efficient in
terms of byte stream size. That’s about as much as you could expect to get with compression!
</p>
        <p>
The result is that you can probably avoid the CPU intensive overhead of compression
and still get a small byte stream to transfer over the network.
</p>
        <p>
The <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=1c287e08-d428-4c27-b538-d588e3c55775">CSLA
4 version 4.3.0 change log</a> includes a discussion of the configuration settings
you need to change to use the new reader/writer objects.
</p>
        <p>
This is a non-breaking change, because the default is the same behavior as in 4.2.
But this is a <em>big change</em> and we really appreciate your help in testing the
new reader/writer objects to ensure they work across a wide range of applications.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2209426d-e18d-42cb-af81-5ea1a8417284" />
      </body>
      <title>CSLA 4 version 4.3.0 alpha available</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,2209426d-e18d-42cb-af81-5ea1a8417284.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLA4Version430AlphaAvailable.aspx</link>
      <pubDate>Thu, 26 Jan 2012 19:15:02 GMT</pubDate>
      <description>&lt;p&gt;
I have posted an alpha version of CSLA 4 version 4.3.0 for download from the &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA
download page&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Although Jonny has been extremely busy with a number of bug fixes and some feature
changes, I think the biggest change in this alpha release is a major optimization
of the &lt;a href="http://www.lhotka.net/weblog/CSLALightObjectSerialization.aspx"&gt;MobileFormatter&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
MobileFormatter is used to serialize object graphs on Silverlight and Windows Phone.
It is used by the data portal, and n-level undo (if you use that feature).
&lt;/p&gt;
&lt;p&gt;
Until now, I have recommended that you use compression on the byte stream that flows
over the data portal, because the XML created by the MobileFormatter is often quite
large. It compresses efficiently, and we’re quite efficient about what we put into
the byte stream, but it is just plain big.
&lt;/p&gt;
&lt;p&gt;
Sergey did some really nice work for version 4.3, allowing the use of alternate reader/writer
objects so the data can be serialized into something other than XML. Specifically,
he created binary reader and writer objects that are around 70% more efficient in
terms of byte stream size. That’s about as much as you could expect to get with compression!
&lt;/p&gt;
&lt;p&gt;
The result is that you can probably avoid the CPU intensive overhead of compression
and still get a small byte stream to transfer over the network.
&lt;/p&gt;
&lt;p&gt;
The &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=1c287e08-d428-4c27-b538-d588e3c55775"&gt;CSLA
4 version 4.3.0 change log&lt;/a&gt; includes a discussion of the configuration settings
you need to change to use the new reader/writer objects.
&lt;/p&gt;
&lt;p&gt;
This is a non-breaking change, because the default is the same behavior as in 4.2.
But this is a &lt;em&gt;big change&lt;/em&gt; and we really appreciate your help in testing the
new reader/writer objects to ensure they work across a wide range of applications.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2209426d-e18d-42cb-af81-5ea1a8417284" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,2209426d-e18d-42cb-af81-5ea1a8417284.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WP7</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=2461dff3-e39c-4bd2-9279-12c349a04395</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,2461dff3-e39c-4bd2-9279-12c349a04395.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,2461dff3-e39c-4bd2-9279-12c349a04395.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2461dff3-e39c-4bd2-9279-12c349a04395</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the primary goals for CSLA 4 version 4.3 (the next version we’ll be creating)
is to improve the performance of the MobileFormattter that is used for Silverlight
and Windows Phone applications. This is made all the more important, because it will
also be used in WinRT applications in the future.
</p>
        <p>
Sergey (a CSLA dev team member, and Magenic colleague) has been doing some heavy research
into this area, and we’d originally thought to do the changes as part of the 4.2 release.
It turns out that doing a really great job of optimization will require some breaking
changes – at least for people who aren’t using managed backing fields. So we are deferring
the bigger changes until 4.3.
</p>
        <p>
In the meantime, Sergey has blogged about <a href="http://dotnetspeak.com/index.php/2011/11/how-to-improve-performance-of-csla-for-silverlight/">how
to improve performance of MobileFormatter</a> in 3.8 and 4 (4.0, 4.1, or 4.2). These
are changes you can make to your CSLA codebase now if you want some of the performance
benefits without waiting for the “big change” that’ll come in 4.3.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2461dff3-e39c-4bd2-9279-12c349a04395" />
      </body>
      <title>Improving CSLA 4 MobileFormatter behavior</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,2461dff3-e39c-4bd2-9279-12c349a04395.aspx</guid>
      <link>http://www.lhotka.net/weblog/ImprovingCSLA4MobileFormatterBehavior.aspx</link>
      <pubDate>Sat, 12 Nov 2011 18:41:27 GMT</pubDate>
      <description>&lt;p&gt;
One of the primary goals for CSLA 4 version 4.3 (the next version we’ll be creating)
is to improve the performance of the MobileFormattter that is used for Silverlight
and Windows Phone applications. This is made all the more important, because it will
also be used in WinRT applications in the future.
&lt;/p&gt;
&lt;p&gt;
Sergey (a CSLA dev team member, and Magenic colleague) has been doing some heavy research
into this area, and we’d originally thought to do the changes as part of the 4.2 release.
It turns out that doing a really great job of optimization will require some breaking
changes – at least for people who aren’t using managed backing fields. So we are deferring
the bigger changes until 4.3.
&lt;/p&gt;
&lt;p&gt;
In the meantime, Sergey has blogged about &lt;a href="http://dotnetspeak.com/index.php/2011/11/how-to-improve-performance-of-csla-for-silverlight/"&gt;how
to improve performance of MobileFormatter&lt;/a&gt; in 3.8 and 4 (4.0, 4.1, or 4.2). These
are changes you can make to your CSLA codebase now if you want some of the performance
benefits without waiting for the “big change” that’ll come in 4.3.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2461dff3-e39c-4bd2-9279-12c349a04395" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,2461dff3-e39c-4bd2-9279-12c349a04395.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>Windows Phone</category>
      <category>WinRT</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=12925691-3e22-41e2-9d8f-a66c115e8b8c</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,12925691-3e22-41e2-9d8f-a66c115e8b8c.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,12925691-3e22-41e2-9d8f-a66c115e8b8c.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=12925691-3e22-41e2-9d8f-a66c115e8b8c</wfw:commentRss>
      <slash:comments>22</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>Disclaimer: I know nothing. The following is (hopefully) well educated speculation
on my part. Time will tell whether I’m right.</em>
        </p>
        <p>
I really like Silverlight. I’ve been a strong proponent of <sub></sub>Silverlight
since 2007 when I rushed to port CSLA .NET to the new platform.
</p>
        <p>
In fact, Magenic provided me with a dev and test team to make that transition happen,
because we all saw the amazing potential of Silverlight.
</p>
        <p>
And it has been a good few years.
</p>
        <p>
But let’s face reality. Microsoft has invested who-knows-how-much money to build WinRT,
and no matter how you look at it, WinRT is the replacement for Win32. That means all
the stuff that runs on Win32 is “dead”. This includes Silverlight, Windows Forms,
WPF, console apps – everything.
</p>
        <p>
(this is partially in answer to <a href="http://www.zdnet.com/blog/microsoft/will-there-be-a-silverlight-6-and-does-it-matter/11180">Mary-Jo’s
article on Silverlight 5</a>)
</p>
        <p>
I wouldn’t be surprised if Silverlight 5 was the last version. I also wouldn’t be
surprised if .NET 4.5 was the last version for the Win32 client, and that future versions
of .NET were released for servers and Azure only.
</p>
        <p>
Before you panic though, remember that VB6 has been “dead” for well over a decade.
It died at the PDC in 1999, along with COM. But you still use VB6 and/or COM? Or at
least you know organizations who do? How can that be when it is dead??
</p>
        <p>
That’s my point. “dead” isn’t really dead.
</p>
        <p>
Just how long do you think people (like me and you) will continue to run Win32-based
operating systems and applications? At least 10 years, and many will probably run
15-20 years into the future. This is the rate of change that exists in the corporate
world. At least that’s been my observation for the past couple decades.
</p>
        <p>
Microsoft supports their technologies for 10 years after a final release. So even
if SL5 is the end (and they haven’t said it is), that gives us 10 years of supported
Silverlight usage. The same for the other various .NET and Win32 technologies.
</p>
        <p>
That’s plenty of time for Microsoft to get WinRT mature, and to allow us to migrate
to that platform over a period of years.
</p>
        <p>
I don’t expect WinRT 1.0 (the Windows 8 version) to be capable of replacing Win32
or .NET. I rather expect it to be pretty crippled in many respects. Much like VB 1.0
(and 2.0), .NET 1.0 and 1.1, Silverlight 1 and 2, etc.
</p>
        <p>
But Windows 9 or Windows 10 (WinRT 2.0 or 3.0) should be quite capable of replacing
Win32 and .NET and Silverlight.
</p>
        <p>
If we assume Win8 comes out in 2012, and that Microsoft does a forced march release
of 9 and 10 every two years, that means 2016 will give us WinRT 3.0. And if we hold
to the basic truism that Microsoft always gets it right on their third release, that’ll
be the one to target.
</p>
        <p>
I think it is also reasonable to expect that Win9 and Win10 will probably continue
to have the “blue side” (see my <a href="http://www.lhotka.net/weblog/UpdatedWin8DevPlatformDiagram.aspx">Windows
8 dev platform</a> post), meaning Win32, .NET, and Silverlight will continue to be
released and therefore supported over that time. They may not <em>change</em> over
that time, but they’ll be there, and they’ll be supported – or so goes my theory.
</p>
        <p>
This means that in 2016 the clock might really start for migration from Win32/.NET/Silverlight
to WinRT.
</p>
        <p>
Yes, I expect that a lot of us will build things for WinRT sooner than 2016. I certainly
hope so, because it looks like a lot of fun!
</p>
        <p>
But from a corporate perspective, where things move so slowly, this is probably good
news. Certain apps can be ported sooner, but big and important apps can move slowly
over time.
</p>
        <p>
What to do in the meantime? Between now and 2016?
</p>
        <p>
Focus on XAML, and on n-tier or SOA async server access as architectural models.
</p>
        <p>
Or focus on HTML 5 (soon to be HTML 6 fwiw, and possibly HTML 7 by 2016 for all we
know).
</p>
        <p>
I’m focusing on XAML, creating a CSLA 4 version 4.5 release that supports .NET 4.5
on servers, Azure, Windows (Win32), and Windows (WinRT). And Silverlight 5 of course.
</p>
        <p>
In fact, the plan is for a version 4.3 release to support Silverlight 5, then version
4.5 with support for .NET 4.5 and WinRT.
</p>
        <p>
I suspect that you can use Silverlight or WPF as a bridge to WinRT. The real key is
architecture.
</p>
        <ol>
          <li>
An n-tier architecture is fine, as long as the data access layer is running on a server,
and the client uses async calls to interact with the server. WinRT requires a lot
of async, at a minimum all server interactions. Silverlight forces you to adopt this
architecture already, so it is a natural fit. WPF doesn’t force the issue, but you
can choose to do “the right thing”.</li>
          <li>
You can also build your client applications to be “edge applications” – on the edge
of a service-oriented system. This is a less mature technology area, and it is more
costly. But it is also a fine architecture for environments composed of many disparate
applications that need to interact as a loosely coupled system. Again, all service
interactions by the edge applications (the ones running on the clients) must be async.</li>
          <li>
Or you can build “hybrid solutions”, where individual applications are built using
n-tier architectures (with async server calls). And where <em>some</em> of those applications
also expose service interfaces so they can participate as part of a broader service-oriented
system.</li>
        </ol>
        <p>
I favor option 3. I don’t like to accept the cost and performance ramifications of
SOA when building <em>an application</em>, so I’d prefer to use a faster and cheaper
n-tier architecture. At the same time, many applications do need to interact with
each other, and the requirement to create “application mashups” through edge applications
happens from time to time. So building my n-tier applications to have dual interfaces
(XAML and JSON for example) is a perfect compromise.
</p>
        <p>
The direct users of my application get n-tier performance and maintainability. And
the broader organization can access my slower-moving, standards-based, contractual
service interface. It is the best of both worlds.
</p>
        <p>
So do I care if Silverlight 5 is the last version of Silverlight?
</p>
        <p>
Only if WPF continues to evolve prior to us all moving to WinRT. If WPF continues
to evolve, I would expect Silverlight to, at a minimum, keep up. Otherwise Microsoft
has led a lot of people down a dead-end path, and that’s a serious betrayal of trust.
</p>
        <p>
But if my suspicions are correct, we won’t see anything but bug fixes for WPF or Silverlight
for many years. I rather expect that these two technologies just became the next Windows
Forms. You’ll notice that WinForms hasn’t had anything but bug fixes for 6 years right?
The precedent is there for a UI technology to be “supported, stable, and stagnant”
for a very long time, and this is my expectation for WPF/SL.
</p>
        <p>
And if that’s the case, then I don’t care at all about a Silverlight 6 release. We
can use WPF/SL in their current form, right up to the point that WinRT is stable and
capable enough to act as a replacement for today’s Win32/.NET applications.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=12925691-3e22-41e2-9d8f-a66c115e8b8c" />
      </body>
      <title>Silverlight 6 doesn&amp;rsquo;t matter</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,12925691-3e22-41e2-9d8f-a66c115e8b8c.aspx</guid>
      <link>http://www.lhotka.net/weblog/Silverlight6DoesnrsquotMatter.aspx</link>
      <pubDate>Wed, 09 Nov 2011 02:51:12 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;Disclaimer: I know nothing. The following is (hopefully) well educated speculation
on my part. Time will tell whether I’m right.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I really like Silverlight. I’ve been a strong proponent of &lt;sub&gt;&lt;/sub&gt;Silverlight
since 2007 when I rushed to port CSLA .NET to the new platform.
&lt;/p&gt;
&lt;p&gt;
In fact, Magenic provided me with a dev and test team to make that transition happen,
because we all saw the amazing potential of Silverlight.
&lt;/p&gt;
&lt;p&gt;
And it has been a good few years.
&lt;/p&gt;
&lt;p&gt;
But let’s face reality. Microsoft has invested who-knows-how-much money to build WinRT,
and no matter how you look at it, WinRT is the replacement for Win32. That means all
the stuff that runs on Win32 is “dead”. This includes Silverlight, Windows Forms,
WPF, console apps – everything.
&lt;/p&gt;
&lt;p&gt;
(this is partially in answer to &lt;a href="http://www.zdnet.com/blog/microsoft/will-there-be-a-silverlight-6-and-does-it-matter/11180"&gt;Mary-Jo’s
article on Silverlight 5&lt;/a&gt;)
&lt;/p&gt;
&lt;p&gt;
I wouldn’t be surprised if Silverlight 5 was the last version. I also wouldn’t be
surprised if .NET 4.5 was the last version for the Win32 client, and that future versions
of .NET were released for servers and Azure only.
&lt;/p&gt;
&lt;p&gt;
Before you panic though, remember that VB6 has been “dead” for well over a decade.
It died at the PDC in 1999, along with COM. But you still use VB6 and/or COM? Or at
least you know organizations who do? How can that be when it is dead??
&lt;/p&gt;
&lt;p&gt;
That’s my point. “dead” isn’t really dead.
&lt;/p&gt;
&lt;p&gt;
Just how long do you think people (like me and you) will continue to run Win32-based
operating systems and applications? At least 10 years, and many will probably run
15-20 years into the future. This is the rate of change that exists in the corporate
world. At least that’s been my observation for the past couple decades.
&lt;/p&gt;
&lt;p&gt;
Microsoft supports their technologies for 10 years after a final release. So even
if SL5 is the end (and they haven’t said it is), that gives us 10 years of supported
Silverlight usage. The same for the other various .NET and Win32 technologies.
&lt;/p&gt;
&lt;p&gt;
That’s plenty of time for Microsoft to get WinRT mature, and to allow us to migrate
to that platform over a period of years.
&lt;/p&gt;
&lt;p&gt;
I don’t expect WinRT 1.0 (the Windows 8 version) to be capable of replacing Win32
or .NET. I rather expect it to be pretty crippled in many respects. Much like VB 1.0
(and 2.0), .NET 1.0 and 1.1, Silverlight 1 and 2, etc.
&lt;/p&gt;
&lt;p&gt;
But Windows 9 or Windows 10 (WinRT 2.0 or 3.0) should be quite capable of replacing
Win32 and .NET and Silverlight.
&lt;/p&gt;
&lt;p&gt;
If we assume Win8 comes out in 2012, and that Microsoft does a forced march release
of 9 and 10 every two years, that means 2016 will give us WinRT 3.0. And if we hold
to the basic truism that Microsoft always gets it right on their third release, that’ll
be the one to target.
&lt;/p&gt;
&lt;p&gt;
I think it is also reasonable to expect that Win9 and Win10 will probably continue
to have the “blue side” (see my &lt;a href="http://www.lhotka.net/weblog/UpdatedWin8DevPlatformDiagram.aspx"&gt;Windows
8 dev platform&lt;/a&gt; post), meaning Win32, .NET, and Silverlight will continue to be
released and therefore supported over that time. They may not &lt;em&gt;change&lt;/em&gt; over
that time, but they’ll be there, and they’ll be supported – or so goes my theory.
&lt;/p&gt;
&lt;p&gt;
This means that in 2016 the clock might really start for migration from Win32/.NET/Silverlight
to WinRT.
&lt;/p&gt;
&lt;p&gt;
Yes, I expect that a lot of us will build things for WinRT sooner than 2016. I certainly
hope so, because it looks like a lot of fun!
&lt;/p&gt;
&lt;p&gt;
But from a corporate perspective, where things move so slowly, this is probably good
news. Certain apps can be ported sooner, but big and important apps can move slowly
over time.
&lt;/p&gt;
&lt;p&gt;
What to do in the meantime? Between now and 2016?
&lt;/p&gt;
&lt;p&gt;
Focus on XAML, and on n-tier or SOA async server access as architectural models.
&lt;/p&gt;
&lt;p&gt;
Or focus on HTML 5 (soon to be HTML 6 fwiw, and possibly HTML 7 by 2016 for all we
know).
&lt;/p&gt;
&lt;p&gt;
I’m focusing on XAML, creating a CSLA 4 version 4.5 release that supports .NET 4.5
on servers, Azure, Windows (Win32), and Windows (WinRT). And Silverlight 5 of course.
&lt;/p&gt;
&lt;p&gt;
In fact, the plan is for a version 4.3 release to support Silverlight 5, then version
4.5 with support for .NET 4.5 and WinRT.
&lt;/p&gt;
&lt;p&gt;
I suspect that you can use Silverlight or WPF as a bridge to WinRT. The real key is
architecture.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
An n-tier architecture is fine, as long as the data access layer is running on a server,
and the client uses async calls to interact with the server. WinRT requires a lot
of async, at a minimum all server interactions. Silverlight forces you to adopt this
architecture already, so it is a natural fit. WPF doesn’t force the issue, but you
can choose to do “the right thing”.&lt;/li&gt;
&lt;li&gt;
You can also build your client applications to be “edge applications” – on the edge
of a service-oriented system. This is a less mature technology area, and it is more
costly. But it is also a fine architecture for environments composed of many disparate
applications that need to interact as a loosely coupled system. Again, all service
interactions by the edge applications (the ones running on the clients) must be async.&lt;/li&gt;
&lt;li&gt;
Or you can build “hybrid solutions”, where individual applications are built using
n-tier architectures (with async server calls). And where &lt;em&gt;some&lt;/em&gt; of those applications
also expose service interfaces so they can participate as part of a broader service-oriented
system.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I favor option 3. I don’t like to accept the cost and performance ramifications of
SOA when building &lt;em&gt;an application&lt;/em&gt;, so I’d prefer to use a faster and cheaper
n-tier architecture. At the same time, many applications do need to interact with
each other, and the requirement to create “application mashups” through edge applications
happens from time to time. So building my n-tier applications to have dual interfaces
(XAML and JSON for example) is a perfect compromise.
&lt;/p&gt;
&lt;p&gt;
The direct users of my application get n-tier performance and maintainability. And
the broader organization can access my slower-moving, standards-based, contractual
service interface. It is the best of both worlds.
&lt;/p&gt;
&lt;p&gt;
So do I care if Silverlight 5 is the last version of Silverlight?
&lt;/p&gt;
&lt;p&gt;
Only if WPF continues to evolve prior to us all moving to WinRT. If WPF continues
to evolve, I would expect Silverlight to, at a minimum, keep up. Otherwise Microsoft
has led a lot of people down a dead-end path, and that’s a serious betrayal of trust.
&lt;/p&gt;
&lt;p&gt;
But if my suspicions are correct, we won’t see anything but bug fixes for WPF or Silverlight
for many years. I rather expect that these two technologies just became the next Windows
Forms. You’ll notice that WinForms hasn’t had anything but bug fixes for 6 years right?
The precedent is there for a UI technology to be “supported, stable, and stagnant”
for a very long time, and this is my expectation for WPF/SL.
&lt;/p&gt;
&lt;p&gt;
And if that’s the case, then I don’t care at all about a Silverlight 6 release. We
can use WPF/SL in their current form, right up to the point that WinRT is stable and
capable enough to act as a replacement for today’s Win32/.NET applications.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=12925691-3e22-41e2-9d8f-a66c115e8b8c" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,12925691-3e22-41e2-9d8f-a66c115e8b8c.aspx</comments>
      <category>Architecture</category>
      <category>CSLA .NET</category>
      <category>Microsoft .NET</category>
      <category>Silverlight</category>
      <category>WinRT</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=37980542-4e6c-4a85-840e-7cd1aecaf6c3</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,37980542-4e6c-4a85-840e-7cd1aecaf6c3.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,37980542-4e6c-4a85-840e-7cd1aecaf6c3.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=37980542-4e6c-4a85-840e-7cd1aecaf6c3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve posted a number of blog entries on Windows 8 and WinRT, and thought it might
be worth summarizing them. I suggest reading them in this order:
</p>
        <p>
          <a title="Win8, Metro, and WinRT terminology" href="http://www.lhotka.net/weblog/Win8MetroAndWinRTTerminology.aspx">Win8,
Metro, and WinRT terminology</a> – why WinRT != Metro, and when I think each term
should be used
</p>
        <p>
          <a title="Windows 8 Development Platform Clarified" href="http://www.lhotka.net/weblog/Windows8DevelopmentPlatformClarified.aspx">Windows
8 Development Platform Clarified</a> – addresses questions about today’s technologies
and how they map into Windows 8, includes the Magenic Windows 8 platform diagrams
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/UpdatedWin8DevPlatformDiagram.aspx">Updated
Windows 8 Dev Platform</a> - revised/improved Windows 8 Development Platform
graphic
</p>
        <p>
          <a title="WinRT and business apps" href="http://www.lhotka.net/weblog/WinRTAndBusinessApps.aspx">WinRT
and business apps</a> – why I am convinced that WinRT is relevant for business developers
(and future business app development)
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/Silverlight6DoesnrsquotMatter.aspx">Silverlight
6 doesn't matter</a> - why the Microsoft product support strategy, and WinRT, mean
that Silverlight 6 (whether it exists or not) doesn't matter
</p>
        <p>
          <a title="Migrating smart clients to WinRT" href="http://www.lhotka.net/weblog/MigratingSmartClientsToWinRT.aspx">Migrating
smart clients to WinRT</a> – somewhat CSLA .NET specific discussion on what you can
do today to ease migration to WinRT in the future
</p>
        <p>
          <a title="WinRT and .NET" href="http://www.lhotka.net/weblog/WinRTAndNET.aspx">WinRT
and .NET</a> – first thoughts based on the //Build/ conference – a bit rambling, but
still generally useful
</p>
        <p>
          <a title="Why MVVM-" href="http://www.lhotka.net/weblog/WhyMVVM.aspx">Why MVVM</a> –
technical post discussing why using MVVM in WPF/SL today will help migrate to WinRT
in the future
</p>
        <p>
          <a title="CSLA on WinRT (project start)" href="http://www.lhotka.net/weblog/CSLAOnWinRTProjectStart.aspx">CSLA
on WinRT (project start)</a> – initial findings as I started porting CSLA .NET to
WinRT
</p>
        <p>
          <a title="WinRT BackgroundWorker type" href="http://www.lhotka.net/weblog/WinRTBackgroundWorkerType.aspx">WinRT
BackgroundWorker type</a> – technical post showing one way to recreate BackgroundWorker
using async/await in WinRT
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=37980542-4e6c-4a85-840e-7cd1aecaf6c3" />
      </body>
      <title>Windows 8 blog summary</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,37980542-4e6c-4a85-840e-7cd1aecaf6c3.aspx</guid>
      <link>http://www.lhotka.net/weblog/Windows8BlogSummary.aspx</link>
      <pubDate>Mon, 24 Oct 2011 18:04:36 GMT</pubDate>
      <description>&lt;p&gt;
I’ve posted a number of blog entries on Windows 8 and WinRT, and thought it might
be worth summarizing them. I suggest reading them in this order:
&lt;/p&gt;
&lt;p&gt;
&lt;a title="Win8, Metro, and WinRT terminology" href="http://www.lhotka.net/weblog/Win8MetroAndWinRTTerminology.aspx"&gt;Win8,
Metro, and WinRT terminology&lt;/a&gt; – why WinRT != Metro, and when I think each term
should be used
&lt;/p&gt;
&lt;p&gt;
&lt;a title="Windows 8 Development Platform Clarified" href="http://www.lhotka.net/weblog/Windows8DevelopmentPlatformClarified.aspx"&gt;Windows
8 Development Platform Clarified&lt;/a&gt; – addresses questions about today’s technologies
and how they map into Windows 8, includes the Magenic Windows 8 platform diagrams
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/UpdatedWin8DevPlatformDiagram.aspx"&gt;Updated
Windows 8 Dev Platform&lt;/a&gt;&amp;nbsp;- revised/improved Windows 8 Development Platform
graphic
&lt;/p&gt;
&lt;p&gt;
&lt;a title="WinRT and business apps" href="http://www.lhotka.net/weblog/WinRTAndBusinessApps.aspx"&gt;WinRT
and business apps&lt;/a&gt; – why I am convinced that WinRT is relevant for business developers
(and future business app development)
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/Silverlight6DoesnrsquotMatter.aspx"&gt;Silverlight
6 doesn't matter&lt;/a&gt; - why the Microsoft product support strategy, and WinRT, mean
that Silverlight 6 (whether it exists or not) doesn't matter
&lt;/p&gt;
&lt;p&gt;
&lt;a title="Migrating smart clients to WinRT" href="http://www.lhotka.net/weblog/MigratingSmartClientsToWinRT.aspx"&gt;Migrating
smart clients to WinRT&lt;/a&gt; – somewhat CSLA .NET specific discussion on what you can
do today to ease migration to WinRT in the future
&lt;/p&gt;
&lt;p&gt;
&lt;a title="WinRT and .NET" href="http://www.lhotka.net/weblog/WinRTAndNET.aspx"&gt;WinRT
and .NET&lt;/a&gt; – first thoughts based on the //Build/ conference – a bit rambling, but
still generally useful
&lt;/p&gt;
&lt;p&gt;
&lt;a title="Why MVVM-" href="http://www.lhotka.net/weblog/WhyMVVM.aspx"&gt;Why MVVM&lt;/a&gt; –
technical post discussing why using MVVM in WPF/SL today will help migrate to WinRT
in the future
&lt;/p&gt;
&lt;p&gt;
&lt;a title="CSLA on WinRT (project start)" href="http://www.lhotka.net/weblog/CSLAOnWinRTProjectStart.aspx"&gt;CSLA
on WinRT (project start)&lt;/a&gt; – initial findings as I started porting CSLA .NET to
WinRT
&lt;/p&gt;
&lt;p&gt;
&lt;a title="WinRT BackgroundWorker type" href="http://www.lhotka.net/weblog/WinRTBackgroundWorkerType.aspx"&gt;WinRT
BackgroundWorker type&lt;/a&gt; – technical post showing one way to recreate BackgroundWorker
using async/await in WinRT
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=37980542-4e6c-4a85-840e-7cd1aecaf6c3" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,37980542-4e6c-4a85-840e-7cd1aecaf6c3.aspx</comments>
      <category>Silverlight</category>
      <category>WinRT</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=62f31de1-af1a-4afb-956b-a3b7ce71eb9d</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,62f31de1-af1a-4afb-956b-a3b7ce71eb9d.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,62f31de1-af1a-4afb-956b-a3b7ce71eb9d.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=62f31de1-af1a-4afb-956b-a3b7ce71eb9d</wfw:commentRss>
      <slash:comments>7</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At <a href="http://www.vslive.com/">Visual Studio Live!</a> last week I used some
slides that several of us at <a href="http://www.magenic.com/">Magenic</a> have been
working on to provide clarity around the “Windows 8” development platform, based on
what we know from //Build/ 2011. I wanted to share some of these slides here.
</p>
        <p>
We’re also working on a related white paper that will be online soon, and I’ll link
to that when it is available.
</p>
        <p>
First, is the obligatory Microsoft “boxology” diagram that generated so much controversy
due to its over-simplistic design:
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb.png" width="244" height="138" />
          </a>
        </p>
        <p>
Although this diagram is usually found to be lacking, it did set the standard for
the green/blue color scheme and overall layout of everyone else’s “boxology” diagrams
– including ours.
</p>
        <h1>Magenic Windows 8 Diagram
</h1>
        <p>
Here is the Magenic diagram that provides more detail and clarity:
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_4.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_1.png" width="244" height="137" />
          </a>
        </p>
        <p>
Win32 (blue) is the existing Windows operating system API, and it shouldn’t be surprising
that it supports existing technologies.
</p>
        <p>
WinRT (green) is the new Windows operating system API, that I suspect will replace
Win32 over a period of many, many years. In my mind this is absolutely necessary.
Win32 is more than 16 years old, and just doesn’t provide the capabilities we want
in a modern operating system. Hopefully the new WinRT API will provide these capabilities,
and will last for another 15+ years.
</p>
        <p>
The idea in the Magenic diagram is to clearly show the WinRT (Metro, green) and Win32
(desktop, blue) sides of the Windows 8 platform, and the various development technology
stacks that can be used to build software for each operating system API.
</p>
        <p>
To provide even more clarity, we have a series of highlight diagrams for various technology
stacks.
</p>
        <h2>The Desktop (blue)
</h2>
        <p>
I’ll start by walking through all the technology stacks on the desktop (blue) side
of the master diagram:
</p>
        <ul>
          <li>
Silverlight</li>
          <li>
WPF</li>
          <li>
Web sites with plugins</li>
          <li>
Web sites with pure HTML/js</li>
          <li>
Windows Forms</li>
          <li>
C++, MFC, ATL</li>
        </ul>
        <p>
Each technology maps directly from today into Windows 8.
</p>
        <h3>Silverlight
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_8.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_3.png" width="244" height="136" />
          </a>
        </p>
        <p>
Silverlight runs in Win8 in the desktop browser, and out of browser, just like it
does today on Win7.
</p>
        <h3>WPF
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_10.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_4.png" width="244" height="136" />
          </a>
        </p>
        <p>
WPF runs in the Win8 desktop just like it does today in Win7.
</p>
        <h3>Web sites with plugin support
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_12.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_5.png" width="244" height="134" />
          </a>
        </p>
        <p>
Today’s web sites that use HTML, js, Flash, Silverlight, ActiveX, and other common
web technologies all run in the desktop web browser. This is the same as web sites
work today in Win7.
</p>
        <h3>Web sites with pure HTML/js
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_14.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_6.png" width="244" height="134" />
          </a>
        </p>
        <p>
If a web site only uses HTML, CSS, and js, then it can run in the WinRT and desktop
browsers interchangeably. Microsoft clearly expects this type of web site to become
more common over time, though it is interesting that a large number of existing Microsoft
web sites are really only useful in the desktop browser.
</p>
        <h3>Windows Forms
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_16.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_7.png" width="244" height="136" />
          </a>
        </p>
        <p>
Windows Forms continues to run in Windows 8 on the desktop, just like it does in Win7.
This isn’t surprising, given that Windows Forms is almost certainly still the dominant
technology for building Windows smart client applications, even though the technology
hasn’t had anything beyond bug fixes since 2005. It goes to show how stability in
a platform is important, and attracts widespread use for business development.
</p>
        <h3>C++, MFC, ATL
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_18.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_8.png" width="244" height="135" />
          </a>
        </p>
        <p>
Although little business development is done with C++ anymore, this technology remains
relevant for game developers, OS and device driver developers, and every now and then
I encounter someone using it for business development. From my perspective, the important
thing about C++ support is that my favorite games will probably continue to run on
Win8 in the desktop.
</p>
        <h2>WinRT (green)
</h2>
        <p>
Next, I’ll walk through the three technologies that support the WinRT API:
</p>
        <ul>
          <li>
WinRT .NET</li>
          <li>
WinRT HTML 5</li>
          <li>
WinRT C++</li>
        </ul>
        <p>
Each technology draws from existing technologies by the same names, but in each case
there’s a little “twist” as you move from the Win32 to the WinRT platform.
</p>
        <h3>WinRT .NET and XAML
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_20.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_9.png" width="244" height="138" />
          </a>
        </p>
        <p>
I expect this to be the most widely used technology stack for building WinRT applications.
The .NET available to WinRT applications is (I think) best thought of as being like
.NET on the Windows Phone. It is basically the Silverlight subset of .NET, plus a
bunch of WinRT-specific features and capabilities. The differences between Silverlight
and WinRT are a bit more dramatic than with WP7, but the analogy remains quite accurate.
</p>
        <p>
The XAML is very close to Silverlight and WPF, and the types of code you can write
using C# and VB are very comparable to what you can write today using Silverlight. 
</p>
        <p>
As a preview: the white paper we’re creating at Magenic ultimately concludes that
using Silverlight today provides the easiest transition to WinRT in the future. Not
seamless or trivial, but practical. We also conclude that WPF can enable a WinRT transition
too – especially if you limit your use of WPF and .NET to the Silverlight subset of
behaviors and features.
</p>
        <h3>WinRT HTML 5
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_22.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_10.png" width="244" height="138" />
          </a>
        </p>
        <p>
Microsoft has made much of the HTML 5 technology stack for building WinRT applications.
In no way are we talking about web sites, web pages, or web applications here. This
is <em>smart client development</em> done using technologies that were previously
web-focused.
</p>
        <p>
For a .NET developer, the technologies map like this:
</p>
        <ul>
          <li>
HTML instead of XAML</li>
          <li>
JavaScript instead of C#</li>
          <li>
WinJS instead of the .NET BCL</li>
        </ul>
        <p>
In my conversations with traditional web developers, it is a brain-bending moment
when I point out that there is <em>no web server involved</em>, and so no server-side
code at all here. All the stuff that is done in ASP.NET or PHP is now done in JavaScript.
From an architecture, design, and application functionality perspective, a WinRT HTML
5 app is almost, but not completely, unlike a web app.
</p>
        <p>
On the positive side, if a web developer can learn and embrace the smart client architectural
model, their skills with HTML, CSS, and JavaScript will carry over to this new platform.
Some HTML and CSS assets, and perhaps some js assets, will carry from web development
into this type of smart client development as well.
</p>
        <h3>WinRT C++
</h3>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_24.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_11.png" width="244" height="138" />
          </a>
        </p>
        <p>
Finally, C++ remains relevant on WinRT as well. This should come as no surprise, given
that the Windows OS developers primarily use C++, and there’ll hopefully be games
and other applications that are traditionally created using this technology.
</p>
        <p>
I also suspect that Objective C apps will port to WinRT more directly through C++
than with C# or js, and (at least for my part) I hope that some of the existing iPad/iPhone
apps quickly make their way onto WinRT so I can enjoy them.
</p>
        <h2>Summary
</h2>
        <p>
Through this series of diagrams, we clearly show how today’s technologies map directly
into the Win8 desktop world, still running on the Win32 API. And we show the three
technology stacks that enable development of applications on the new WinRT API.
</p>
        <p>
From everything we know today, it seems clear that migrating to WinRT will require
effort, regardless of the technology used today, or in the Win8 desktop. Of all existing
technologies, Silverlight and then WPF appear to offer the easiest migration. HTML
5, css, and js skills, along with some code assets will also migrate, but there’s
a non-trivial architectural difference between web development and smart client development
that shouldn’t be overlooked.
</p>
        <p>
As Microsoft releases updates to the Win8 preview and moves into a beta process, I’m
sure that we’ll learn more about the platform and how existing technologies map into
the future. It will be interesting to see how we need to update these diagrams as
Microsoft provides more information over time.
</p>
        <p>
Windows 8 is exciting, and the new WinRT platform is long-overdue. I look forward
to building WinRT applications in the not-to-distant future!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=62f31de1-af1a-4afb-956b-a3b7ce71eb9d" />
      </body>
      <title>Windows 8 Development Platform Clarified</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,62f31de1-af1a-4afb-956b-a3b7ce71eb9d.aspx</guid>
      <link>http://www.lhotka.net/weblog/Windows8DevelopmentPlatformClarified.aspx</link>
      <pubDate>Mon, 24 Oct 2011 17:08:54 GMT</pubDate>
      <description>&lt;p&gt;
At &lt;a href="http://www.vslive.com/"&gt;Visual Studio Live!&lt;/a&gt; last week I used some
slides that several of us at &lt;a href="http://www.magenic.com/"&gt;Magenic&lt;/a&gt; have been
working on to provide clarity around the “Windows 8” development platform, based on
what we know from //Build/ 2011. I wanted to share some of these slides here.
&lt;/p&gt;
&lt;p&gt;
We’re also working on a related white paper that will be online soon, and I’ll link
to that when it is available.
&lt;/p&gt;
&lt;p&gt;
First, is the obligatory Microsoft “boxology” diagram that generated so much controversy
due to its over-simplistic design:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb.png" width="244" height="138" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Although this diagram is usually found to be lacking, it did set the standard for
the green/blue color scheme and overall layout of everyone else’s “boxology” diagrams
– including ours.
&lt;/p&gt;
&lt;h1&gt;Magenic Windows 8 Diagram
&lt;/h1&gt;
&lt;p&gt;
Here is the Magenic diagram that provides more detail and clarity:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_1.png" width="244" height="137" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Win32 (blue) is the existing Windows operating system API, and it shouldn’t be surprising
that it supports existing technologies.
&lt;/p&gt;
&lt;p&gt;
WinRT (green) is the new Windows operating system API, that I suspect will replace
Win32 over a period of many, many years. In my mind this is absolutely necessary.
Win32 is more than 16 years old, and just doesn’t provide the capabilities we want
in a modern operating system. Hopefully the new WinRT API will provide these capabilities,
and will last for another 15+ years.
&lt;/p&gt;
&lt;p&gt;
The idea in the Magenic diagram is to clearly show the WinRT (Metro, green) and Win32
(desktop, blue) sides of the Windows 8 platform, and the various development technology
stacks that can be used to build software for each operating system API.
&lt;/p&gt;
&lt;p&gt;
To provide even more clarity, we have a series of highlight diagrams for various technology
stacks.
&lt;/p&gt;
&lt;h2&gt;The Desktop (blue)
&lt;/h2&gt;
&lt;p&gt;
I’ll start by walking through all the technology stacks on the desktop (blue) side
of the master diagram:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Silverlight&lt;/li&gt;
&lt;li&gt;
WPF&lt;/li&gt;
&lt;li&gt;
Web sites with plugins&lt;/li&gt;
&lt;li&gt;
Web sites with pure HTML/js&lt;/li&gt;
&lt;li&gt;
Windows Forms&lt;/li&gt;
&lt;li&gt;
C++, MFC, ATL&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Each technology maps directly from today into Windows 8.
&lt;/p&gt;
&lt;h3&gt;Silverlight
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_8.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_3.png" width="244" height="136" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Silverlight runs in Win8 in the desktop browser, and out of browser, just like it
does today on Win7.
&lt;/p&gt;
&lt;h3&gt;WPF
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_10.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_4.png" width="244" height="136" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
WPF runs in the Win8 desktop just like it does today in Win7.
&lt;/p&gt;
&lt;h3&gt;Web sites with plugin support
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_12.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_5.png" width="244" height="134" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Today’s web sites that use HTML, js, Flash, Silverlight, ActiveX, and other common
web technologies all run in the desktop web browser. This is the same as web sites
work today in Win7.
&lt;/p&gt;
&lt;h3&gt;Web sites with pure HTML/js
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_14.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_6.png" width="244" height="134" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
If a web site only uses HTML, CSS, and js, then it can run in the WinRT and desktop
browsers interchangeably. Microsoft clearly expects this type of web site to become
more common over time, though it is interesting that a large number of existing Microsoft
web sites are really only useful in the desktop browser.
&lt;/p&gt;
&lt;h3&gt;Windows Forms
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_16.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_7.png" width="244" height="136" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Windows Forms continues to run in Windows 8 on the desktop, just like it does in Win7.
This isn’t surprising, given that Windows Forms is almost certainly still the dominant
technology for building Windows smart client applications, even though the technology
hasn’t had anything beyond bug fixes since 2005. It goes to show how stability in
a platform is important, and attracts widespread use for business development.
&lt;/p&gt;
&lt;h3&gt;C++, MFC, ATL
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_18.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_8.png" width="244" height="135" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Although little business development is done with C++ anymore, this technology remains
relevant for game developers, OS and device driver developers, and every now and then
I encounter someone using it for business development. From my perspective, the important
thing about C++ support is that my favorite games will probably continue to run on
Win8 in the desktop.
&lt;/p&gt;
&lt;h2&gt;WinRT (green)
&lt;/h2&gt;
&lt;p&gt;
Next, I’ll walk through the three technologies that support the WinRT API:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
WinRT .NET&lt;/li&gt;
&lt;li&gt;
WinRT HTML 5&lt;/li&gt;
&lt;li&gt;
WinRT C++&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Each technology draws from existing technologies by the same names, but in each case
there’s a little “twist” as you move from the Win32 to the WinRT platform.
&lt;/p&gt;
&lt;h3&gt;WinRT .NET and XAML
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_20.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_9.png" width="244" height="138" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I expect this to be the most widely used technology stack for building WinRT applications.
The .NET available to WinRT applications is (I think) best thought of as being like
.NET on the Windows Phone. It is basically the Silverlight subset of .NET, plus a
bunch of WinRT-specific features and capabilities. The differences between Silverlight
and WinRT are a bit more dramatic than with WP7, but the analogy remains quite accurate.
&lt;/p&gt;
&lt;p&gt;
The XAML is very close to Silverlight and WPF, and the types of code you can write
using C# and VB are very comparable to what you can write today using Silverlight. 
&lt;/p&gt;
&lt;p&gt;
As a preview: the white paper we’re creating at Magenic ultimately concludes that
using Silverlight today provides the easiest transition to WinRT in the future. Not
seamless or trivial, but practical. We also conclude that WPF can enable a WinRT transition
too – especially if you limit your use of WPF and .NET to the Silverlight subset of
behaviors and features.
&lt;/p&gt;
&lt;h3&gt;WinRT HTML 5
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_22.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_10.png" width="244" height="138" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Microsoft has made much of the HTML 5 technology stack for building WinRT applications.
In no way are we talking about web sites, web pages, or web applications here. This
is &lt;em&gt;smart client development&lt;/em&gt; done using technologies that were previously
web-focused.
&lt;/p&gt;
&lt;p&gt;
For a .NET developer, the technologies map like this:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
HTML instead of XAML&lt;/li&gt;
&lt;li&gt;
JavaScript instead of C#&lt;/li&gt;
&lt;li&gt;
WinJS instead of the .NET BCL&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In my conversations with traditional web developers, it is a brain-bending moment
when I point out that there is &lt;em&gt;no web server involved&lt;/em&gt;, and so no server-side
code at all here. All the stuff that is done in ASP.NET or PHP is now done in JavaScript.
From an architecture, design, and application functionality perspective, a WinRT HTML
5 app is almost, but not completely, unlike a web app.
&lt;/p&gt;
&lt;p&gt;
On the positive side, if a web developer can learn and embrace the smart client architectural
model, their skills with HTML, CSS, and JavaScript will carry over to this new platform.
Some HTML and CSS assets, and perhaps some js assets, will carry from web development
into this type of smart client development as well.
&lt;/p&gt;
&lt;h3&gt;WinRT C++
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_24.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Windows-8_9AEF/image_thumb_11.png" width="244" height="138" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Finally, C++ remains relevant on WinRT as well. This should come as no surprise, given
that the Windows OS developers primarily use C++, and there’ll hopefully be games
and other applications that are traditionally created using this technology.
&lt;/p&gt;
&lt;p&gt;
I also suspect that Objective C apps will port to WinRT more directly through C++
than with C# or js, and (at least for my part) I hope that some of the existing iPad/iPhone
apps quickly make their way onto WinRT so I can enjoy them.
&lt;/p&gt;
&lt;h2&gt;Summary
&lt;/h2&gt;
&lt;p&gt;
Through this series of diagrams, we clearly show how today’s technologies map directly
into the Win8 desktop world, still running on the Win32 API. And we show the three
technology stacks that enable development of applications on the new WinRT API.
&lt;/p&gt;
&lt;p&gt;
From everything we know today, it seems clear that migrating to WinRT will require
effort, regardless of the technology used today, or in the Win8 desktop. Of all existing
technologies, Silverlight and then WPF appear to offer the easiest migration. HTML
5, css, and js skills, along with some code assets will also migrate, but there’s
a non-trivial architectural difference between web development and smart client development
that shouldn’t be overlooked.
&lt;/p&gt;
&lt;p&gt;
As Microsoft releases updates to the Win8 preview and moves into a beta process, I’m
sure that we’ll learn more about the platform and how existing technologies map into
the future. It will be interesting to see how we need to update these diagrams as
Microsoft provides more information over time.
&lt;/p&gt;
&lt;p&gt;
Windows 8 is exciting, and the new WinRT platform is long-overdue. I look forward
to building WinRT applications in the not-to-distant future!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=62f31de1-af1a-4afb-956b-a3b7ce71eb9d" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,62f31de1-af1a-4afb-956b-a3b7ce71eb9d.aspx</comments>
      <category>Magenic</category>
      <category>Silverlight</category>
      <category>WinRT</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=dd726e14-09c9-4a42-b88e-a4b9ce526034</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,dd726e14-09c9-4a42-b88e-a4b9ce526034.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,dd726e14-09c9-4a42-b88e-a4b9ce526034.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=dd726e14-09c9-4a42-b88e-a4b9ce526034</wfw:commentRss>
      <slash:comments>7</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been giving quite a lot of thought to the WinRT migration path. What is the
outlook for taking a Windows Forms, WPF, or Silverlight app into WinRT/Metro in Windows
8?
</p>
        <p>
The amount of effort required for any given application may vary radically, depending
on the architecture used when building the application, and how well that architecture
was implemented in the actual code. And it is obviously important to understand how
much client-side application code uses .NET features that aren’t in WinRT, or that
are substantially different in WinRT.
</p>
        <p>
And of course I tend to look at this from a CSLA .NET perspective <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/wlEmoticon-smile_2.png" /> 
If you use CSLA 4 today, and you adhere to the architecture and coding structures
recommended when using CSLA, most or all of your business layer code will probably
move to WinRT without change.
</p>
        <p>
So, rather simplified, and CSLA-centric, here’s a set of process flows:
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/image_4.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/image_thumb_1.png" width="403" height="306" />
          </a>
        </p>
        <p>
Although the first decision point is “Using CSLA?”, you could replace that with “using
a architecture/framework that abstracts all business, validation, authorization, data
access and other application logic away from the UI, exposing a model that supports
data binding and async server interactions”. Although I’m obviously biased, there
are absolutely other architectures that offer the same layered abstraction to keep <em>all
business and data logic</em> out of the presentation layer. And that’s really what’s
required.
</p>
        <p>
In the final analysis, if you have any business or data logic in your code-behind,
or you aren’t using data binding to connect your existing UI views to some sort of
business objects, you have some work ahead of you to get to that point.
</p>
        <p>
Essentially all non-CSLA <strong>Windows Forms apps </strong>I’ve ever seen will require
a complete rewrite. Most use DataSet objects, and therefore require total rework.
And most use a lot of code-behind, and therefore require total rework. And a lot of
them use numerous windows and modal dialogs, so the user workflow will require a complete
rethink.
</p>
        <p>
A surprising number of <strong>WPF apps </strong>are written much like Windows Forms
apps, with code-behind, etc. Those apps will require much the same effort to migrate
as Windows Forms. But if you’ve written your WPF app using MVVM, even without something
like CSLA, and have strictly avoided code-behind, the migration probably won’t be
too bad. 
</p>
        <p>
The big thing is that a lot of WPF apps aren’t written to assume async server interactions,
and updating code to handle that can be a lot of work. WPF apps written using CSLA
may already be using the async features in CSLA, and so can avoid this issue entirely.
Worst case, if you are already using CSLA synchronously, the changes to move to async
aren’t overwhelming.
</p>
        <p>
If you have a <strong>Silverlight app</strong>, you are in the best position of anyone,
because you are already using async server interaction, and can’t have made the mistake
of using the DataSet. And if you are using MVVM without any code-behind your migration
will probably be quite smooth.
</p>
        <p>
If you are also using CSLA, then your existing business layer will probably translate
to WinRT without change.
</p>
        <p>
As I mentioned in a previous <a href="http://www.lhotka.net/weblog/WinRTAndNET.aspx">WinRT
post</a>, Windows 8 is years away for most organizations. At the same time, I do think
that <a href="http://www.lhotka.net/weblog/WinRTAndBusinessApps.aspx">WinRT/Metro
will be used for business app development</a>.
</p>
        <p>
Quite a number of people are mistakenly saying that “Silverlight is dead”, when in
reality Silverlight has never been more important.
</p>
        <p>
What are you going to use to build business apps in the years between now and when
Win8 is available in your organization? 
</p>
        <p>
You might consider using the technology that appears to offer the easiest migration
to WinRT… And that is Silverlight (plus MVVM and CSLA 4 <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/wlEmoticon-smile_2.png" /> ).
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=dd726e14-09c9-4a42-b88e-a4b9ce526034" />
      </body>
      <title>Migrating smart clients to WinRT</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,dd726e14-09c9-4a42-b88e-a4b9ce526034.aspx</guid>
      <link>http://www.lhotka.net/weblog/MigratingSmartClientsToWinRT.aspx</link>
      <pubDate>Wed, 28 Sep 2011 17:35:58 GMT</pubDate>
      <description>&lt;p&gt;
I have been giving quite a lot of thought to the WinRT migration path. What is the
outlook for taking a Windows Forms, WPF, or Silverlight app into WinRT/Metro in Windows
8?
&lt;/p&gt;
&lt;p&gt;
The amount of effort required for any given application may vary radically, depending
on the architecture used when building the application, and how well that architecture
was implemented in the actual code. And it is obviously important to understand how
much client-side application code uses .NET features that aren’t in WinRT, or that
are substantially different in WinRT.
&lt;/p&gt;
&lt;p&gt;
And of course I tend to look at this from a CSLA .NET perspective &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/wlEmoticon-smile_2.png" /&gt;&amp;#160;
If you use CSLA 4 today, and you adhere to the architecture and coding structures
recommended when using CSLA, most or all of your business layer code will probably
move to WinRT without change.
&lt;/p&gt;
&lt;p&gt;
So, rather simplified, and CSLA-centric, here’s a set of process flows:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/image_thumb_1.png" width="403" height="306" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Although the first decision point is “Using CSLA?”, you could replace that with “using
a architecture/framework that abstracts all business, validation, authorization, data
access and other application logic away from the UI, exposing a model that supports
data binding and async server interactions”. Although I’m obviously biased, there
are absolutely other architectures that offer the same layered abstraction to keep &lt;em&gt;all
business and data logic&lt;/em&gt; out of the presentation layer. And that’s really what’s
required.
&lt;/p&gt;
&lt;p&gt;
In the final analysis, if you have any business or data logic in your code-behind,
or you aren’t using data binding to connect your existing UI views to some sort of
business objects, you have some work ahead of you to get to that point.
&lt;/p&gt;
&lt;p&gt;
Essentially all non-CSLA &lt;strong&gt;Windows Forms apps &lt;/strong&gt;I’ve ever seen will require
a complete rewrite. Most use DataSet objects, and therefore require total rework.
And most use a lot of code-behind, and therefore require total rework. And a lot of
them use numerous windows and modal dialogs, so the user workflow will require a complete
rethink.
&lt;/p&gt;
&lt;p&gt;
A surprising number of &lt;strong&gt;WPF apps &lt;/strong&gt;are written much like Windows Forms
apps, with code-behind, etc. Those apps will require much the same effort to migrate
as Windows Forms. But if you’ve written your WPF app using MVVM, even without something
like CSLA, and have strictly avoided code-behind, the migration probably won’t be
too bad. 
&lt;/p&gt;
&lt;p&gt;
The big thing is that a lot of WPF apps aren’t written to assume async server interactions,
and updating code to handle that can be a lot of work. WPF apps written using CSLA
may already be using the async features in CSLA, and so can avoid this issue entirely.
Worst case, if you are already using CSLA synchronously, the changes to move to async
aren’t overwhelming.
&lt;/p&gt;
&lt;p&gt;
If you have a &lt;strong&gt;Silverlight app&lt;/strong&gt;, you are in the best position of anyone,
because you are already using async server interaction, and can’t have made the mistake
of using the DataSet. And if you are using MVVM without any code-behind your migration
will probably be quite smooth.
&lt;/p&gt;
&lt;p&gt;
If you are also using CSLA, then your existing business layer will probably translate
to WinRT without change.
&lt;/p&gt;
&lt;p&gt;
As I mentioned in a previous &lt;a href="http://www.lhotka.net/weblog/WinRTAndNET.aspx"&gt;WinRT
post&lt;/a&gt;, Windows 8 is years away for most organizations. At the same time, I do think
that &lt;a href="http://www.lhotka.net/weblog/WinRTAndBusinessApps.aspx"&gt;WinRT/Metro
will be used for business app development&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Quite a number of people are mistakenly saying that “Silverlight is dead”, when in
reality Silverlight has never been more important.
&lt;/p&gt;
&lt;p&gt;
What are you going to use to build business apps in the years between now and when
Win8 is available in your organization? 
&lt;/p&gt;
&lt;p&gt;
You might consider using the technology that appears to offer the easiest migration
to WinRT… And that is Silverlight (plus MVVM and CSLA 4 &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.lhotka.net/weblog/content/binary/Windows-Live-Writer/Migrating-smart-clients-to-WinRT_ABF7/wlEmoticon-smile_2.png" /&gt; ).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=dd726e14-09c9-4a42-b88e-a4b9ce526034" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,dd726e14-09c9-4a42-b88e-a4b9ce526034.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WinRT</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=b4e62243-4995-499f-9d68-cfd7663c1992</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,b4e62243-4995-499f-9d68-cfd7663c1992.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,b4e62243-4995-499f-9d68-cfd7663c1992.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=b4e62243-4995-499f-9d68-cfd7663c1992</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://bxf.codeplex.com">Bxf</a> and CSLA .NET both include a TriggerAction
control. This control helps support the MVVM design pattern in WPF, Silverlight, and
WP7 applications.
</p>
        <p>
(Bxf is completely independent from CSLA – I donated TriggerAction from CSLA to the
Bxf project a while back though, so this type is available from either framework)
</p>
        <p>
The specific problem addressed by TriggerAction is the need to invoke a verb (method/command)
on your viewmodel object in response to any arbitrary UI event. One common UI event
is something like a button click event, though you can often use commanding in that
case. But there are numerous other UI events from many controls other than buttons,
and you might want to have one of those UI events cause the viewmodel to perform an
action.
</p>
        <p>
TriggerAction basically wires arbitrary UI events to methods on the current DataContext
(usually the viewmodel object).
</p>
        <blockquote>
          <p>
            <font face="Courier New">&lt;bxf:TriggerAction TargetControl="{Binding ElementName=MyControl}" 
<br />
                                          
TriggerEvent="MouseOver" 
<br />
                                          
DataContext="{Binding Source={StaticResource vm}}" 
<br />
                                          
MethodName="MyAction" /&gt;</font>
          </p>
        </blockquote>
        <p>
TriggerAction listens for the trigger event from the TargetControl. When it handles
that event, it invokes the specified method (MethodName) on its current DataContext
object. There’s nothing more to it.
</p>
        <p>
To get TriggerAction working you need two things: source and target.
</p>
        <p>
Source:
</p>
        <ol>
          <li>
TargetControl must be set</li>
          <li>
TriggerEvent may be set (default is “Click”)</li>
        </ol>
        <p>
Target:
</p>
        <ol>
          <li>
DataContext must be set (or inherited from the container)</li>
          <li>
MethodName must be set</li>
        </ol>
        <p>
Parameter (optional):
</p>
        <ol>
          <li>
MethodParameter may be set (to a value or binding expression)</li>
          <li>
RebindParameterDynamically may be set to true (to force rebinding of MethodParameter
to work around issues with certain control properties such as ListBox.SelectedItems)</li>
        </ol>
        <p>
The most common causes of failure when using TriggerAction are that the TargetControl
isn’t set right, or the DataContext isn’t set right, and of those two the most common
is that the DataContext isn’t what you think it is (that happens to me all the time).
</p>
        <p>
The method TriggerAction invokes on the DataContext object can accept either 0 or
2 parameters:
</p>
        <blockquote>
          <p>
public void MyAction()
</p>
        </blockquote>
        <p>
or
</p>
        <blockquote>
          <p>
public void MyAction(object sender, ExecuteEventArgs e)
</p>
        </blockquote>
        <p>
The ExecuteEventArgs class is also defined in Bxf and CSLA. If you use TriggerAction
from Bxf.Xaml, you <em>must</em> use ExecuteEventArgs from Bxf.Xaml. If you use TriggerAction
from Csla.Xaml, you <em>must</em> use ExecuteEventArgs from Csla.Xaml.
</p>
        <p>
If you are using Bxf and CSLA together it is important to understand that the ViewModel&lt;T&gt;
class from Csla.Xaml uses the Csla.Xaml.ExecuteEventArgs type. If you are using the
Bxf TriggerAction control, you’ll need to create your own viewmodel types from Csla.Xaml.ViewModelBase&lt;T&gt;
to accept the Bxf.Xaml.ExecuteEventArgs type.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=b4e62243-4995-499f-9d68-cfd7663c1992" />
      </body>
      <title>Using the TriggerAction control</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,b4e62243-4995-499f-9d68-cfd7663c1992.aspx</guid>
      <link>http://www.lhotka.net/weblog/UsingTheTriggerActionControl.aspx</link>
      <pubDate>Fri, 18 Feb 2011 23:31:39 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://bxf.codeplex.com"&gt;Bxf&lt;/a&gt; and CSLA .NET both include a TriggerAction
control. This control helps support the MVVM design pattern in WPF, Silverlight, and
WP7 applications.
&lt;/p&gt;
&lt;p&gt;
(Bxf is completely independent from CSLA – I donated TriggerAction from CSLA to the
Bxf project a while back though, so this type is available from either framework)
&lt;/p&gt;
&lt;p&gt;
The specific problem addressed by TriggerAction is the need to invoke a verb (method/command)
on your viewmodel object in response to any arbitrary UI event. One common UI event
is something like a button click event, though you can often use commanding in that
case. But there are numerous other UI events from many controls other than buttons,
and you might want to have one of those UI events cause the viewmodel to perform an
action.
&lt;/p&gt;
&lt;p&gt;
TriggerAction basically wires arbitrary UI events to methods on the current DataContext
(usually the viewmodel object).
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;bxf:TriggerAction TargetControl=&amp;quot;{Binding ElementName=MyControl}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
TriggerEvent=&amp;quot;MouseOver&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
DataContext=&amp;quot;{Binding Source={StaticResource vm}}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
MethodName=&amp;quot;MyAction&amp;quot; /&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
TriggerAction listens for the trigger event from the TargetControl. When it handles
that event, it invokes the specified method (MethodName) on its current DataContext
object. There’s nothing more to it.
&lt;/p&gt;
&lt;p&gt;
To get TriggerAction working you need two things: source and target.
&lt;/p&gt;
&lt;p&gt;
Source:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
TargetControl must be set&lt;/li&gt;
&lt;li&gt;
TriggerEvent may be set (default is “Click”)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Target:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
DataContext must be set (or inherited from the container)&lt;/li&gt;
&lt;li&gt;
MethodName must be set&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Parameter (optional):
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
MethodParameter may be set (to a value or binding expression)&lt;/li&gt;
&lt;li&gt;
RebindParameterDynamically may be set to true (to force rebinding of MethodParameter
to work around issues with certain control properties such as ListBox.SelectedItems)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
The most common causes of failure when using TriggerAction are that the TargetControl
isn’t set right, or the DataContext isn’t set right, and of those two the most common
is that the DataContext isn’t what you think it is (that happens to me all the time).
&lt;/p&gt;
&lt;p&gt;
The method TriggerAction invokes on the DataContext object can accept either 0 or
2 parameters:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void MyAction()
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
or
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void MyAction(object sender, ExecuteEventArgs e)
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The ExecuteEventArgs class is also defined in Bxf and CSLA. If you use TriggerAction
from Bxf.Xaml, you &lt;em&gt;must&lt;/em&gt; use ExecuteEventArgs from Bxf.Xaml. If you use TriggerAction
from Csla.Xaml, you &lt;em&gt;must&lt;/em&gt; use ExecuteEventArgs from Csla.Xaml.
&lt;/p&gt;
&lt;p&gt;
If you are using Bxf and CSLA together it is important to understand that the ViewModel&amp;lt;T&amp;gt;
class from Csla.Xaml uses the Csla.Xaml.ExecuteEventArgs type. If you are using the
Bxf TriggerAction control, you’ll need to create your own viewmodel types from Csla.Xaml.ViewModelBase&amp;lt;T&amp;gt;
to accept the Bxf.Xaml.ExecuteEventArgs type.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=b4e62243-4995-499f-9d68-cfd7663c1992" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,b4e62243-4995-499f-9d68-cfd7663c1992.aspx</comments>
      <category>Bxf</category>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WP7</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=8d3d88b6-ccb6-47c1-8a08-b24c63f87db8</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,8d3d88b6-ccb6-47c1-8a08-b24c63f87db8.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,8d3d88b6-ccb6-47c1-8a08-b24c63f87db8.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=8d3d88b6-ccb6-47c1-8a08-b24c63f87db8</wfw:commentRss>
      <slash:comments>18</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Over the past few months there’s been this ongoing buzz about whether WPF is dead,
or whether Silverlight is really mature – in short, people trying to figure out whether
to use WPF or Silverlight or both.
</p>
        <p>
Having worked with WPF since it came out, and with Silverlight 2.0 and higher since
before it came out, I thought I’d share my thoughts. 
</p>
        <p>
This post flows from my experiences with CSLA .NET, <a href="http://unitdriven.codeplex.com">UnitDriven</a> and <a href="http://bxf.codeplex.com">Bxf</a> –
three frameworks I’ve created or been directly involved with, that run on WPF (.NET),
Silverlight and now Windows Phone 7 (WP7). With CSLA in particular, I’ve been maintaining
this one codebase on .NET since 2001, and to my knowledge it was the first major framework
ported to Silverlight from .NET. Also, as I write about this, I’m thinking about how
I build XAML-based apps, using the MVVM pattern as discussed in the <a href="http://store.lhotka.net/">CSLA
4 MVVM video series</a> and some of my previous blog posts.
</p>
        <p>
The way I use SL and WPF there is no meaningful difference between them. My MVVM demos,
for example, are mostly the same across WPF, SL and even WP7.
</p>
        <p>
The business layer, created with CSLA 4, is typically identical across all three platforms.
That’s one of the big benefits of CSLA 4, in that you can write your business, validation
and authorization rules once and use them across multiple interface technologies.
And with the data portal managing any interactions with the application server, you
are shielded from any complexity or differences you’d normally encounter there as
well.
</p>
        <p>
The way I use MVVM, with a strong focus on having zero code-behind any XAML, means
that nearly all interface control logic (any actual code in the presentation layer)
is also reused. Any presentation layer code is either in the viewmodel, in value converters,
in attached properties or custom controls. This reuse isn’t always 100%, especially
when you get to WP7, because the tiny phone screen often forces a different user workflow
than if you have a full-size screen like in WPF or SL. But between WPF and SL, the
viewmodel code is typically the same, as is most value converter and attached property
code. Some custom controls may be different – again especially on the phone.
</p>
        <p>
This commonality of viewmodel code is thanks to the use of Bxf. But any decent MVVM
framework will offer the same kind of abstractions, so your application code is never
directly interacting with the UI shell or any platform-specific constructs or types.
</p>
        <p>
With WPF and SL there are places of direct difference however, depending on how you
structure your user experience.
</p>
        <ul>
          <li>
WPF doesn't have a URL based navigation scheme or a navigation framework, so you have
to come up with your own UI framework to manage any sort of navigation model. I usually
do this by having exactly one Window, and that hosts all my content in the form of
UserControl objects, but you could use many Window objects. 
</li>
          <li>
SL does have an <em>optional</em> URL based navigation scheme and framework, which
is nice - makes things simpler. However, you can use the same "one Window that
hosts UserControl objects" model just like WPF (hence my samples are the same).
What you can't do is have a lot of Window objects (which to me is no loss, since the
multiple SDI interface went out of style in 1997). 
</li>
          <li>
WP7 also has a URL based navigation scheme and framework. I still use the hosted UserControl
idea too, and that makes a lot of the code common with SL and WPF. 
</li>
        </ul>
        <p>
I think the thing to understand, is that while SL runs in the browser, it is a smart
client technology. It is far more like WPF than like HTML. In fact it is virtually
identical to WPF in most ways that matter for a business app.
</p>
        <p>
And the key to my success in this area, is that all my business “forms” or “pages”
are always a subclass of UserControl. So every bit of meaningful UI content (forms/pages)
are UserControl objects that can be hosted by the UI shell. This means that I can
usually change out the shell, or even have different shell styles (URL navigation
vs Outlook-style navigation for example) and this has no effect on the actual business
UI elements. Yes, the shell code may be different, but the business code is unchanged.
</p>
        <p>
This is one powerful technique that makes it quite realistic to create your app in
Silverlight, even using the navigation framework, and then port it to WPF if you need
to in the future. You might have to write some new WPF shell code, but your UserControl
XAML, your viewmodels, your business domain objects, your data access code and your
database remain unchanged.
</p>
        <p>
Beyond UI and navigation differences, there are some technical differences between
WPF and SL, including:
</p>
        <ul>
          <li>
Some minor, niggling differences in XAML - this is the sort of thing I personally
want fixed now that the WPF and SL product teams have merged - this niggling differences
are stupid and are nothing but an annoyance – why is the binding Mode default different
between WPF and SL (for example)??</li>
          <li>
SL <em>requires</em> that all server interactions be async, WPF allows sync or async
- I tend to use async in both places, because the user experience is so superior with
async, I can't figure out why I'd want to punish my end users just because they are
using WPF 
</li>
          <li>
SL has the navigation framework, WPF doesn't 
</li>
          <li>
WPF has an application model that includes navigation, but it is hopelessly broken
- it tried to emulate the worst features of the web without any of the benefits -
to me this is the "ActiveX Documents" of WPF 
</li>
          <li>
WPF apps can use all of .NET, SL uses a subset - but the SL subset is everything I've
needed to build typical business apps 
</li>
          <li>
WPF apps can interact with the full client workstation hardware (odd peripherals,
the full hard drive, etc) 
</li>
          <li>
WPF apps are (typically) deployed via ClickOnce, SL apps are deployed transparently
via the browser - so WPF is slightly more "in your face" for your users,
but the difference should be pretty incidental 
</li>
          <li>
WPF apps can tap into all of DirectX, though SL now has hardware acceleration for
some graphics scenarios too - so this difference is probably less meaningful for most
business apps than for games 
</li>
          <li>
SL doesn't have the complexity of the legacy "crap" that comes with WPF
(DataSet, IBindingList, etc) so it is a simpler, easier and more consistent programming
environment 
</li>
          <li>
SL runs on Windows, in the browser, on the Mac, in the browser on the Mac, and in
WP7; WPF of course runs only on Windows 
</li>
        </ul>
        <p>
Again however, I come back to the same thing - I always use as little of any platform/technology
as necessary to get the job done. SL is a subset, so if I can get the job done with
SL then that's the best thing to do (I can always upsize to WPF later if necessary).
If I can't get the job done with SL, I'll use WPF.
</p>
        <p>
In my mind it is a superset/subset decision - always default to the subset that meets
your needs.
</p>
        <p>
As long as you understand both technologies, you can architect your UI so transitioning
from SL to WPF is relatively easy (the other way isn't always so easy - because your
WPF code might use superset technologies).
</p>
        <p>
In conclusion, my recommendation has been (since SL3 at least) to design your app
for SL, and fall back to WPF only if SL can’t meet your needs. The most common scenarios
for business apps to fall back to WPF are:
</p>
        <ul>
          <li>
Your app is only occasionally connected, and is mostly offline, so you use a client-side
database like SQL Express or SQL CE</li>
          <li>
Your app needs to interact with client-side peripherals</li>
          <li>
Your app needs full access to the client-side hard drive</li>
        </ul>
        <p>
I don’t think this is a “WPF vs SL” thing at all. I think it is a sliding scale, where
you default to SL, and slide up to WPF if necessary. All the angst is unnecessary.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=8d3d88b6-ccb6-47c1-8a08-b24c63f87db8" />
      </body>
      <title>WPF vs Silverlight, really?</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,8d3d88b6-ccb6-47c1-8a08-b24c63f87db8.aspx</guid>
      <link>http://www.lhotka.net/weblog/WPFVsSilverlightReally.aspx</link>
      <pubDate>Tue, 09 Nov 2010 16:06:24 GMT</pubDate>
      <description>&lt;p&gt;
Over the past few months there’s been this ongoing buzz about whether WPF is dead,
or whether Silverlight is really mature – in short, people trying to figure out whether
to use WPF or Silverlight or both.
&lt;/p&gt;
&lt;p&gt;
Having worked with WPF since it came out, and with Silverlight 2.0 and higher since
before it came out, I thought I’d share my thoughts. 
&lt;/p&gt;
&lt;p&gt;
This post flows from my experiences with CSLA .NET, &lt;a href="http://unitdriven.codeplex.com"&gt;UnitDriven&lt;/a&gt; and &lt;a href="http://bxf.codeplex.com"&gt;Bxf&lt;/a&gt; –
three frameworks I’ve created or been directly involved with, that run on WPF (.NET),
Silverlight and now Windows Phone 7 (WP7). With CSLA in particular, I’ve been maintaining
this one codebase on .NET since 2001, and to my knowledge it was the first major framework
ported to Silverlight from .NET. Also, as I write about this, I’m thinking about how
I build XAML-based apps, using the MVVM pattern as discussed in the &lt;a href="http://store.lhotka.net/"&gt;CSLA
4 MVVM video series&lt;/a&gt; and some of my previous blog posts.
&lt;/p&gt;
&lt;p&gt;
The way I use SL and WPF there is no meaningful difference between them. My MVVM demos,
for example, are mostly the same across WPF, SL and even WP7.
&lt;/p&gt;
&lt;p&gt;
The business layer, created with CSLA 4, is typically identical across all three platforms.
That’s one of the big benefits of CSLA 4, in that you can write your business, validation
and authorization rules once and use them across multiple interface technologies.
And with the data portal managing any interactions with the application server, you
are shielded from any complexity or differences you’d normally encounter there as
well.
&lt;/p&gt;
&lt;p&gt;
The way I use MVVM, with a strong focus on having zero code-behind any XAML, means
that nearly all interface control logic (any actual code in the presentation layer)
is also reused. Any presentation layer code is either in the viewmodel, in value converters,
in attached properties or custom controls. This reuse isn’t always 100%, especially
when you get to WP7, because the tiny phone screen often forces a different user workflow
than if you have a full-size screen like in WPF or SL. But between WPF and SL, the
viewmodel code is typically the same, as is most value converter and attached property
code. Some custom controls may be different – again especially on the phone.
&lt;/p&gt;
&lt;p&gt;
This commonality of viewmodel code is thanks to the use of Bxf. But any decent MVVM
framework will offer the same kind of abstractions, so your application code is never
directly interacting with the UI shell or any platform-specific constructs or types.
&lt;/p&gt;
&lt;p&gt;
With WPF and SL there are places of direct difference however, depending on how you
structure your user experience.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
WPF doesn't have a URL based navigation scheme or a navigation framework, so you have
to come up with your own UI framework to manage any sort of navigation model. I usually
do this by having exactly one Window, and that hosts all my content in the form of
UserControl objects, but you could use many Window objects. 
&lt;/li&gt;
&lt;li&gt;
SL does have an &lt;em&gt;optional&lt;/em&gt; URL based navigation scheme and framework, which
is nice - makes things simpler. However, you can use the same &amp;quot;one Window that
hosts UserControl objects&amp;quot; model just like WPF (hence my samples are the same).
What you can't do is have a lot of Window objects (which to me is no loss, since the
multiple SDI interface went out of style in 1997). 
&lt;/li&gt;
&lt;li&gt;
WP7 also has a URL based navigation scheme and framework. I still use the hosted UserControl
idea too, and that makes a lot of the code common with SL and WPF. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I think the thing to understand, is that while SL runs in the browser, it is a smart
client technology. It is far more like WPF than like HTML. In fact it is virtually
identical to WPF in most ways that matter for a business app.
&lt;/p&gt;
&lt;p&gt;
And the key to my success in this area, is that all my business “forms” or “pages”
are always a subclass of UserControl. So every bit of meaningful UI content (forms/pages)
are UserControl objects that can be hosted by the UI shell. This means that I can
usually change out the shell, or even have different shell styles (URL navigation
vs Outlook-style navigation for example) and this has no effect on the actual business
UI elements. Yes, the shell code may be different, but the business code is unchanged.
&lt;/p&gt;
&lt;p&gt;
This is one powerful technique that makes it quite realistic to create your app in
Silverlight, even using the navigation framework, and then port it to WPF if you need
to in the future. You might have to write some new WPF shell code, but your UserControl
XAML, your viewmodels, your business domain objects, your data access code and your
database remain unchanged.
&lt;/p&gt;
&lt;p&gt;
Beyond UI and navigation differences, there are some technical differences between
WPF and SL, including:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Some minor, niggling differences in XAML - this is the sort of thing I personally
want fixed now that the WPF and SL product teams have merged - this niggling differences
are stupid and are nothing but an annoyance – why is the binding Mode default different
between WPF and SL (for example)??&lt;/li&gt;
&lt;li&gt;
SL &lt;em&gt;requires&lt;/em&gt; that all server interactions be async, WPF allows sync or async
- I tend to use async in both places, because the user experience is so superior with
async, I can't figure out why I'd want to punish my end users just because they are
using WPF 
&lt;/li&gt;
&lt;li&gt;
SL has the navigation framework, WPF doesn't 
&lt;/li&gt;
&lt;li&gt;
WPF has an application model that includes navigation, but it is hopelessly broken
- it tried to emulate the worst features of the web without any of the benefits -
to me this is the &amp;quot;ActiveX Documents&amp;quot; of WPF 
&lt;/li&gt;
&lt;li&gt;
WPF apps can use all of .NET, SL uses a subset - but the SL subset is everything I've
needed to build typical business apps 
&lt;/li&gt;
&lt;li&gt;
WPF apps can interact with the full client workstation hardware (odd peripherals,
the full hard drive, etc) 
&lt;/li&gt;
&lt;li&gt;
WPF apps are (typically) deployed via ClickOnce, SL apps are deployed transparently
via the browser - so WPF is slightly more &amp;quot;in your face&amp;quot; for your users,
but the difference should be pretty incidental 
&lt;/li&gt;
&lt;li&gt;
WPF apps can tap into all of DirectX, though SL now has hardware acceleration for
some graphics scenarios too - so this difference is probably less meaningful for most
business apps than for games 
&lt;/li&gt;
&lt;li&gt;
SL doesn't have the complexity of the legacy &amp;quot;crap&amp;quot; that comes with WPF
(DataSet, IBindingList, etc) so it is a simpler, easier and more consistent programming
environment 
&lt;/li&gt;
&lt;li&gt;
SL runs on Windows, in the browser, on the Mac, in the browser on the Mac, and in
WP7; WPF of course runs only on Windows 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Again however, I come back to the same thing - I always use as little of any platform/technology
as necessary to get the job done. SL is a subset, so if I can get the job done with
SL then that's the best thing to do (I can always upsize to WPF later if necessary).
If I can't get the job done with SL, I'll use WPF.
&lt;/p&gt;
&lt;p&gt;
In my mind it is a superset/subset decision - always default to the subset that meets
your needs.
&lt;/p&gt;
&lt;p&gt;
As long as you understand both technologies, you can architect your UI so transitioning
from SL to WPF is relatively easy (the other way isn't always so easy - because your
WPF code might use superset technologies).
&lt;/p&gt;
&lt;p&gt;
In conclusion, my recommendation has been (since SL3 at least) to design your app
for SL, and fall back to WPF only if SL can’t meet your needs. The most common scenarios
for business apps to fall back to WPF are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Your app is only occasionally connected, and is mostly offline, so you use a client-side
database like SQL Express or SQL CE&lt;/li&gt;
&lt;li&gt;
Your app needs to interact with client-side peripherals&lt;/li&gt;
&lt;li&gt;
Your app needs full access to the client-side hard drive&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I don’t think this is a “WPF vs SL” thing at all. I think it is a sliding scale, where
you default to SL, and slide up to WPF if necessary. All the angst is unnecessary.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=8d3d88b6-ccb6-47c1-8a08-b24c63f87db8" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,8d3d88b6-ccb6-47c1-8a08-b24c63f87db8.aspx</comments>
      <category>Bxf</category>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WP7</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=e5c2bd7f-ed6b-409b-b94d-4d1af748e212</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,e5c2bd7f-ed6b-409b-b94d-4d1af748e212.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,e5c2bd7f-ed6b-409b-b94d-4d1af748e212.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=e5c2bd7f-ed6b-409b-b94d-4d1af748e212</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Halloween is over, so it is time to quit being scared and get back to reality.
</p>
        <p>
This is, perhaps, easier for me, because my wife and I attended the <a href="http://www.rallytorestoresanity.com/">Rally
to Restore Sanity and/or Fear</a> over the weekend. There’s nothing like being surrounded
by 200,000+ sane people on a beautiful afternoon in Washington DC to refresh your
spirit and appreciation for the true strength of America (and I think humanity in
general).
</p>
        <p>
Of course while we were <a href="http://www.comedycentral.com/shows/rally_to_restore_sanity_and_or_fear/index.jhtml">enjoying
great music, comedy and an inspirational speech by Jon Stewart</a>, the Microsoft
developer world was turning itself inside out with the hyperbole generated by last
week’s PDC conference and some less than thoroughly explained remarks made by Bob
Muglia in an interview.
</p>
        <p>
My reaction, perhaps tempered by hours of restoring sanity, was relatively simple:
</p>
        <ol>
          <li>
Microsoft (and BobMu) clearly didn’t intend to gut their entire client-side development
community</li>
          <li>
Therefore this is just a (perhaps big) PR mistake, nothing more</li>
          <li>
Therefore it is best to just wait for Microsoft to correct the mistake with clarification</li>
        </ol>
        <p>
I feel justified in that reaction, since we now have clarification from BobMu and
SteveB:
</p>
        <ul>
          <li>
Bob Muglia on the Silverlight Team Blog: <a href="http://team.silverlight.net">http://team.silverlight.net</a></li>
          <li>
Steve Ballmer on his PDC blog: <a href="http://www.microsoft.com/presspass/press/2010/nov10/11-01Statement.mspx">http://www.microsoft.com/presspass/press/2010/nov10/11-01Statement.mspx</a></li>
        </ul>
        <p>
Other Microsoft Silverlight bloggers, such as Tim Heuer, are starting to blog as well,
so I’m sure there’ll be further reinforcement and refinement of these top-level responses.
And I would expect to see continuing movement on the part of Microsoft and its product
groups to prove their ongoing top-level commitment to Silverlight and the whole idea
of a Microsoft-based smart-client experience.
</p>
        <p>
I think what happened is this: at least in the US we’re just a day away from a big
election. For weeks (months?) we’ve been bombarded with messages of fear and hatred
from political candidates, political action committees and cable news channels. It
is very challenging to maintain a positive or even moderate outlook on life itself
when you are continually inundated (unless you never watch television or listen to
the radio or go to your mailbox) by these vile messages from every side for weeks
or months on end.
</p>
        <p>
It is no surprise to me that the developers, at least in the US, fell right into the
same fear/hatred mindset with the (clearly incongruous) information about Silverlight
– everyone’s mind is already primed for a fight-or-flight response. Confusion leads
instantly to fear, which (as we all know) leads to the dark side.
</p>
        <p>
After tomorrow, the election will be over, along with the fear/hate ads. By the time
our brain chemistry has returned to normal, the newly elected politicians will be
well down the path of corporate-sponsored corruption and life will continue.
</p>
        <p>
In the meantime, at least we now know (again) that Silverlight has a bright future
as the smart client development tool of choice for Windows, the Mac, Windows Phone
and other devices. 
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=e5c2bd7f-ed6b-409b-b94d-4d1af748e212" />
      </body>
      <title>Silverlight and the PDC</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,e5c2bd7f-ed6b-409b-b94d-4d1af748e212.aspx</guid>
      <link>http://www.lhotka.net/weblog/SilverlightAndThePDC.aspx</link>
      <pubDate>Mon, 01 Nov 2010 19:27:32 GMT</pubDate>
      <description>&lt;p&gt;
Halloween is over, so it is time to quit being scared and get back to reality.
&lt;/p&gt;
&lt;p&gt;
This is, perhaps, easier for me, because my wife and I attended the &lt;a href="http://www.rallytorestoresanity.com/"&gt;Rally
to Restore Sanity and/or Fear&lt;/a&gt; over the weekend. There’s nothing like being surrounded
by 200,000+ sane people on a beautiful afternoon in Washington DC to refresh your
spirit and appreciation for the true strength of America (and I think humanity in
general).
&lt;/p&gt;
&lt;p&gt;
Of course while we were &lt;a href="http://www.comedycentral.com/shows/rally_to_restore_sanity_and_or_fear/index.jhtml"&gt;enjoying
great music, comedy and an inspirational speech by Jon Stewart&lt;/a&gt;, the Microsoft
developer world was turning itself inside out with the hyperbole generated by last
week’s PDC conference and some less than thoroughly explained remarks made by Bob
Muglia in an interview.
&lt;/p&gt;
&lt;p&gt;
My reaction, perhaps tempered by hours of restoring sanity, was relatively simple:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Microsoft (and BobMu) clearly didn’t intend to gut their entire client-side development
community&lt;/li&gt;
&lt;li&gt;
Therefore this is just a (perhaps big) PR mistake, nothing more&lt;/li&gt;
&lt;li&gt;
Therefore it is best to just wait for Microsoft to correct the mistake with clarification&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I feel justified in that reaction, since we now have clarification from BobMu and
SteveB:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Bob Muglia on the Silverlight Team Blog: &lt;a href="http://team.silverlight.net"&gt;http://team.silverlight.net&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
Steve Ballmer on his PDC blog: &lt;a href="http://www.microsoft.com/presspass/press/2010/nov10/11-01Statement.mspx"&gt;http://www.microsoft.com/presspass/press/2010/nov10/11-01Statement.mspx&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Other Microsoft Silverlight bloggers, such as Tim Heuer, are starting to blog as well,
so I’m sure there’ll be further reinforcement and refinement of these top-level responses.
And I would expect to see continuing movement on the part of Microsoft and its product
groups to prove their ongoing top-level commitment to Silverlight and the whole idea
of a Microsoft-based smart-client experience.
&lt;/p&gt;
&lt;p&gt;
I think what happened is this: at least in the US we’re just a day away from a big
election. For weeks (months?) we’ve been bombarded with messages of fear and hatred
from political candidates, political action committees and cable news channels. It
is very challenging to maintain a positive or even moderate outlook on life itself
when you are continually inundated (unless you never watch television or listen to
the radio or go to your mailbox) by these vile messages from every side for weeks
or months on end.
&lt;/p&gt;
&lt;p&gt;
It is no surprise to me that the developers, at least in the US, fell right into the
same fear/hatred mindset with the (clearly incongruous) information about Silverlight
– everyone’s mind is already primed for a fight-or-flight response. Confusion leads
instantly to fear, which (as we all know) leads to the dark side.
&lt;/p&gt;
&lt;p&gt;
After tomorrow, the election will be over, along with the fear/hate ads. By the time
our brain chemistry has returned to normal, the newly elected politicians will be
well down the path of corporate-sponsored corruption and life will continue.
&lt;/p&gt;
&lt;p&gt;
In the meantime, at least we now know (again) that Silverlight has a bright future
as the smart client development tool of choice for Windows, the Mac, Windows Phone
and other devices. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=e5c2bd7f-ed6b-409b-b94d-4d1af748e212" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,e5c2bd7f-ed6b-409b-b94d-4d1af748e212.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=6473ff9e-fb7e-47c4-8073-478a0599e768</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,6473ff9e-fb7e-47c4-8073-478a0599e768.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,6473ff9e-fb7e-47c4-8073-478a0599e768.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=6473ff9e-fb7e-47c4-8073-478a0599e768</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am pleased to announce the first beta release of CSLA 4 version 4.1 with support
for Windows Phone 7, and continuing support for .NET 4 and Silverlight 4.
</p>
        <p>
          <a href="http://www.lhotka.net/cslanet/download.aspx">Download CSLA 4 version 4.1.0
here</a>
        </p>
        <p>
With this release, it is now possible to write a single business layer composed of
business domain objects that run unchanged on a WP7 device, in Silverlight, on a Windows
client, on Windows Server and on Windows Azure.
</p>
        <p>
The samples download includes Samples\Net\cs\SimpleNTier, which does implement the
following interfaces over one common business layer:
</p>
        <ul>
          <li>
Windows Phone</li>
          <li>
WPF</li>
          <li>
Silverlight</li>
          <li>
ASP.NET MVC</li>
        </ul>
        <p>
Of course this is just the first beta release, so there’s more work to be done. At
the same time, we have completed the vast majority of the effort, and it is quite
possible to build WP7 applications using this beta.
</p>
        <p>
As with all CSLA releases, this one does include some bug fixes and enhancements to
other parts of the framework. Please see the <a href="http://www.lhotka.net/Article.aspx?id=9aad2f99-86eb-453b-a760-6303c3b27552">change
log</a> for a list of all changes. Enhancement highlights include:
</p>
        <ul>
          <li>
Add ability to get a consolidated list of broken rules for an object graph</li>
          <li>
New BackgroundWorker component that automatically initializes background threads with
the current principal and culture from the UI thread</li>
          <li>
TriggerAction provides better debugging information, following the lead of many Microsoft
XAML controls</li>
          <li>
and much more…</li>
        </ul>
        <p>
In related news, <a href="http://unitdriven.codeplex.com">UnitDriven</a> has also
been updated to support WP7, and provides a pretty comprehensive unit test runner
and framework for WP7 code. CSLA uses UnitDriven for its automated testing, but UnitDriven
can be used for any application on .NET, Silverlight or WP7.
</p>
        <p>
Similarly, <a href="http://bxf.codeplex.com">Bxf</a> (Basic XAML Framework) has been
updated to support WP7, thereby providing a common MVVM framework for WPF, Silverlight
and WP7 UI development efforts. Some CSLA sample apps use Bxf, but Bxf can be used
for any application, including those that don’t involve CSLA at all.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=6473ff9e-fb7e-47c4-8073-478a0599e768" />
      </body>
      <title>CSLA 4 version 4.1 beta release</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,6473ff9e-fb7e-47c4-8073-478a0599e768.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLA4Version41BetaRelease.aspx</link>
      <pubDate>Fri, 22 Oct 2010 19:35:18 GMT</pubDate>
      <description>&lt;p&gt;
I am pleased to announce the first beta release of CSLA 4 version 4.1 with support
for Windows Phone 7, and continuing support for .NET 4 and Silverlight 4.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;Download CSLA 4 version 4.1.0
here&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
With this release, it is now possible to write a single business layer composed of
business domain objects that run unchanged on a WP7 device, in Silverlight, on a Windows
client, on Windows Server and on Windows Azure.
&lt;/p&gt;
&lt;p&gt;
The samples download includes Samples\Net\cs\SimpleNTier, which does implement the
following interfaces over one common business layer:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Windows Phone&lt;/li&gt;
&lt;li&gt;
WPF&lt;/li&gt;
&lt;li&gt;
Silverlight&lt;/li&gt;
&lt;li&gt;
ASP.NET MVC&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Of course this is just the first beta release, so there’s more work to be done. At
the same time, we have completed the vast majority of the effort, and it is quite
possible to build WP7 applications using this beta.
&lt;/p&gt;
&lt;p&gt;
As with all CSLA releases, this one does include some bug fixes and enhancements to
other parts of the framework. Please see the &lt;a href="http://www.lhotka.net/Article.aspx?id=9aad2f99-86eb-453b-a760-6303c3b27552"&gt;change
log&lt;/a&gt; for a list of all changes. Enhancement highlights include:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Add ability to get a consolidated list of broken rules for an object graph&lt;/li&gt;
&lt;li&gt;
New BackgroundWorker component that automatically initializes background threads with
the current principal and culture from the UI thread&lt;/li&gt;
&lt;li&gt;
TriggerAction provides better debugging information, following the lead of many Microsoft
XAML controls&lt;/li&gt;
&lt;li&gt;
and much more…&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In related news, &lt;a href="http://unitdriven.codeplex.com"&gt;UnitDriven&lt;/a&gt; has also
been updated to support WP7, and provides a pretty comprehensive unit test runner
and framework for WP7 code. CSLA uses UnitDriven for its automated testing, but UnitDriven
can be used for any application on .NET, Silverlight or WP7.
&lt;/p&gt;
&lt;p&gt;
Similarly, &lt;a href="http://bxf.codeplex.com"&gt;Bxf&lt;/a&gt; (Basic XAML Framework) has been
updated to support WP7, thereby providing a common MVVM framework for WPF, Silverlight
and WP7 UI development efforts. Some CSLA sample apps use Bxf, but Bxf can be used
for any application, including those that don’t involve CSLA at all.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=6473ff9e-fb7e-47c4-8073-478a0599e768" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,6473ff9e-fb7e-47c4-8073-478a0599e768.aspx</comments>
      <category>Bxf</category>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>Web</category>
      <category>Windows Azure</category>
      <category>WP7</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=23df901b-3951-415c-9ff5-da0e7098b2db</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,23df901b-3951-415c-9ff5-da0e7098b2db.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,23df901b-3951-415c-9ff5-da0e7098b2db.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=23df901b-3951-415c-9ff5-da0e7098b2db</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am working on <a href="http://www.lhotka.net/weblog/GettingCSLA4ToCompileForWP7.aspx">CSLA
4 for Windows Phone 7</a>. Of course I want to get all my unit tests (or most of them
anyway) running on WP7.
</p>
        <p>
When we created CSLA .NET for Silverlight it was long before Silverlight 2 shipped,
and there was no workable unit test framework for Silverlight. Even today, it is tricky
to test async methods and features with mstest in SL. Perhaps most importantly however,
I wanted to have the same exact unit test code running in .NET and Silverlight – and
that’s a level of parity that is hard to achieve.
</p>
        <p>
So Justin created UnitDriven and we donated it to the community through codeplex: <a href="http://unitdriven.codeplex.com">http://unitdriven.codeplex.com</a>.
</p>
        <p>
And I have a few hundred unit tests for CSLA that rely on UnitDriven, so it isn’t
a trivial thing to think about switching to something else – so it is important that
UnitDriven work on WP7 too.
</p>
        <p>
Fortunately Justin was able to get this done in an evening. It turns out that the
only major change required was to the UI, because obviously the WP7 form factor is
very space constrained compared to a full-size screen.
</p>
        <p>
          <strong>The end result is that there’s a preview release of UnitDriven that works
on WP7 – you can download it from <a href="http://unitdriven.codeplex.com/">codeplex</a>. </strong>
        </p>
        <p>
Most of my CSLA unit tests are passing at this point, which gives us some confidence
that UnitDriven is working as expected. There are some UI issues still, especially
with long test names and some scrolling issues.
</p>
        <p>
But if you are looking for a way to write unit tests for your WP7 Silverlight code,
and especially if you want to use the same unit test code on .NET, Silverlight and
WP7, then <a href="http://unitdriven.codeplex.com/">UnitDriven</a> is something you
should consider.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=23df901b-3951-415c-9ff5-da0e7098b2db" />
      </body>
      <title>Unit testing for Windows Phone 7</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,23df901b-3951-415c-9ff5-da0e7098b2db.aspx</guid>
      <link>http://www.lhotka.net/weblog/UnitTestingForWindowsPhone7.aspx</link>
      <pubDate>Tue, 10 Aug 2010 19:22:31 GMT</pubDate>
      <description>&lt;p&gt;
I am working on &lt;a href="http://www.lhotka.net/weblog/GettingCSLA4ToCompileForWP7.aspx"&gt;CSLA
4 for Windows Phone 7&lt;/a&gt;. Of course I want to get all my unit tests (or most of them
anyway) running on WP7.
&lt;/p&gt;
&lt;p&gt;
When we created CSLA .NET for Silverlight it was long before Silverlight 2 shipped,
and there was no workable unit test framework for Silverlight. Even today, it is tricky
to test async methods and features with mstest in SL. Perhaps most importantly however,
I wanted to have the same exact unit test code running in .NET and Silverlight – and
that’s a level of parity that is hard to achieve.
&lt;/p&gt;
&lt;p&gt;
So Justin created UnitDriven and we donated it to the community through codeplex: &lt;a href="http://unitdriven.codeplex.com"&gt;http://unitdriven.codeplex.com&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
And I have a few hundred unit tests for CSLA that rely on UnitDriven, so it isn’t
a trivial thing to think about switching to something else – so it is important that
UnitDriven work on WP7 too.
&lt;/p&gt;
&lt;p&gt;
Fortunately Justin was able to get this done in an evening. It turns out that the
only major change required was to the UI, because obviously the WP7 form factor is
very space constrained compared to a full-size screen.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The end result is that there’s a preview release of UnitDriven that works
on WP7 – you can download it from &lt;a href="http://unitdriven.codeplex.com/"&gt;codeplex&lt;/a&gt;. &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Most of my CSLA unit tests are passing at this point, which gives us some confidence
that UnitDriven is working as expected. There are some UI issues still, especially
with long test names and some scrolling issues.
&lt;/p&gt;
&lt;p&gt;
But if you are looking for a way to write unit tests for your WP7 Silverlight code,
and especially if you want to use the same unit test code on .NET, Silverlight and
WP7, then &lt;a href="http://unitdriven.codeplex.com/"&gt;UnitDriven&lt;/a&gt; is something you
should consider.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=23df901b-3951-415c-9ff5-da0e7098b2db" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,23df901b-3951-415c-9ff5-da0e7098b2db.aspx</comments>
      <category>Silverlight</category>
      <category>Windows Phone</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=eab4a9ea-50b7-4542-8a51-bc792d68684f</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,eab4a9ea-50b7-4542-8a51-bc792d68684f.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,eab4a9ea-50b7-4542-8a51-bc792d68684f.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=eab4a9ea-50b7-4542-8a51-bc792d68684f</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <em>CSLA .NET and MVVM video series</em> is now complete and online.
</p>
        <ul>
          <li>
            <a href="http://store.lhotka.net/Default.aspx?tabid=1560&amp;ProductID=21">Click here
to purchase</a>
          </li>
          <li>
            <a href="http://download.lhotka.net/Default.aspx?t=CslaMvvm">Click here to download</a> if
you’ve already purchased the series</li>
        </ul>
        <p>
The first video in the series is available for free from the <a href="http://download.lhotka.net/Default.aspx?t=CslaMvvm">download
page</a>, so you can get a better idea about the approach I’m taking in using MVVM
with CSLA 4 and Silverlight or WPF.
</p>
        <p>
This is a six part series (nearly 3.5 hours of content) covering the Model-View-ViewModel
(MVVM) design pattern and how to efficiently apply it when your model is constructed
using <a href="http://www.lhotka.net/cslanet/">CSLA 4</a>, and your UI is built using
Silverlight or WPF.
</p>
        <p>
That means you have a rich business domain model that fully encapsulates your business
logic (validation, authorization, calculations, etc), and those objects (thanks to
CSLA) fully support all the data binding semantics for Silverlight and WPF. And it
means you have access to useful helper components and controls from the Csla.Xaml
namespace, including viewmodel base classes, validation information display and UI
event triggering to help wire up UI events to viewmodel verbs/methods.
</p>
        <p>
The series also makes use of the <a href="http://bxf.codeplex.com/">Bxf framework</a>,
which is an extremely lightweight MVVM UI framework designed to illustrate the basic
concepts of an MVVM framework. Like MVC, it is really impossible to make effective
use of the MVVM design pattern without some level of framework support. <em>Something</em> has
to manage the creation and display of views, and the process of wiring up a viewmodel
to a view, just like <em>something</em> has to route commands to a controller and
render views in MVC. Bxf is the smallest possible set of framework behaviors I’ve
been able to identify that makes MVVM practical to implement.
</p>
        <p>
As a bonus, the sixth video in the series discusses how to apply the concepts from
the video series in CSLA .NET 3.8.4 with Visual Studio 2008. Even if you can’t move
to CSLA 4, .NET 4 and Visual Studio 2010 yet, the vast majority of the content in
this video series is still valuable!
</p>
        <p>
If you are using CSLA .NET to build Silverlight or WPF applications, or if you want
to explore some practical ways to think about and implement the MVVM design pattern,
this video series is a must have!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=eab4a9ea-50b7-4542-8a51-bc792d68684f" />
      </body>
      <title>CSLA .NET and MVVM video series</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,eab4a9ea-50b7-4542-8a51-bc792d68684f.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANETAndMVVMVideoSeries.aspx</link>
      <pubDate>Sat, 31 Jul 2010 17:36:49 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;em&gt;CSLA .NET and MVVM video series&lt;/em&gt; is now complete and online.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://store.lhotka.net/Default.aspx?tabid=1560&amp;amp;ProductID=21"&gt;Click here
to purchase&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://download.lhotka.net/Default.aspx?t=CslaMvvm"&gt;Click here to download&lt;/a&gt; if
you’ve already purchased the series&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The first video in the series is available for free from the &lt;a href="http://download.lhotka.net/Default.aspx?t=CslaMvvm"&gt;download
page&lt;/a&gt;, so you can get a better idea about the approach I’m taking in using MVVM
with CSLA 4 and Silverlight or WPF.
&lt;/p&gt;
&lt;p&gt;
This is a six part series (nearly 3.5 hours of content) covering the Model-View-ViewModel
(MVVM) design pattern and how to efficiently apply it when your model is constructed
using &lt;a href="http://www.lhotka.net/cslanet/"&gt;CSLA 4&lt;/a&gt;, and your UI is built using
Silverlight or WPF.
&lt;/p&gt;
&lt;p&gt;
That means you have a rich business domain model that fully encapsulates your business
logic (validation, authorization, calculations, etc), and those objects (thanks to
CSLA) fully support all the data binding semantics for Silverlight and WPF. And it
means you have access to useful helper components and controls from the Csla.Xaml
namespace, including viewmodel base classes, validation information display and UI
event triggering to help wire up UI events to viewmodel verbs/methods.
&lt;/p&gt;
&lt;p&gt;
The series also makes use of the &lt;a href="http://bxf.codeplex.com/"&gt;Bxf framework&lt;/a&gt;,
which is an extremely lightweight MVVM UI framework designed to illustrate the basic
concepts of an MVVM framework. Like MVC, it is really impossible to make effective
use of the MVVM design pattern without some level of framework support. &lt;em&gt;Something&lt;/em&gt; has
to manage the creation and display of views, and the process of wiring up a viewmodel
to a view, just like &lt;em&gt;something&lt;/em&gt; has to route commands to a controller and
render views in MVC. Bxf is the smallest possible set of framework behaviors I’ve
been able to identify that makes MVVM practical to implement.
&lt;/p&gt;
&lt;p&gt;
As a bonus, the sixth video in the series discusses how to apply the concepts from
the video series in CSLA .NET 3.8.4 with Visual Studio 2008. Even if you can’t move
to CSLA 4, .NET 4 and Visual Studio 2010 yet, the vast majority of the content in
this video series is still valuable!
&lt;/p&gt;
&lt;p&gt;
If you are using CSLA .NET to build Silverlight or WPF applications, or if you want
to explore some practical ways to think about and implement the MVVM design pattern,
this video series is a must have!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=eab4a9ea-50b7-4542-8a51-bc792d68684f" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,eab4a9ea-50b7-4542-8a51-bc792d68684f.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=01510111-fab5-4ea9-b741-30889c7ef74a</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,01510111-fab5-4ea9-b741-30889c7ef74a.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,01510111-fab5-4ea9-b741-30889c7ef74a.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=01510111-fab5-4ea9-b741-30889c7ef74a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was interviewed for MSDN Bytes while at Tech Ed in New Orleans earlier this year.
The interview is now online:
</p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/ff851876.aspx">http://msdn.microsoft.com/en-us/ff851876.aspx</a>
        </p>
        <p>
The interview is focused on Windows Phone 7, but of course I also talk about Silverlight
and CSLA .NET a little bit too.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=01510111-fab5-4ea9-b741-30889c7ef74a" />
      </body>
      <title>MSDN Bytes interview on WP7</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,01510111-fab5-4ea9-b741-30889c7ef74a.aspx</guid>
      <link>http://www.lhotka.net/weblog/MSDNBytesInterviewOnWP7.aspx</link>
      <pubDate>Mon, 26 Jul 2010 16:39:28 GMT</pubDate>
      <description>&lt;p&gt;
I was interviewed for MSDN Bytes while at Tech Ed in New Orleans earlier this year.
The interview is now online:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/ff851876.aspx"&gt;http://msdn.microsoft.com/en-us/ff851876.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The interview is focused on Windows Phone 7, but of course I also talk about Silverlight
and CSLA .NET a little bit too.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=01510111-fab5-4ea9-b741-30889c7ef74a" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,01510111-fab5-4ea9-b741-30889c7ef74a.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WP7</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=ecf754b9-65b4-4b29-a8b6-84412e2c2753</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,ecf754b9-65b4-4b29-a8b6-84412e2c2753.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,ecf754b9-65b4-4b29-a8b6-84412e2c2753.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ecf754b9-65b4-4b29-a8b6-84412e2c2753</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have put the CSLA 4 MVVM video series on the store: 
</p>
        <p>
          <a href="http://store.lhotka.net/Default.aspx?tabid=1560&amp;ProductID=21">http://store.lhotka.net/Default.aspx?tabid=1560&amp;ProductID=21</a>
        </p>
        <p>
The video series is not complete, but the first two segments are online.
</p>
        <p>
The current <strike>$44.95</strike> $74.95 purchase price is a limited time offer
- a discount from the final price (to be determined) for people willing to buy now
and get the rest of the content as it is completed.
</p>
        <p>
I expect to complete the series by the end of July, so if you want the discount please
act soon.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ecf754b9-65b4-4b29-a8b6-84412e2c2753" />
      </body>
      <title>CSLA 4 MVVM video series pre-release offer</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,ecf754b9-65b4-4b29-a8b6-84412e2c2753.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLA4MVVMVideoSeriesPrereleaseOffer.aspx</link>
      <pubDate>Wed, 14 Jul 2010 02:45:07 GMT</pubDate>
      <description>&lt;p&gt;
I have put the CSLA 4 MVVM video series on the store: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://store.lhotka.net/Default.aspx?tabid=1560&amp;amp;ProductID=21"&gt;http://store.lhotka.net/Default.aspx?tabid=1560&amp;amp;ProductID=21&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The video series is not complete, but the first two segments are online.
&lt;/p&gt;
&lt;p&gt;
The current &lt;strike&gt;$44.95&lt;/strike&gt; $74.95 purchase price is a limited time offer
- a discount from the final price (to be determined) for people willing to buy now
and get the rest of the content as it is completed.
&lt;/p&gt;
&lt;p&gt;
I expect to complete the series by the end of July, so if you want the discount please
act soon.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ecf754b9-65b4-4b29-a8b6-84412e2c2753" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,ecf754b9-65b4-4b29-a8b6-84412e2c2753.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=386a3650-049b-4a15-a60c-ffd3efee9551</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,386a3650-049b-4a15-a60c-ffd3efee9551.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,386a3650-049b-4a15-a60c-ffd3efee9551.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=386a3650-049b-4a15-a60c-ffd3efee9551</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The fact that server access is all async in Silverlight makes some common tasks a
little more challenging. This includes lazy loading child objects in an on-demand
manner.
</p>
        <p>
When implementing lazy loading in CSLA it is pretty typical to implement the on-demand
load of the child property value in the child property getter. In other words, in
the parent object, there’ll be a property that exposes the child object, and in the
getter of that property is where the lazy loading code goes:
</p>
        <blockquote>public static PropertyInfo&lt;Child&gt; ChildProperty = RegisterProperty&lt;Child&gt;(c
=&gt; c.Child); 
<br />
public Child Child 
<br />
{ 
<br />
  get 
<br />
  { 
<br /><strong>    if (!FieldManager.FieldExists(ChildProperty)) 
<br />
    {<br />
      Child = DataPortal.Fetch&lt;ChildLoader&gt;().Child; 
<br />
      OnPropertyChanged(ChildProperty);<br />
    }<br /></strong>    return GetProperty(ChildProperty); 
<br />
  } 
<br />
  private set { LoadProperty(ChildrenProperty, value); } 
<br />
}</blockquote>
        <p>
The ChildLoader type shown here is a command object (I typically use a ReadOnlyBase
subclass) that runs to the server, loads the child object and returns it to the client.
ChildLoader might look like this:
</p>
        <blockquote>
          <p>
[Serializable] 
<br />
public class ChildLoader : ReadOnlyBase&lt;ChildLoader&gt; 
<br />
{ 
<br />
  public static PropertyInfo&lt;Child&gt; ChildProperty = RegisterProperty&lt;Child&gt;(c
=&gt; c.Child); 
<br />
  public Child Child 
<br />
  { 
<br />
    get { return ReadProperty(ChildProperty); } 
<br />
    private set { LoadProperty(ChildProperty, value); } 
<br />
  } 
<br /><br />
  private void DataPortal_Fetch() 
<br />
  { 
<br />
    Child = DataPortal.FetchChild&lt;Child&gt;(); 
<br />
  } 
<br />
}
</p>
        </blockquote>
        <p>
This all works great in .NET, where all this code is synchronous. But it needs a little
tweaking to work in Silverlight, where server communication is async.
</p>
        <p>
First, the parent property getter must return something <em>before it has the actual
value</em>. This is kind of a big deal, because it means the UI must be able to handle
getting back a null value, and then later getting the real value. This isn’t too hard
though, at least if you are using data binding, because the UI will show nothing for
the null value, and will automatically refresh the display when the real value arrives
(because CSLA will raise a PropertyChanged event for the Child property).
</p>
        <p>
Also, you’ll probably want to mark the parent object as busy while the operation is
occurring, so the UI can take appropriate steps (again, by using data binding against
the IsBusy property) to block the user from trying to interact with this part of the
app until the actual data arrives:
</p>
        <blockquote>
          <p>
public static PropertyInfo&lt;Child&gt; ChildProperty = RegisterProperty&lt;Child&gt;(c
=&gt; c.Child); 
<br />
public Child Child 
<br />
{ 
<br />
  get 
<br />
  { 
<br /><strong>    if (!FieldManager.FieldExists(ChildProperty)) 
<br />
    { 
<br />
      MarkBusy(); 
<br />
      DataPortal.BeginFetch&lt;ChildLoader&gt;((o, e) =&gt; 
<br />
        { 
<br />
          if (e.Error != null) 
<br />
            throw e.Error; 
<br />
          Child = e.Object.Child; 
<br />
          MarkIdle(); 
<br />
          OnPropertyChanged(ChildProperty);<br />
        }); 
<br />
    } 
<br /></strong>    return GetProperty(ChildrenProperty); 
<br />
  } 
<br />
  private set { LoadProperty(ChildrenProperty, value); } 
<br />
}
</p>
        </blockquote>
        <p>
When the getter is first called it will start the async load operation, and then it
will return null. Later, when the BeginFetch() call completes it will set the Child
property to the actual value and indicate that the parent object is no longer busy.
</p>
        <p>
The ChildLoader is unaffected, since it was (and still is) running primarily on the
.NET app server. The only difference is that the client is using BeginFetch() instead
of Fetch(), so the ChildLoader is running async instead of sync. But that doesn’t
affect the way ChildLoader works – so the only impact is to the parent object’s Child
property getter.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=386a3650-049b-4a15-a60c-ffd3efee9551" />
      </body>
      <title>Lazy loading children in CSLA 4 and Silverlight</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,386a3650-049b-4a15-a60c-ffd3efee9551.aspx</guid>
      <link>http://www.lhotka.net/weblog/LazyLoadingChildrenInCSLA4AndSilverlight.aspx</link>
      <pubDate>Thu, 01 Jul 2010 18:11:43 GMT</pubDate>
      <description>&lt;p&gt;
The fact that server access is all async in Silverlight makes some common tasks a
little more challenging. This includes lazy loading child objects in an on-demand
manner.
&lt;/p&gt;
&lt;p&gt;
When implementing lazy loading in CSLA it is pretty typical to implement the on-demand
load of the child property value in the child property getter. In other words, in
the parent object, there’ll be a property that exposes the child object, and in the
getter of that property is where the lazy loading code goes:
&lt;/p&gt;
&lt;blockquote&gt;public static PropertyInfo&amp;lt;Child&amp;gt; ChildProperty = RegisterProperty&amp;lt;Child&amp;gt;(c
=&amp;gt; c.Child); 
&lt;br&gt;
public Child Child 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp; get 
&lt;br&gt;
&amp;nbsp; { 
&lt;br&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!FieldManager.FieldExists(ChildProperty)) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Child = DataPortal.Fetch&amp;lt;ChildLoader&amp;gt;().Child; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnPropertyChanged(ChildProperty);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return GetProperty(ChildProperty); 
&lt;br&gt;
&amp;nbsp; } 
&lt;br&gt;
&amp;nbsp; private set { LoadProperty(ChildrenProperty, value); } 
&lt;br&gt;
}&lt;/blockquote&gt; 
&lt;p&gt;
The ChildLoader type shown here is a command object (I typically use a ReadOnlyBase
subclass) that runs to the server, loads the child object and returns it to the client.
ChildLoader might look like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
[Serializable] 
&lt;br&gt;
public class ChildLoader : ReadOnlyBase&amp;lt;ChildLoader&amp;gt; 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp; public static PropertyInfo&amp;lt;Child&amp;gt; ChildProperty = RegisterProperty&amp;lt;Child&amp;gt;(c
=&amp;gt; c.Child); 
&lt;br&gt;
&amp;nbsp; public Child Child 
&lt;br&gt;
&amp;nbsp; { 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return ReadProperty(ChildProperty); } 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private set { LoadProperty(ChildProperty, value); } 
&lt;br&gt;
&amp;nbsp; } 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp; private void DataPortal_Fetch() 
&lt;br&gt;
&amp;nbsp; { 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Child = DataPortal.FetchChild&amp;lt;Child&amp;gt;(); 
&lt;br&gt;
&amp;nbsp; } 
&lt;br&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This all works great in .NET, where all this code is synchronous. But it needs a little
tweaking to work in Silverlight, where server communication is async.
&lt;/p&gt;
&lt;p&gt;
First, the parent property getter must return something &lt;em&gt;before it has the actual
value&lt;/em&gt;. This is kind of a big deal, because it means the UI must be able to handle
getting back a null value, and then later getting the real value. This isn’t too hard
though, at least if you are using data binding, because the UI will show nothing for
the null value, and will automatically refresh the display when the real value arrives
(because CSLA will raise a PropertyChanged event for the Child property).
&lt;/p&gt;
&lt;p&gt;
Also, you’ll probably want to mark the parent object as busy while the operation is
occurring, so the UI can take appropriate steps (again, by using data binding against
the IsBusy property) to block the user from trying to interact with this part of the
app until the actual data arrives:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public static PropertyInfo&amp;lt;Child&amp;gt; ChildProperty = RegisterProperty&amp;lt;Child&amp;gt;(c
=&amp;gt; c.Child); 
&lt;br&gt;
public Child Child 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp; get 
&lt;br&gt;
&amp;nbsp; { 
&lt;br&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!FieldManager.FieldExists(ChildProperty)) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MarkBusy(); 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataPortal.BeginFetch&amp;lt;ChildLoader&amp;gt;((o, e) =&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (e.Error != null) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw e.Error; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Child = e.Object.Child; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MarkIdle(); 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnPropertyChanged(ChildProperty);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;br&gt;
&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return GetProperty(ChildrenProperty); 
&lt;br&gt;
&amp;nbsp; } 
&lt;br&gt;
&amp;nbsp; private set { LoadProperty(ChildrenProperty, value); } 
&lt;br&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
When the getter is first called it will start the async load operation, and then it
will return null. Later, when the BeginFetch() call completes it will set the Child
property to the actual value and indicate that the parent object is no longer busy.
&lt;/p&gt;
&lt;p&gt;
The ChildLoader is unaffected, since it was (and still is) running primarily on the
.NET app server. The only difference is that the client is using BeginFetch() instead
of Fetch(), so the ChildLoader is running async instead of sync. But that doesn’t
affect the way ChildLoader works – so the only impact is to the parent object’s Child
property getter.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=386a3650-049b-4a15-a60c-ffd3efee9551" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,386a3650-049b-4a15-a60c-ffd3efee9551.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=ead52403-d10d-486d-91c4-d0765cb24ec9</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,ead52403-d10d-486d-91c4-d0765cb24ec9.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,ead52403-d10d-486d-91c4-d0765cb24ec9.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ead52403-d10d-486d-91c4-d0765cb24ec9</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
CSLA includes a control called PropertyStatus, which is somewhat like the Windows
Forms ErrorProvider, but far more powerful. It displays error, warning and informational
messages from the business object property to which it is bound, and also exposes
various metadata properties so other UI elements can bind in interesting ways (like
disabling or hiding parts of the UI if the user isn’t authorized to view or edit a
property).
</p>
        <p>
The PropertyStatus control has been around for a couple years, in Silverlight 2 and
3 and WPF 3.5.
</p>
        <p>
It broke in Silverlight 4 (but not WPF 4). I spent most of today trying to figure
out why. What changed? We’d made a few changes to the control as part of the CSLA
4 project, but nothing really major – certainly nothing that seemed like it should
make the control fail in SL4 and work in WPF (it is the same control for both technologies).
</p>
        <p>
After a couple hours of frustration with the debugger, I enlisted the help of my friend
and colleague Justin Chase. We fired up SharedView and spent a couple more hours of
quality time with the VS10 debugger.
</p>
        <p>
Nothing made sense. The problem was that the control would just disappear. If it was
displaying an error icon, and the property was changed, but remained in error, the
icon would disappear – the control would vanish.
</p>
        <p>
The control is written using the VisualStateManager (VSM). So whether it is visible
or not depends on which visual state is current. States are Valid, Error, Warning,
Information, Busy.
</p>
        <p>
There’s exactly one line of code in the control that calls the VMS GoToState() method.
We could watch the code set the visual state to Error. And then we could watch the
control vanish from the UI shortly thereafter.
</p>
        <p>
Justin had the bright idea to put non-blank content in the Valid and Busy states (because
normally they are empty). That worked – it turned out that <em>something</em> was
setting the state to Valid.
</p>
        <p>
We searched rather thoroughly through the CSLA codebase trying to find anything that
might be using the VSM to set the state to Valid. We commented out most of the code
in the control – including the one GoToState() call. We made sure CSLA was not setting
the visual state.
</p>
        <p>
And yet the state was being set to Valid.
</p>
        <p>
So we changed the name of the state from Valid to Foo. That fixed the problem. Whatever
code (presumably in the Silverlight runtime???) that was setting the state to Valid
was no longer impacting us, because we no longer had a Valid state.
</p>
        <p>
I assume this has something to do with the new validation concepts built into Silverlight
4. But talk about nasty! Apparently something in Silverlight runs through the visual
tree, setting visual states of controls to “Valid” if that state is defined. I rather
suspect there are other “reserved states” as well – but I don’t know for sure.
</p>
        <p>
Of course my theory could be wrong, and perhaps it is yet something else that is setting
visual states to Valid – but my money is on the Silverlight 4 validation system…
</p>
        <p>
This is a horrific breaking change from SL3 to SL4, primarily because it isn’t something
you’d expect. To have some other code hijack your visual states just because of how
they are named – that’s really unpleasant.
</p>
        <p>
So I’m blogging this in the hopes that anyone else using the VSM with a state name
of “Valid” can avoid spending as many hours as Justin and I just did trying to figure
out the problem…
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ead52403-d10d-486d-91c4-d0765cb24ec9" />
      </body>
      <title>Silverlight 4 VisualStateManager Valid issue</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,ead52403-d10d-486d-91c4-d0765cb24ec9.aspx</guid>
      <link>http://www.lhotka.net/weblog/Silverlight4VisualStateManagerValidIssue.aspx</link>
      <pubDate>Tue, 29 Jun 2010 20:58:25 GMT</pubDate>
      <description>&lt;p&gt;
CSLA includes a control called PropertyStatus, which is somewhat like the Windows
Forms ErrorProvider, but far more powerful. It displays error, warning and informational
messages from the business object property to which it is bound, and also exposes
various metadata properties so other UI elements can bind in interesting ways (like
disabling or hiding parts of the UI if the user isn’t authorized to view or edit a
property).
&lt;/p&gt;
&lt;p&gt;
The PropertyStatus control has been around for a couple years, in Silverlight 2 and
3 and WPF 3.5.
&lt;/p&gt;
&lt;p&gt;
It broke in Silverlight 4 (but not WPF 4). I spent most of today trying to figure
out why. What changed? We’d made a few changes to the control as part of the CSLA
4 project, but nothing really major – certainly nothing that seemed like it should
make the control fail in SL4 and work in WPF (it is the same control for both technologies).
&lt;/p&gt;
&lt;p&gt;
After a couple hours of frustration with the debugger, I enlisted the help of my friend
and colleague Justin Chase. We fired up SharedView and spent a couple more hours of
quality time with the VS10 debugger.
&lt;/p&gt;
&lt;p&gt;
Nothing made sense. The problem was that the control would just disappear. If it was
displaying an error icon, and the property was changed, but remained in error, the
icon would disappear – the control would vanish.
&lt;/p&gt;
&lt;p&gt;
The control is written using the VisualStateManager (VSM). So whether it is visible
or not depends on which visual state is current. States are Valid, Error, Warning,
Information, Busy.
&lt;/p&gt;
&lt;p&gt;
There’s exactly one line of code in the control that calls the VMS GoToState() method.
We could watch the code set the visual state to Error. And then we could watch the
control vanish from the UI shortly thereafter.
&lt;/p&gt;
&lt;p&gt;
Justin had the bright idea to put non-blank content in the Valid and Busy states (because
normally they are empty). That worked – it turned out that &lt;em&gt;something&lt;/em&gt; was
setting the state to Valid.
&lt;/p&gt;
&lt;p&gt;
We searched rather thoroughly through the CSLA codebase trying to find anything that
might be using the VSM to set the state to Valid. We commented out most of the code
in the control – including the one GoToState() call. We made sure CSLA was not setting
the visual state.
&lt;/p&gt;
&lt;p&gt;
And yet the state was being set to Valid.
&lt;/p&gt;
&lt;p&gt;
So we changed the name of the state from Valid to Foo. That fixed the problem. Whatever
code (presumably in the Silverlight runtime???) that was setting the state to Valid
was no longer impacting us, because we no longer had a Valid state.
&lt;/p&gt;
&lt;p&gt;
I assume this has something to do with the new validation concepts built into Silverlight
4. But talk about nasty! Apparently something in Silverlight runs through the visual
tree, setting visual states of controls to “Valid” if that state is defined. I rather
suspect there are other “reserved states” as well – but I don’t know for sure.
&lt;/p&gt;
&lt;p&gt;
Of course my theory could be wrong, and perhaps it is yet something else that is setting
visual states to Valid – but my money is on the Silverlight 4 validation system…
&lt;/p&gt;
&lt;p&gt;
This is a horrific breaking change from SL3 to SL4, primarily because it isn’t something
you’d expect. To have some other code hijack your visual states just because of how
they are named – that’s really unpleasant.
&lt;/p&gt;
&lt;p&gt;
So I’m blogging this in the hopes that anyone else using the VSM with a state name
of “Valid” can avoid spending as many hours as Justin and I just did trying to figure
out the problem…
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ead52403-d10d-486d-91c4-d0765cb24ec9" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,ead52403-d10d-486d-91c4-d0765cb24ec9.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=aa934b13-3397-409e-a191-b09e3c0dba40</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,aa934b13-3397-409e-a191-b09e3c0dba40.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,aa934b13-3397-409e-a191-b09e3c0dba40.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=aa934b13-3397-409e-a191-b09e3c0dba40</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Over the past few months I’ve been researching, writing and speaking about MVVM quite
a lot. One of the teaching tools I’ve developed has turned out to be useful for both
teaching and actually building applications. This is the Bxf (Basic XAML Framework)
code I’ve developed.
</p>
        <p>
I must confess, I have little interest in becoming a UI framework author. But I also
recognize that you can’t do any UI pattern like MVVM (or MVC) without some minimal
framework support – there’s just some plumbing code you must have for the pattern
to be actually useful.
</p>
        <p>
Bxf is the minimum set of functionality I’ve been able to identify to support MVVM,
with a couple other key goals:
</p>
        <ol>
          <li>
Support MVVM so a developer only creates a View, ViewModel and Model</li>
          <li>
Same functionality/code in Silverlight and WPF</li>
          <li>
Zero code-behind the XAML – any UI code goes in the viewmodel, and binding/commanding/trigger
actions are used to allow the view to interact with the viewmodel</li>
          <li>
Enable the use of the Visual Studio 2010 XAML designer (“Cider”), most notably the
drag-and-drop data binding support it provides</li>
          <li>
Enable the use of Expression Blend</li>
        </ol>
        <p>
I’ve included Bxf in some samples from the Visual Studio 2010 launch and for CSLA
4. But I’ve decided that’s too random, so I created <a href="http://bxf.codeplex.com">http://bxf.codeplex.com</a> to
house the code.
</p>
        <p>
My hope is that other people who find Bxf useful might choose to join the project
as contributors and extend it to be more broadly useful. However, I also hope that
the framework remains extremely simple and minimalistic (since there are already several
quite robust and complex frameworks out there for people who need more than a simple
solution can offer).
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=aa934b13-3397-409e-a191-b09e3c0dba40" />
      </body>
      <title>Basic XAML Framework on CodePlex</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,aa934b13-3397-409e-a191-b09e3c0dba40.aspx</guid>
      <link>http://www.lhotka.net/weblog/BasicXAMLFrameworkOnCodePlex.aspx</link>
      <pubDate>Tue, 08 Jun 2010 18:23:23 GMT</pubDate>
      <description>&lt;p&gt;
Over the past few months I’ve been researching, writing and speaking about MVVM quite
a lot. One of the teaching tools I’ve developed has turned out to be useful for both
teaching and actually building applications. This is the Bxf (Basic XAML Framework)
code I’ve developed.
&lt;/p&gt;
&lt;p&gt;
I must confess, I have little interest in becoming a UI framework author. But I also
recognize that you can’t do any UI pattern like MVVM (or MVC) without some minimal
framework support – there’s just some plumbing code you must have for the pattern
to be actually useful.
&lt;/p&gt;
&lt;p&gt;
Bxf is the minimum set of functionality I’ve been able to identify to support MVVM,
with a couple other key goals:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Support MVVM so a developer only creates a View, ViewModel and Model&lt;/li&gt;
&lt;li&gt;
Same functionality/code in Silverlight and WPF&lt;/li&gt;
&lt;li&gt;
Zero code-behind the XAML – any UI code goes in the viewmodel, and binding/commanding/trigger
actions are used to allow the view to interact with the viewmodel&lt;/li&gt;
&lt;li&gt;
Enable the use of the Visual Studio 2010 XAML designer (“Cider”), most notably the
drag-and-drop data binding support it provides&lt;/li&gt;
&lt;li&gt;
Enable the use of Expression Blend&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I’ve included Bxf in some samples from the Visual Studio 2010 launch and for CSLA
4. But I’ve decided that’s too random, so I created &lt;a href="http://bxf.codeplex.com"&gt;http://bxf.codeplex.com&lt;/a&gt; to
house the code.
&lt;/p&gt;
&lt;p&gt;
My hope is that other people who find Bxf useful might choose to join the project
as contributors and extend it to be more broadly useful. However, I also hope that
the framework remains extremely simple and minimalistic (since there are already several
quite robust and complex frameworks out there for people who need more than a simple
solution can offer).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=aa934b13-3397-409e-a191-b09e3c0dba40" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,aa934b13-3397-409e-a191-b09e3c0dba40.aspx</comments>
      <category>Bxf</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=82310240-f331-4609-b0b4-4f4a468cf634</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,82310240-f331-4609-b0b4-4f4a468cf634.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,82310240-f331-4609-b0b4-4f4a468cf634.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=82310240-f331-4609-b0b4-4f4a468cf634</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am working on a video series discussing the use of the MVVM design pattern, plus
a “zero code-behind” philosophy with CSLA .NET version 4.
</p>
        <p>
I’ve decided to put the intro video out there for free. It is a good video, covering
the basics of the pattern, my approach to the pattern and how a CSLA-based Model works
best in the pattern.
</p>
        <p>
          <a title="http://www.lhotka.net/files/MvvmIntro.wmv" href="http://www.lhotka.net/files/MvvmIntro.wmv">http://www.lhotka.net/files/MvvmIntro.wmv</a>
        </p>
        <p>
The rest of the series will be demo-based, covering the specifics of implementation.
I’ll add another blog post when that’s available for purchase, but I thought I’d get
this intro online now so people can make use of it.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=82310240-f331-4609-b0b4-4f4a468cf634" />
      </body>
      <title>CSLA 4 and MVVM video series</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,82310240-f331-4609-b0b4-4f4a468cf634.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLA4AndMVVMVideoSeries.aspx</link>
      <pubDate>Wed, 02 Jun 2010 18:36:58 GMT</pubDate>
      <description>&lt;p&gt;
I am working on a video series discussing the use of the MVVM design pattern, plus
a “zero code-behind” philosophy with CSLA .NET version 4.
&lt;/p&gt;
&lt;p&gt;
I’ve decided to put the intro video out there for free. It is a good video, covering
the basics of the pattern, my approach to the pattern and how a CSLA-based Model works
best in the pattern.
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.lhotka.net/files/MvvmIntro.wmv" href="http://www.lhotka.net/files/MvvmIntro.wmv"&gt;http://www.lhotka.net/files/MvvmIntro.wmv&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The rest of the series will be demo-based, covering the specifics of implementation.
I’ll add another blog post when that’s available for purchase, but I thought I’d get
this intro online now so people can make use of it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=82310240-f331-4609-b0b4-4f4a468cf634" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,82310240-f331-4609-b0b4-4f4a468cf634.aspx</comments>
      <category>Architecture</category>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=26706644-7e94-431f-872b-a7f9b0d73c7a</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,26706644-7e94-431f-872b-a7f9b0d73c7a.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,26706644-7e94-431f-872b-a7f9b0d73c7a.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=26706644-7e94-431f-872b-a7f9b0d73c7a</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There’s a lot of understandable buzz about the iPad, including <a href="http://chucksblog.emc.com/chucks_blog/2010/05/what-ipads-did-to-my-family.html">this
well-written post</a> that I think conveys something important.
</p>
        <p>
As a Microsoft-oriented technical evangelist I’m now almost constantly asked what
I think of the iPad. I’ve spent perhaps a total of 20 minutes with one, so I’m not
an expert, but I can confidently say that I found it very pleasant to use, and I think
it is a great v1 product.
</p>
        <p>
(as an aside, many people also call it a “Kindle killer”, which I absolutely think
it is NOT. It is too heavy, the screen is shiny and backlit and the battery doesn’t
last 1-2 weeks – it was almost inconceivable to me that anything could replace real
books (but the <a href="http://kindle.amazon.com/">Kindle</a> did), and the iPad certainly
doesn’t compete with real paper or the Kindle)
</p>
        <p>
I think the iPad reveals something very, very important. As does the iPhone, the Android
phones and the upcoming Windows Phone 7: most users don’t need a “computer”. 
</p>
        <p>
Not a computer in the traditional sense, the way we as software designer/developers
think about it.
</p>
        <p>
Given the following:
</p>
        <ul>
          <li>
“Instant” on 
</li>
          <li>
Primarily touch-based UI for the OS 
</li>
          <li>
Apps (and OS) that is designed for touch through and through (and no non-touch apps) 
</li>
          <li>
Light weight 
</li>
          <li>
Good battery life 
</li>
          <li>
Good networking (including home LAN, corporate domain, network printing, etc) 
</li>
          <li>
Portable peripherals, and standard connectors (USB, Firewire, ESATA, etc) 
</li>
          <li>
Docking station capability 
</li>
        </ul>
        <p>
I submit that your typical user <em>doesn’t need a traditional computer</em>. Sure,
there are the “knowledge workers” in accounting, who push computers harder than developers
do, but they aren’t a typical user either.
</p>
        <p>
From what I can see, a typical user spends a lot of time 
</p>
        <ul>
          <li>
reading and composing email 
</li>
          <li>
using specialized line of business apps, mostly doing data entry and data viewing/analysis 
</li>
          <li>
browsing the web 
</li>
          <li>
playing lightweight casual games (solitaire, Flash-based games, etc) 
</li>
          <li>
using consumer apps like birthday card makers 
</li>
          <li>
organizing and viewing pictures and home videos 
</li>
          <li>
creating simple art projects with drawing apps, etc 
</li>
        </ul>
        <p>
None of these things require anything like the new i7 quad core (w/ hyperthreading
– so 8 way) laptop Magenic is rolling out to all its consultants. Most users just
don’t need that kind of horsepower, and would gladly trade it to get better battery
life and more intuitive apps.
</p>
        <p>
Which (finally) brings me to the real point of this post: today’s apps suck (just
ask <a href="http://suckbusters.com/">David Platt</a>).
</p>
        <p>
David talks a lot about why software sucks. But I want to focus on one narrow area:
usability, especially in a world where touch is the primary model, and keyboard/mouse
is secondary.
</p>
        <p>
I have a Windows 7 tablet, which I like quite a lot. But it is far, far, far less
usable than the iPad for most things. Why? It really isn’t because of Windows, which
can be configured to be pretty touch-friendly. It is because of the apps.
</p>
        <p>
Outlook, for example, is absolutely horrible. Trying to click on a message in the
inbox, or worse, trying to click on something in the ribbon – that’s crazy. I’m a
big guy, and I have big fingers. I typically touch the wrong thing more often than
the right thing…
</p>
        <p>
Web browsers are also horrible. Their toolbars are too small as well. But web pages
are as much to blame – all those text links crammed together in tables and lists –
it is nearly impossible to touch the correct link to navigate from page to page. Sure,
I can zoom in and out, but that’s just a pain.
</p>
        <p>
The web page thing is one area where the iPad is just as bad as anything else. It
isn’t the fault of the devices (Windows or iPad), it is the fault of the web page
designers. And it really isn’t <em>their</em> fault either, because their primary
audience is keyboard/mouse computer users…
</p>
        <p>
And that’s the challenge we all face. If the traditional computing form factor is
at its end, and I suspect it is, then we’re in for an interesting ride over the next
5-7 years. I don’t think there’s been as big a user interaction transition since we
moved from green-screen terminals to the Windows GUI keyboard/mouse world. 
</p>
        <p>
Moving to a world that is primarily touch is going to affect every app we build in
pretty fundamental ways. When click targets need to be 2-4 times bigger than they
are today, our beautiful high-resolution screens start to seem terribly cramped. And
these battery-conserving end user devices don’t have that high of resolution to start
with, so that makes space <em>really cramped</em>.
</p>
        <p>
And that means interaction metaphors must change, and UI layouts need to be more dynamic.
That’s the only way to really leverage this limited space and retain usability.
</p>
        <p>
For my part, I think Microsoft is in a great place in this regard. Several years ago
they introduced WPF and XAML, which are awesome tools for addressing these UI requirements.
More recently they streamlined those concepts by creating Silverlight – lighter weight
and more easily deployed, but with the same UI power.
</p>
        <p>
I’d be absolutely shocked if we don’t see some sort of Silverlight-based tablet/slate/pad/whatever
device in the relatively near future. And I’d be shocked if we don’t see the iPad
rapidly evolve based on user feedback.
</p>
        <p>
I really think we’re entering a period of major transition in terms of what it means
to be a “computer user”, and this transition will have a deep impact on how we design
and develop software for these computing appliances/devices.
</p>
        <p>
And it all starts with recognizing that the type of UI we’ve been building since the
early 1990’s is about to become just as obsolete as the green-screen terminal UIs
from the 1980’s.
</p>
        <p>
It took about 5 years for most organizations to transition from green-screen to GUI.
I don’t think the iPad alone is enough to start the next transition, but I think it
is the pebble that will start the avalanche. Once there are other devices (most notably
some Silverlight-based device – in my mind at least), then the real change will start,
because line of business apps will shift, as will consumer apps.
</p>
        <p>
I’m looking forward to the next few years – I think it is going to be a wild ride!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=26706644-7e94-431f-872b-a7f9b0d73c7a" />
      </body>
      <title>A &amp;ldquo;computer free&amp;rdquo; future?</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,26706644-7e94-431f-872b-a7f9b0d73c7a.aspx</guid>
      <link>http://www.lhotka.net/weblog/ALdquocomputerFreerdquoFuture.aspx</link>
      <pubDate>Fri, 07 May 2010 16:16:26 GMT</pubDate>
      <description>&lt;p&gt;
There’s a lot of understandable buzz about the iPad, including &lt;a href="http://chucksblog.emc.com/chucks_blog/2010/05/what-ipads-did-to-my-family.html"&gt;this
well-written post&lt;/a&gt; that I think conveys something important.
&lt;/p&gt;
&lt;p&gt;
As a Microsoft-oriented technical evangelist I’m now almost constantly asked what
I think of the iPad. I’ve spent perhaps a total of 20 minutes with one, so I’m not
an expert, but I can confidently say that I found it very pleasant to use, and I think
it is a great v1 product.
&lt;/p&gt;
&lt;p&gt;
(as an aside, many people also call it a “Kindle killer”, which I absolutely think
it is NOT. It is too heavy, the screen is shiny and backlit and the battery doesn’t
last 1-2 weeks – it was almost inconceivable to me that anything could replace real
books (but the &lt;a href="http://kindle.amazon.com/"&gt;Kindle&lt;/a&gt; did), and the iPad certainly
doesn’t compete with real paper or the Kindle)
&lt;/p&gt;
&lt;p&gt;
I think the iPad reveals something very, very important. As does the iPhone, the Android
phones and the upcoming Windows Phone 7: most users don’t need a “computer”. 
&lt;/p&gt;
&lt;p&gt;
Not a computer in the traditional sense, the way we as software designer/developers
think about it.
&lt;/p&gt;
&lt;p&gt;
Given the following:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
“Instant” on 
&lt;li&gt;
Primarily touch-based UI for the OS 
&lt;li&gt;
Apps (and OS) that is designed for touch through and through (and no non-touch apps) 
&lt;li&gt;
Light weight 
&lt;li&gt;
Good battery life 
&lt;li&gt;
Good networking (including home LAN, corporate domain, network printing, etc) 
&lt;li&gt;
Portable peripherals, and standard connectors (USB, Firewire, ESATA, etc) 
&lt;li&gt;
Docking station capability 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I submit that your typical user &lt;em&gt;doesn’t need a traditional computer&lt;/em&gt;. Sure,
there are the “knowledge workers” in accounting, who push computers harder than developers
do, but they aren’t a typical user either.
&lt;/p&gt;
&lt;p&gt;
From what I can see, a typical user spends a lot of time 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
reading and composing email 
&lt;li&gt;
using specialized line of business apps, mostly doing data entry and data viewing/analysis 
&lt;li&gt;
browsing the web 
&lt;li&gt;
playing lightweight casual games (solitaire, Flash-based games, etc) 
&lt;li&gt;
using consumer apps like birthday card makers 
&lt;li&gt;
organizing and viewing pictures and home videos 
&lt;li&gt;
creating simple art projects with drawing apps, etc 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
None of these things require anything like the new i7 quad core (w/ hyperthreading
– so 8 way) laptop Magenic is rolling out to all its consultants. Most users just
don’t need that kind of horsepower, and would gladly trade it to get better battery
life and more intuitive apps.
&lt;/p&gt;
&lt;p&gt;
Which (finally) brings me to the real point of this post: today’s apps suck (just
ask &lt;a href="http://suckbusters.com/"&gt;David Platt&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
David talks a lot about why software sucks. But I want to focus on one narrow area:
usability, especially in a world where touch is the primary model, and keyboard/mouse
is secondary.
&lt;/p&gt;
&lt;p&gt;
I have a Windows 7 tablet, which I like quite a lot. But it is far, far, far less
usable than the iPad for most things. Why? It really isn’t because of Windows, which
can be configured to be pretty touch-friendly. It is because of the apps.
&lt;/p&gt;
&lt;p&gt;
Outlook, for example, is absolutely horrible. Trying to click on a message in the
inbox, or worse, trying to click on something in the ribbon – that’s crazy. I’m a
big guy, and I have big fingers. I typically touch the wrong thing more often than
the right thing…
&lt;/p&gt;
&lt;p&gt;
Web browsers are also horrible. Their toolbars are too small as well. But web pages
are as much to blame – all those text links crammed together in tables and lists –
it is nearly impossible to touch the correct link to navigate from page to page. Sure,
I can zoom in and out, but that’s just a pain.
&lt;/p&gt;
&lt;p&gt;
The web page thing is one area where the iPad is just as bad as anything else. It
isn’t the fault of the devices (Windows or iPad), it is the fault of the web page
designers. And it really isn’t &lt;em&gt;their&lt;/em&gt; fault either, because their primary
audience is keyboard/mouse computer users…
&lt;/p&gt;
&lt;p&gt;
And that’s the challenge we all face. If the traditional computing form factor is
at its end, and I suspect it is, then we’re in for an interesting ride over the next
5-7 years. I don’t think there’s been as big a user interaction transition since we
moved from green-screen terminals to the Windows GUI keyboard/mouse world. 
&lt;/p&gt;
&lt;p&gt;
Moving to a world that is primarily touch is going to affect every app we build in
pretty fundamental ways. When click targets need to be 2-4 times bigger than they
are today, our beautiful high-resolution screens start to seem terribly cramped. And
these battery-conserving end user devices don’t have that high of resolution to start
with, so that makes space &lt;em&gt;really cramped&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
And that means interaction metaphors must change, and UI layouts need to be more dynamic.
That’s the only way to really leverage this limited space and retain usability.
&lt;/p&gt;
&lt;p&gt;
For my part, I think Microsoft is in a great place in this regard. Several years ago
they introduced WPF and XAML, which are awesome tools for addressing these UI requirements.
More recently they streamlined those concepts by creating Silverlight – lighter weight
and more easily deployed, but with the same UI power.
&lt;/p&gt;
&lt;p&gt;
I’d be absolutely shocked if we don’t see some sort of Silverlight-based tablet/slate/pad/whatever
device in the relatively near future. And I’d be shocked if we don’t see the iPad
rapidly evolve based on user feedback.
&lt;/p&gt;
&lt;p&gt;
I really think we’re entering a period of major transition in terms of what it means
to be a “computer user”, and this transition will have a deep impact on how we design
and develop software for these computing appliances/devices.
&lt;/p&gt;
&lt;p&gt;
And it all starts with recognizing that the type of UI we’ve been building since the
early 1990’s is about to become just as obsolete as the green-screen terminal UIs
from the 1980’s.
&lt;/p&gt;
&lt;p&gt;
It took about 5 years for most organizations to transition from green-screen to GUI.
I don’t think the iPad alone is enough to start the next transition, but I think it
is the pebble that will start the avalanche. Once there are other devices (most notably
some Silverlight-based device – in my mind at least), then the real change will start,
because line of business apps will shift, as will consumer apps.
&lt;/p&gt;
&lt;p&gt;
I’m looking forward to the next few years – I think it is going to be a wild ride!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=26706644-7e94-431f-872b-a7f9b0d73c7a" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,26706644-7e94-431f-872b-a7f9b0d73c7a.aspx</comments>
      <category>Architecture</category>
      <category>Programming</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=2738e3d0-f180-4ccf-9019-c3b7ea0c98c5</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,2738e3d0-f180-4ccf-9019-c3b7ea0c98c5.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,2738e3d0-f180-4ccf-9019-c3b7ea0c98c5.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2738e3d0-f180-4ccf-9019-c3b7ea0c98c5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have put the demos from my Visual Studio 2010 launch talks online:
</p>
        <p>
          <a href="http://www.lhotka.net/files/devconn/VS2010Launch.zip">http://www.lhotka.net/files/devconn/VS2010Launch.zip</a>
        </p>
        <p>
BasicVM and LiveDemo are literally the code I created on stage, so they are nothing
to look at and probably have little value if you weren’t at the talks. The other demos
are more complete and may be useful – especially UsingBxf, which shows some interesting
UI proto-framework concepts in a pretty straightforward manner.
</p>
        <h3>BasicVM
</h3>
        <p>
Demo created on stage to illustrate the most basic MVVM concepts.
</p>
        <h3>Collective
</h3>
        <p>
Demo/prototype of a knowledge base/forum application that makes use of a pre-release
version of CSLA 4, MVVM and other Silverlight concepts. It is a 3-tier physical deployment
(Silverlight client, web/app server, SQL Server database) architecture using many
CSLA .NET concepts.
</p>
        <p>
This code uses the Bxf (“Basic XAML Framework”) to implement its shell and viewmodel
code in a way that can be unit tested.
</p>
        <p>
This project has a dependency on a pre-release version of <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA
4</a>.
</p>
        <h3>LiveDemo
</h3>
        <p>
Demo created on stage to illustrate the basic use of the Visual Studio 2010 XAML designer.
</p>
        <h3>UsingBxf
</h3>
        <p>
Demo showing simple use of the “Basic XAML Framework” (Bxf) in WPF. The same Bxf code
works in Silverlight as well. The Bxf code and this demo show how to implement a basic
UI shell that shows content and a status bar. For more advanced uses of Bxf see the
Collective demo.
</p>
        <p>
This project has a dependency on a pre-release version of <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA
4</a>.
</p>
        <h3>VSL01
</h3>
        <p>
Demo showing some concepts and implementation around MVVM.
</p>
        <h3>VSL02
</h3>
        <p>
Demo showing some concepts and implementation around MVVM.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2738e3d0-f180-4ccf-9019-c3b7ea0c98c5" />
      </body>
      <title>Visual Studio 2010 launch demos</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,2738e3d0-f180-4ccf-9019-c3b7ea0c98c5.aspx</guid>
      <link>http://www.lhotka.net/weblog/VisualStudio2010LaunchDemos.aspx</link>
      <pubDate>Mon, 19 Apr 2010 14:59:44 GMT</pubDate>
      <description>&lt;p&gt;
I have put the demos from my Visual Studio 2010 launch talks online:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/files/devconn/VS2010Launch.zip"&gt;http://www.lhotka.net/files/devconn/VS2010Launch.zip&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
BasicVM and LiveDemo are literally the code I created on stage, so they are nothing
to look at and probably have little value if you weren’t at the talks. The other demos
are more complete and may be useful – especially UsingBxf, which shows some interesting
UI proto-framework concepts in a pretty straightforward manner.
&lt;/p&gt;
&lt;h3&gt;BasicVM
&lt;/h3&gt;
&lt;p&gt;
Demo created on stage to illustrate the most basic MVVM concepts.
&lt;/p&gt;
&lt;h3&gt;Collective
&lt;/h3&gt;
&lt;p&gt;
Demo/prototype of a knowledge base/forum application that makes use of a pre-release
version of CSLA 4, MVVM and other Silverlight concepts. It is a 3-tier physical deployment
(Silverlight client, web/app server, SQL Server database) architecture using many
CSLA .NET concepts.
&lt;/p&gt;
&lt;p&gt;
This code uses the Bxf (“Basic XAML Framework”) to implement its shell and viewmodel
code in a way that can be unit tested.
&lt;/p&gt;
&lt;p&gt;
This project has a dependency on a pre-release version of &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA
4&lt;/a&gt;.
&lt;/p&gt;
&lt;h3&gt;LiveDemo
&lt;/h3&gt;
&lt;p&gt;
Demo created on stage to illustrate the basic use of the Visual Studio 2010 XAML designer.
&lt;/p&gt;
&lt;h3&gt;UsingBxf
&lt;/h3&gt;
&lt;p&gt;
Demo showing simple use of the “Basic XAML Framework” (Bxf) in WPF. The same Bxf code
works in Silverlight as well. The Bxf code and this demo show how to implement a basic
UI shell that shows content and a status bar. For more advanced uses of Bxf see the
Collective demo.
&lt;/p&gt;
&lt;p&gt;
This project has a dependency on a pre-release version of &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA
4&lt;/a&gt;.
&lt;/p&gt;
&lt;h3&gt;VSL01
&lt;/h3&gt;
&lt;p&gt;
Demo showing some concepts and implementation around MVVM.
&lt;/p&gt;
&lt;h3&gt;VSL02
&lt;/h3&gt;
&lt;p&gt;
Demo showing some concepts and implementation around MVVM.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2738e3d0-f180-4ccf-9019-c3b7ea0c98c5" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,2738e3d0-f180-4ccf-9019-c3b7ea0c98c5.aspx</comments>
      <category>CSLA .NET</category>
      <category>Microsoft .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=09a82d6f-3955-4929-bdac-9d3480149a76</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,09a82d6f-3955-4929-bdac-9d3480149a76.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,09a82d6f-3955-4929-bdac-9d3480149a76.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=09a82d6f-3955-4929-bdac-9d3480149a76</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have an app that uses the SL4 RichTextBox control. It is a nice control, and I’ve
been enjoying using it. I even went so far as to convert thousands of rows of HTML
to Xaml in my database for use with the RTB.
</p>
        <p>
But the control has a couple changes in the new release candidate that I’m having
to work around – and if they are not bugs then I’ll have to write a little app to
clean the data in my database.
</p>
        <p>
Prior to the RC the minimum value you could set to the Xaml property was “&lt;Section
/&gt;”. This was (and is) a pain, because it won’t accept null or string.Empty – so
if your actual value is null you need to detect that and change it before trying to
set the Xaml property.
</p>
        <p>
But in the RC the minimum value is now “&lt;Section xmlns=\"<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation\&quot;/">http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/</a>&gt;”.
Not a huge change, but it broke my app of course.
</p>
        <p>
The bigger issue is that prior to the RC the RTB allowed the TextDecorations attribute
on the &lt;Section&gt; element. And in fact it <em>generated this attribute</em> when
it created Xaml.
</p>
        <p>
In the RC the TextDecorations attribute is no longer valid. It isn’t generated, but
more importantly it isn’t allowed, so all my Xaml data is invalid.
</p>
        <p>
This is a bit of code that fixes both issues:
</p>
        <blockquote>
          <p>
string xaml; 
<br />
if (e.NewValue == null) 
<br />
  xaml = string.Empty; 
<br />
else 
<br />
  xaml = e.NewValue.ToString(); 
<br />
// RTB won't accept an empty string, so if the value is empty/null 
<br />
// replace it with the minumum necessary Xaml 
<br />
if (string.IsNullOrWhiteSpace(xaml)) 
<br />
  xaml = "&lt;Section xmlns=\"<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation\&quot;/">http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/</a>&gt;"; 
<br />
// RTB used to support TextDecorations, but now doesn't, so that value 
<br />
// must be removed to avoid a crash 
<br />
var pos = xaml.IndexOf(" TextDecorations="); 
<br />
if (pos &gt;= 0) 
<br />
{ 
<br />
  var closeQuote = xaml.IndexOf("\"", pos); 
<br />
  closeQuote = xaml.IndexOf("\"", closeQuote + 1); 
<br />
  xaml = xaml.Remove(pos, closeQuote - pos + 1); 
<br />
} 
<br />
return xaml;
</p>
        </blockquote>
        <p>
In this case e.NewValue is the Xaml text I’m hoping to put into the control, and the
xaml field ends up holding the corrected result.
</p>
        <p>
I’m sure other people moving from the beta to the RC will encounter this same issue.
I’m rather hopeful that the TextDecorations thing is a bug so I don’t have to fix
all my data, but I suspect it is an intentional breaking change…
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=09a82d6f-3955-4929-bdac-9d3480149a76" />
      </body>
      <title>Silverlight 4 RC RichTextBox changes</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,09a82d6f-3955-4929-bdac-9d3480149a76.aspx</guid>
      <link>http://www.lhotka.net/weblog/Silverlight4RCRichTextBoxChanges.aspx</link>
      <pubDate>Fri, 19 Mar 2010 01:25:40 GMT</pubDate>
      <description>&lt;p&gt;
I have an app that uses the SL4 RichTextBox control. It is a nice control, and I’ve
been enjoying using it. I even went so far as to convert thousands of rows of HTML
to Xaml in my database for use with the RTB.
&lt;/p&gt;
&lt;p&gt;
But the control has a couple changes in the new release candidate that I’m having
to work around – and if they are not bugs then I’ll have to write a little app to
clean the data in my database.
&lt;/p&gt;
&lt;p&gt;
Prior to the RC the minimum value you could set to the Xaml property was “&amp;lt;Section
/&amp;gt;”. This was (and is) a pain, because it won’t accept null or string.Empty – so
if your actual value is null you need to detect that and change it before trying to
set the Xaml property.
&lt;/p&gt;
&lt;p&gt;
But in the RC the minimum value is now “&amp;lt;Section xmlns=\&amp;quot;&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation\&amp;quot;/"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation\&amp;quot;/&lt;/a&gt;&amp;gt;”.
Not a huge change, but it broke my app of course.
&lt;/p&gt;
&lt;p&gt;
The bigger issue is that prior to the RC the RTB allowed the TextDecorations attribute
on the &amp;lt;Section&amp;gt; element. And in fact it &lt;em&gt;generated this attribute&lt;/em&gt; when
it created Xaml.
&lt;/p&gt;
&lt;p&gt;
In the RC the TextDecorations attribute is no longer valid. It isn’t generated, but
more importantly it isn’t allowed, so all my Xaml data is invalid.
&lt;/p&gt;
&lt;p&gt;
This is a bit of code that fixes both issues:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
string xaml; 
&lt;br /&gt;
if (e.NewValue == null) 
&lt;br /&gt;
&amp;#160; xaml = string.Empty; 
&lt;br /&gt;
else 
&lt;br /&gt;
&amp;#160; xaml = e.NewValue.ToString(); 
&lt;br /&gt;
// RTB won't accept an empty string, so if the value is empty/null 
&lt;br /&gt;
// replace it with the minumum necessary Xaml 
&lt;br /&gt;
if (string.IsNullOrWhiteSpace(xaml)) 
&lt;br /&gt;
&amp;#160; xaml = &amp;quot;&amp;lt;Section xmlns=\&amp;quot;&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation\&amp;quot;/"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation\&amp;quot;/&lt;/a&gt;&amp;gt;&amp;quot;; 
&lt;br /&gt;
// RTB used to support TextDecorations, but now doesn't, so that value 
&lt;br /&gt;
// must be removed to avoid a crash 
&lt;br /&gt;
var pos = xaml.IndexOf(&amp;quot; TextDecorations=&amp;quot;); 
&lt;br /&gt;
if (pos &amp;gt;= 0) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; var closeQuote = xaml.IndexOf(&amp;quot;\&amp;quot;&amp;quot;, pos); 
&lt;br /&gt;
&amp;#160; closeQuote = xaml.IndexOf(&amp;quot;\&amp;quot;&amp;quot;, closeQuote + 1); 
&lt;br /&gt;
&amp;#160; xaml = xaml.Remove(pos, closeQuote - pos + 1); 
&lt;br /&gt;
} 
&lt;br /&gt;
return xaml;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
In this case e.NewValue is the Xaml text I’m hoping to put into the control, and the
xaml field ends up holding the corrected result.
&lt;/p&gt;
&lt;p&gt;
I’m sure other people moving from the beta to the RC will encounter this same issue.
I’m rather hopeful that the TextDecorations thing is a bug so I don’t have to fix
all my data, but I suspect it is an intentional breaking change…
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=09a82d6f-3955-4929-bdac-9d3480149a76" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,09a82d6f-3955-4929-bdac-9d3480149a76.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=7febc10b-ce01-4404-897f-8cee69d22321</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,7febc10b-ce01-4404-897f-8cee69d22321.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,7febc10b-ce01-4404-897f-8cee69d22321.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=7febc10b-ce01-4404-897f-8cee69d22321</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
 <a href="http://chicagosilverlight.eventbrite.com/">The Silverlight User Group
- Eventbrite</a></p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=7febc10b-ce01-4404-897f-8cee69d22321" />
      </body>
      <title>New Chicago Silverlight User Group</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,7febc10b-ce01-4404-897f-8cee69d22321.aspx</guid>
      <link>http://www.lhotka.net/weblog/NewChicagoSilverlightUserGroup.aspx</link>
      <pubDate>Mon, 01 Mar 2010 21:04:57 GMT</pubDate>
      <description>&lt;p&gt;
&amp;#160;&lt;a href="http://chicagosilverlight.eventbrite.com/"&gt;The Silverlight User Group
- Eventbrite&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=7febc10b-ce01-4404-897f-8cee69d22321" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,7febc10b-ce01-4404-897f-8cee69d22321.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Joost van Schaik spent some time figuring out how to get CSLA .NET 3.8.2 to work with
Silverlight 4 – which takes a little effort because SL4 changes the way WCF proxies
are referenced in the client config file. It is such an odd change that I rather suspect
it might be a bug in SL4, but I guess we’ll see what happens as it gets closer to
release.
</p>
        <p>
He also wrote a nice blog post summarizing the steps required, which will probably
be useful to a number of people: 
</p>
        <p>
          <a href="http://dotnetbyexample.blogspot.com/2010/03/running-cslalight-382-under-net-4-and.html">.NET
by Example: Running CSLALight 3.8.2 under .NET 4 and Silverlight 4</a>
        </p>
        <p>
Thank you Joost!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7" />
      </body>
      <title>Running CSLA .NET 3.8.2 under .NET 4 and Silverlight 4</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7.aspx</guid>
      <link>http://www.lhotka.net/weblog/RunningCSLANET382UnderNET4AndSilverlight4.aspx</link>
      <pubDate>Mon, 01 Mar 2010 21:01:48 GMT</pubDate>
      <description>&lt;p&gt;
Joost van Schaik spent some time figuring out how to get CSLA .NET 3.8.2 to work with
Silverlight 4 – which takes a little effort because SL4 changes the way WCF proxies
are referenced in the client config file. It is such an odd change that I rather suspect
it might be a bug in SL4, but I guess we’ll see what happens as it gets closer to
release.
&lt;/p&gt;
&lt;p&gt;
He also wrote a nice blog post summarizing the steps required, which will probably
be useful to a number of people: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://dotnetbyexample.blogspot.com/2010/03/running-cslalight-382-under-net-4-and.html"&gt;.NET
by Example: Running CSLALight 3.8.2 under .NET 4 and Silverlight 4&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Thank you Joost!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,d4f667fb-e1e5-4bdf-996f-6ecc93a5b1d7.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=c9e390f7-3153-4538-ba36-6e56dfd94699</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,c9e390f7-3153-4538-ba36-6e56dfd94699.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,c9e390f7-3153-4538-ba36-6e56dfd94699.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=c9e390f7-3153-4538-ba36-6e56dfd94699</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Continuing on my quest to use the Visual Studio 2010 XAML designer, MVVM and absolutely
no code behind, I ran into the common problem of setting focus to a control as a form
loads.
</p>
        <p>
This is easily accomplished using code-behind:
</p>
        <blockquote>
          <p>
firstControl.Focus();
</p>
        </blockquote>
        <p>
But of course that requires <em>code-behind</em>, which I believe should be unnecessary.
</p>
        <p>
It can also be accomplished by creating an attached property or (with the Blend 3
SDK) trigger action or behavior. Neither of these are great with the VS10 designer
though, because the designer has no way to apply attached properties and doesn’t know
about the Blend 3 SDK concepts.
</p>
        <p>
So while those solutions are fine, they require manual typing of XAML, which I believe
should be unnecessary (as unrealistic as that view might be…).
</p>
        <p>
My solution is to create a FrameworkElement called SetFocus. This shows up in the
Toolbox and so can be dragged directly onto the form using the designer. The SetFocus
control has no visual aspect, so it doesn’t interfere with the layout or look of the
form. Once SetFocus is on the form, the Properties window can be used to set its TargetProperty
property, indicating the property that should get focus when the form is loaded.
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/SettingfocusinXAMLwithnocode_A042/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 10px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/SettingfocusinXAMLwithnocode_A042/image_thumb.png" width="240" height="133" />
          </a>
        </p>
        <p>
This requires no code-behind and no manual typing of XAML. It keeps the concept of
startup focus completely in the view, which (I think) is a good place for it. So my
viewmodel doesn’t know or care about this issue. And the same control works in Silverlight
and WPF, which should be the goal for any good XAML control.
</p>
        <p>
Here’s the code:
</p>
        <p>
using System; 
<br />
using System.Windows; 
<br />
using System.Windows.Controls; 
<br />
using System.ComponentModel; 
</p>
        <p>
namespace Collective.Controls 
<br />
{ 
<br />
  /// &lt;summary&gt; 
<br />
  /// Sets the focus to the TargetControl property as the 
<br />
  /// form is loaded. 
<br />
  /// &lt;/summary&gt; 
<br />
  public class SetFocus : FrameworkElement 
<br />
  { 
<br />
    /// &lt;summary&gt; 
<br />
    /// Gets or sets the target UI control. 
<br />
    /// &lt;/summary&gt; 
<br />
    public static readonly DependencyProperty TargetControlProperty
= 
<br />
      DependencyProperty.Register("TargetControl",
typeof(Control), 
<br />
      typeof(SetFocus), new PropertyMetadata((o, e) =&gt; 
<br />
      { 
<br />
        var sf = o as SetFocus; 
<br />
        if (sf != null &amp;&amp; sf.TargetControl
!= null) 
<br />
          sf.TargetControl.Focus(); 
<br />
      })); 
<br />
    /// &lt;summary&gt; 
<br />
    /// Gets or sets the target UI control. 
<br />
    /// &lt;/summary&gt; 
<br />
    [Category("Common")] 
<br />
    public Control TargetControl 
<br />
    { 
<br />
      get { return (Control)GetValue(TargetControlProperty);
} 
<br />
      set { SetValue(TargetControlProperty, value); } 
<br />
    } 
<br />
  } 
<br />
}
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c9e390f7-3153-4538-ba36-6e56dfd94699" />
      </body>
      <title>Setting focus in XAML with no code</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,c9e390f7-3153-4538-ba36-6e56dfd94699.aspx</guid>
      <link>http://www.lhotka.net/weblog/SettingFocusInXAMLWithNoCode.aspx</link>
      <pubDate>Fri, 26 Feb 2010 17:25:09 GMT</pubDate>
      <description>&lt;p&gt;
Continuing on my quest to use the Visual Studio 2010 XAML designer, MVVM and absolutely
no code behind, I ran into the common problem of setting focus to a control as a form
loads.
&lt;/p&gt;
&lt;p&gt;
This is easily accomplished using code-behind:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
firstControl.Focus();
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
But of course that requires &lt;em&gt;code-behind&lt;/em&gt;, which I believe should be unnecessary.
&lt;/p&gt;
&lt;p&gt;
It can also be accomplished by creating an attached property or (with the Blend 3
SDK) trigger action or behavior. Neither of these are great with the VS10 designer
though, because the designer has no way to apply attached properties and doesn’t know
about the Blend 3 SDK concepts.
&lt;/p&gt;
&lt;p&gt;
So while those solutions are fine, they require manual typing of XAML, which I believe
should be unnecessary (as unrealistic as that view might be…).
&lt;/p&gt;
&lt;p&gt;
My solution is to create a FrameworkElement called SetFocus. This shows up in the
Toolbox and so can be dragged directly onto the form using the designer. The SetFocus
control has no visual aspect, so it doesn’t interfere with the layout or look of the
form. Once SetFocus is on the form, the Properties window can be used to set its TargetProperty
property, indicating the property that should get focus when the form is loaded.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/SettingfocusinXAMLwithnocode_A042/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 10px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/SettingfocusinXAMLwithnocode_A042/image_thumb.png" width="240" height="133" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
This requires no code-behind and no manual typing of XAML. It keeps the concept of
startup focus completely in the view, which (I think) is a good place for it. So my
viewmodel doesn’t know or care about this issue. And the same control works in Silverlight
and WPF, which should be the goal for any good XAML control.
&lt;/p&gt;
&lt;p&gt;
Here’s the code:
&lt;/p&gt;
&lt;p&gt;
using System; 
&lt;br /&gt;
using System.Windows; 
&lt;br /&gt;
using System.Windows.Controls; 
&lt;br /&gt;
using System.ComponentModel; 
&lt;/p&gt;
&lt;p&gt;
namespace Collective.Controls 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; /// &amp;lt;summary&amp;gt; 
&lt;br /&gt;
&amp;#160; /// Sets the focus to the TargetControl property as the 
&lt;br /&gt;
&amp;#160; /// form is loaded. 
&lt;br /&gt;
&amp;#160; /// &amp;lt;/summary&amp;gt; 
&lt;br /&gt;
&amp;#160; public class SetFocus : FrameworkElement 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the target UI control. 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; public static readonly DependencyProperty TargetControlProperty
= 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DependencyProperty.Register(&amp;quot;TargetControl&amp;quot;,
typeof(Control), 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; typeof(SetFocus), new PropertyMetadata((o, e) =&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var sf = o as SetFocus; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (sf != null &amp;amp;&amp;amp; sf.TargetControl
!= null) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sf.TargetControl.Focus(); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the target UI control. 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; [Category(&amp;quot;Common&amp;quot;)] 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; public Control TargetControl 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (Control)GetValue(TargetControlProperty);
} 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { SetValue(TargetControlProperty, value); } 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; } 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c9e390f7-3153-4538-ba36-6e56dfd94699" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,c9e390f7-3153-4538-ba36-6e56dfd94699.aspx</comments>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=286b4a9a-23cd-4a85-9290-92bd9028f921</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,286b4a9a-23cd-4a85-9290-92bd9028f921.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,286b4a9a-23cd-4a85-9290-92bd9028f921.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=286b4a9a-23cd-4a85-9290-92bd9028f921</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As noted in a previous post, I’ve been spending some quality time with the new VS10
XAML designer. It is fun, but challenging to figure out how the designer wants everything
to work, and to adapt existing CSLA .NET components to work smoothly in the new environment.
</p>
        <p>
Yesterday I spent a substantial amount of time trying to get PropertyStatus, InvokeMethod
and Execute to work nicely. These three controls have one thing in common: they all
interact <em>directly with the real data object</em>. InvokeMethod and Execute both
invoke methods on the data object (usually a viewmodel), and PropertyStatus reads
property-specific metadata about a property, such as whether the property has any
info/warning/error messages that the user should see.
</p>
        <p>
The VS10 designer uses something called a CollectionViewSource as its primary binding
target. When you drag-and-drop a type from the Data Sources window onto your form,
the designer creates a CVS resource in the form and uses that as the DataContext for
your UI elements. In this regard it is not entirely unlike a data provider control
in WPF, though it is certainly not a data provider control.
</p>
        <p>
If you are using a viewmodel (and I am), then your DataContext is actually a hierarchy
of object instances.
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/Willtherealdataobjectstandup_CEA6/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/Willtherealdataobjectstandup_CEA6/image_thumb.png" width="240" height="92" />
          </a>
        </p>
        <p>
This is made slightly more complex when you realize that the Source property of a
CollectionViewSource can only be a list. So really the CVS contains a list of viewmodel
objects – but in my case that list has only one item.
</p>
        <p>
InvokeMethod and Execute both need access to the viewmodel – that’s the object containing
the methods to be invoked. PropertyStatus actually needs access to the Model (the
real business object), because that’s the object where the business properties and
associated metadata are actually implemented.
</p>
        <p>
None of this would be that complex, except that the VS10 designer sets the DataContext
to the CVS, and then uses currency to make one item in the Source property “current”.
But if you, in code, get access to the DataContext for a control you get the CVS.
If you get a BindingExpression object for a given binding, the DataItem is the <em>current
item in the CVS</em>, which turns out to <em>not be the viewmodel</em>. Instead the
DataItem on a binding is an internal type within .NET.
</p>
        <p>
And this is what had me stuck. The CVS has no CurrentItem property, but this internal
type does. However (short of reflection), there’s no way to interact with members
of an internal type. What to do? Thanks to help from Mark Boulter I now know that
this internal type implements the public ICollectionView interface, and that interface
does have a CurrentItem property.
</p>
        <p>
Whew!
</p>
        <p>
What this means is that in InvokeMethod and Execute, I can take the associated UI
control (like a Button or something) and use it to find the viewmodel:
</p>
        <blockquote>
          <p>
public static object GetTarget(UIElement ctrl) 
<br />
{ 
<br />
  object result = null; 
<br />
  result = ctrl.GetValue(TargetProperty); 
<br />
  if (result == null) 
<br />
  { 
<br />
    var fe = ctrl as FrameworkElement; 
<br />
    if (fe != null) 
<br />
      result = fe.DataContext; 
<br />
  } 
<br /><strong>  var icv = result as ICollectionView; 
<br />
  if (icv != null) 
<br />
    result = icv.CurrentItem; 
<br /></strong>  return result; 
<br />
} 
</p>
        </blockquote>
        <p>
This basically takes the DataContext value, sees if it is an ICollectionView, and
if so it returns the CurrentItem – which is the real data object, or at least the
viewmodel.
</p>
        <p>
PropertyStatus is a little more complex, because it has to trace down to the actual
underlying business object, and if so it needs to dereference elements of the property
name path. For example, the property name might be Name, or it might be Model.Name.
If it is Name, the assumption is that CurrentItem is the actual data object. If it
is something like Model.Name, the assumption is that PropertyStatus needs to use the
Name property on the object referenced by the Model property. The code actually goes
n levels like this, allowing for access deep into hierarchical object graphs.
</p>
        <blockquote>
          <p>
private object GetRealSource(object source, string bindingPath) 
<br />
{ 
<br /><strong>  var icv = source as ICollectionView; 
<br />
  if (icv != null) 
<br />
    source = icv.CurrentItem; 
<br /></strong>  if (source != null &amp;&amp; bindingPath.IndexOf('.') &gt; 0) 
<br />
  { 
<br />
    var firstProperty = bindingPath.Substring(0, bindingPath.IndexOf('.')); 
<br />
    var p = MethodCaller.GetProperty(source.GetType(), firstProperty); 
<br />
    return GetRealSource( 
<br />
      MethodCaller.GetPropertyValue(source, p), 
<br />
      bindingPath.Substring(bindingPath.IndexOf('.') + 1)); 
<br />
  } 
<br />
  else 
<br />
    return source; 
<br />
} 
</p>
        </blockquote>
        <p>
Again, if the source is an ICollectionView, the code skips right to the CurrentItem
property, which is the first “real” object worth using.
</p>
        <p>
I suppose writing controls that interact with the real data object isn’t something
people do every day, but if you end up writing such a control hopefully this blog
post will help save you some time and frustration.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=286b4a9a-23cd-4a85-9290-92bd9028f921" />
      </body>
      <title>Will the real data object stand up?</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,286b4a9a-23cd-4a85-9290-92bd9028f921.aspx</guid>
      <link>http://www.lhotka.net/weblog/WillTheRealDataObjectStandUp.aspx</link>
      <pubDate>Fri, 19 Feb 2010 20:42:23 GMT</pubDate>
      <description>&lt;p&gt;
As noted in a previous post, I’ve been spending some quality time with the new VS10
XAML designer. It is fun, but challenging to figure out how the designer wants everything
to work, and to adapt existing CSLA .NET components to work smoothly in the new environment.
&lt;/p&gt;
&lt;p&gt;
Yesterday I spent a substantial amount of time trying to get PropertyStatus, InvokeMethod
and Execute to work nicely. These three controls have one thing in common: they all
interact &lt;em&gt;directly with the real data object&lt;/em&gt;. InvokeMethod and Execute both
invoke methods on the data object (usually a viewmodel), and PropertyStatus reads
property-specific metadata about a property, such as whether the property has any
info/warning/error messages that the user should see.
&lt;/p&gt;
&lt;p&gt;
The VS10 designer uses something called a CollectionViewSource as its primary binding
target. When you drag-and-drop a type from the Data Sources window onto your form,
the designer creates a CVS resource in the form and uses that as the DataContext for
your UI elements. In this regard it is not entirely unlike a data provider control
in WPF, though it is certainly not a data provider control.
&lt;/p&gt;
&lt;p&gt;
If you are using a viewmodel (and I am), then your DataContext is actually a hierarchy
of object instances.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/Willtherealdataobjectstandup_CEA6/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/Willtherealdataobjectstandup_CEA6/image_thumb.png" width="240" height="92" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
This is made slightly more complex when you realize that the Source property of a
CollectionViewSource can only be a list. So really the CVS contains a list of viewmodel
objects – but in my case that list has only one item.
&lt;/p&gt;
&lt;p&gt;
InvokeMethod and Execute both need access to the viewmodel – that’s the object containing
the methods to be invoked. PropertyStatus actually needs access to the Model (the
real business object), because that’s the object where the business properties and
associated metadata are actually implemented.
&lt;/p&gt;
&lt;p&gt;
None of this would be that complex, except that the VS10 designer sets the DataContext
to the CVS, and then uses currency to make one item in the Source property “current”.
But if you, in code, get access to the DataContext for a control you get the CVS.
If you get a BindingExpression object for a given binding, the DataItem is the &lt;em&gt;current
item in the CVS&lt;/em&gt;, which turns out to &lt;em&gt;not be the viewmodel&lt;/em&gt;. Instead the
DataItem on a binding is an internal type within .NET.
&lt;/p&gt;
&lt;p&gt;
And this is what had me stuck. The CVS has no CurrentItem property, but this internal
type does. However (short of reflection), there’s no way to interact with members
of an internal type. What to do? Thanks to help from Mark Boulter I now know that
this internal type implements the public ICollectionView interface, and that interface
does have a CurrentItem property.
&lt;/p&gt;
&lt;p&gt;
Whew!
&lt;/p&gt;
&lt;p&gt;
What this means is that in InvokeMethod and Execute, I can take the associated UI
control (like a Button or something) and use it to find the viewmodel:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public static object GetTarget(UIElement ctrl) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; object result = null; 
&lt;br /&gt;
&amp;#160; result = ctrl.GetValue(TargetProperty); 
&lt;br /&gt;
&amp;#160; if (result == null) 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var fe = ctrl as FrameworkElement; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; if (fe != null) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; result = fe.DataContext; 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
&lt;strong&gt;&amp;#160; var icv = result as ICollectionView; 
&lt;br /&gt;
&amp;#160; if (icv != null) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; result = icv.CurrentItem; 
&lt;br /&gt;
&lt;/strong&gt;&amp;#160; return result; 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This basically takes the DataContext value, sees if it is an ICollectionView, and
if so it returns the CurrentItem – which is the real data object, or at least the
viewmodel.
&lt;/p&gt;
&lt;p&gt;
PropertyStatus is a little more complex, because it has to trace down to the actual
underlying business object, and if so it needs to dereference elements of the property
name path. For example, the property name might be Name, or it might be Model.Name.
If it is Name, the assumption is that CurrentItem is the actual data object. If it
is something like Model.Name, the assumption is that PropertyStatus needs to use the
Name property on the object referenced by the Model property. The code actually goes
n levels like this, allowing for access deep into hierarchical object graphs.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
private object GetRealSource(object source, string bindingPath) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&lt;strong&gt;&amp;#160; var icv = source as ICollectionView; 
&lt;br /&gt;
&amp;#160; if (icv != null) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; source = icv.CurrentItem; 
&lt;br /&gt;
&lt;/strong&gt;&amp;#160; if (source != null &amp;amp;&amp;amp; bindingPath.IndexOf('.') &amp;gt; 0) 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var firstProperty = bindingPath.Substring(0, bindingPath.IndexOf('.')); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var p = MethodCaller.GetProperty(source.GetType(), firstProperty); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; return GetRealSource( 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MethodCaller.GetPropertyValue(source, p), 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bindingPath.Substring(bindingPath.IndexOf('.') + 1)); 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
&amp;#160; else 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; return source; 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Again, if the source is an ICollectionView, the code skips right to the CurrentItem
property, which is the first “real” object worth using.
&lt;/p&gt;
&lt;p&gt;
I suppose writing controls that interact with the real data object isn’t something
people do every day, but if you end up writing such a control hopefully this blog
post will help save you some time and frustration.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=286b4a9a-23cd-4a85-9290-92bd9028f921" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,286b4a9a-23cd-4a85-9290-92bd9028f921.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=1f0188a5-b346-4187-a4c6-5c71ac01c779</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,1f0188a5-b346-4187-a4c6-5c71ac01c779.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,1f0188a5-b346-4187-a4c6-5c71ac01c779.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=1f0188a5-b346-4187-a4c6-5c71ac01c779</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
OK, this is cool. Magenic is running a <a href="http://magenic.com/Default.aspx?tabid=1835">Silverlight/WPF
development contest</a>, open to anyone. The primary prizes for first to third place
are sizable donations to the Haiti relief effort, with respectable cash prizes for
the winning teams.
</p>
        <p>
Even if your visual UI design skills aren’t super-solid (like mine), all teams get
an hour of Magenic Studio’s assistance, which might at least jump-start a decent looking
visual layout :)
</p>
        <p>
The app must use Silverlight or WPF (versions 3 or 4 are both acceptable), otherwise
pretty much anything goes. Well, obviously the judges need to be able to run the app
and view the code, but otherwise…
</p>
        <p>
The contest starts on Feb 22 and ends March 22.
</p>
        <p>
So go to the web site, read the rules, send email to get registered and start exercising
those mad XAML and .NET skilz!!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1f0188a5-b346-4187-a4c6-5c71ac01c779" />
      </body>
      <title>Magenic Studios Silverlight/WPF Contest</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,1f0188a5-b346-4187-a4c6-5c71ac01c779.aspx</guid>
      <link>http://www.lhotka.net/weblog/MagenicStudiosSilverlightWPFContest.aspx</link>
      <pubDate>Thu, 18 Feb 2010 16:07:32 GMT</pubDate>
      <description>&lt;p&gt;
OK, this is cool. Magenic is running a &lt;a href="http://magenic.com/Default.aspx?tabid=1835"&gt;Silverlight/WPF
development contest&lt;/a&gt;, open to anyone. The primary prizes for first to third place
are sizable donations to the Haiti relief effort, with respectable cash prizes for
the winning teams.
&lt;/p&gt;
&lt;p&gt;
Even if your visual UI design skills aren’t super-solid (like mine), all teams get
an hour of Magenic Studio’s assistance, which might at least jump-start a decent looking
visual layout :)
&lt;/p&gt;
&lt;p&gt;
The app must use Silverlight or WPF (versions 3 or 4 are both acceptable), otherwise
pretty much anything goes. Well, obviously the judges need to be able to run the app
and view the code, but otherwise…
&lt;/p&gt;
&lt;p&gt;
The contest starts on Feb 22 and ends March 22.
&lt;/p&gt;
&lt;p&gt;
So go to the web site, read the rules, send email to get registered and start exercising
those mad XAML and .NET skilz!!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1f0188a5-b346-4187-a4c6-5c71ac01c779" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,1f0188a5-b346-4187-a4c6-5c71ac01c779.aspx</comments>
      <category>Magenic</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=edb9472e-03c9-4b40-9330-7c2e8a722906</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,edb9472e-03c9-4b40-9330-7c2e8a722906.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,edb9472e-03c9-4b40-9330-7c2e8a722906.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=edb9472e-03c9-4b40-9330-7c2e8a722906</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Visual Studio 2010 includes a new XAML designer, with capabilities roughly comparable
to the Windows Forms designer we’ve enjoyed all these many years. 
</p>
        <p>
This means you can use drag-and-drop design concepts to get controls from the Toolbox
onto the design surface, drag them around, see snaplines and use the Properties window
to set properties (including data binding). And the Data Sources window works, so
you can drag entire objects or specific properties from a data source (like a CSLA
.NET business object) onto the design surface to create a UI control with the data
binding all set up.
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_thumb.png" width="172" height="365" />
          </a>
        </p>
        <p>
I’m very excited about this designer, as I think the lack of a good designer has been
the single biggest roadblock to WPF (and now Silverlight) adoption. While some people
are OK with manually typing XAML, I think a lot more people have been (im)patiently
waiting for tooling so they don’t have to work at that level. I’m in the latter camp,
but I’ve been forcing myself to type XAML for a few years now because the results
are so much better than Windows Forms that it has been worth the pain.
</p>
        <p>
However, with the designer being out now (stable and fast in the RC) I’ve been spending
some quality time with it. And what I’m finding is that I have to unlearn a lot of
techniques. Things that work great when you manually type XAML don’t always translate
exactly into the designer metaphor and/or workflow.
</p>
        <h3>CollectionViewSource Indirection
</h3>
        <p>
For example, when you drag something from the Data Sources window to the design surface
the designer creates a CollectionViewSource resource to manage the data object. Suppose
the data source is your business object – the CVS now contains your business object.
Suppose the data source is your viewmodel object – the CVS now contains your viewmodel
object.
</p>
        <p>
It is this last point that is tricky. I have been building my viewmodel objects so <em>they
are the resource</em>. Now they are <em>contained inside the resource</em>. There’s
a new level of indirection involved.
</p>
        <p>
Oh, and the CVS only contains a list of objects, never a single object. So when I
drag my single viewmodel onto the designer it ends up in a list of 1 item in the CVS.
And that’s OK, it just means your binding expressions need to take this into account.
Instead of setting the DataContext directly to the resource, you must set it to the <em>current
item</em> in the resource:
</p>
        <p>
DataContext=”{Binding Source={StaticResource viewModelViewSource}, Path=/}”
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_thumb_1.png" width="341" height="209" />
          </a> It
is the <em>Path=/</em> part that is new and different. Of course you don’t really
type that binding expression – the designer has a dialog where you set up or edit
the DataContext and other binding details.
</p>
        <p>
In the screen shot to the left you can see some regions on the form. The top, where
the button and checkbox are visible, is bound to the / path. The bottom, where the
datagrid is visible, is bound to the Model property – which means the datagrid is
bound directly to the business object, and that’s a fine thing since CSLA 4 BusinessListBase
objects derive from ObservableCollection&lt;T&gt; and are fully bindable in XAML.
</p>
        <h3>Executing ViewModel Verbs
</h3>
        <p>
The other area of challenge I’ve encountered is with triggering viewmodel verbs/commands/actions/methods
when a UI event occurs. Remember that Silverlight doesn’t have commanding, and even
in WPF commanding is not a complete solution to this problem.
</p>
        <p>
Blend 3 introduced the concept of trigger actions and behaviors, and CSLA .NET 3.8
has an Execute trigger action that executes a method on the viewmodel when an event
occurs on a UI control. Prior to that, in version 3.6, there was the InvokeMethod
attached property that did the same basic thing.
</p>
        <p>
The problem with both InvokeMethod and the Blend 3 trigger action concept is that
there’s no access to these concepts from the VS10 designer. You can use them, but
you have to manually type the XAML. My personal goal and hope with the designer is
to never type (or even see) XAML.
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_thumb_2.png" width="341" height="99" />
          </a> So
this evening I took the ideas from InvokeMethod and Execute and created a new control
I’m calling TriggerAction (<a href="http://www.lhotka.net/cslacvs/viewvc.cgi/core/branches/V4-0-0-RC/Source/Csla.Xaml/TriggerAction.cs?view=markup">see
code here</a>). The TriggerAction control is a real control – it shows up in the Toolbox
and you can drag it onto the design surface. It is invisible (collapsed), as it really
has no UI aspect. But it does have some important properties:
</p>
        <ul>
          <li>
TargetControl – use element binding to connect it to the UI control that’ll raise
the event</li>
          <li>
TriggerEvent – the name of the event raised by the UI control</li>
          <li>
MethodName – the name of the method/verb/action on the viewmodel (DataContext) object
to invoke in response to the trigger event</li>
          <li>
MethodParameter – a bindable parameter value that can optionally be passed to the
viewmodel method</li>
        </ul>
        <p>
In short, TriggerAction does exactly what InvokeMethod and Execute do, but in a way
that is friendly to the XAML designer. This means not requiring any manual editing
of XAML.
</p>
        <p>
I’m not done yet, but I’m becoming increasingly convinced that the VS10 designer really
will allow creation of XAML interfaces using patterns like MVVM and requiring zero
code-behind the XAML – without the developer ever having to see (much less edit) XAML
directly. Happiness!!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=edb9472e-03c9-4b40-9330-7c2e8a722906" />
      </body>
      <title>Applying MVVM in the VS10 XAML designer</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,edb9472e-03c9-4b40-9330-7c2e8a722906.aspx</guid>
      <link>http://www.lhotka.net/weblog/ApplyingMVVMInTheVS10XAMLDesigner.aspx</link>
      <pubDate>Wed, 17 Feb 2010 02:48:16 GMT</pubDate>
      <description>&lt;p&gt;
Visual Studio 2010 includes a new XAML designer, with capabilities roughly comparable
to the Windows Forms designer we’ve enjoyed all these many years. 
&lt;/p&gt;
&lt;p&gt;
This means you can use drag-and-drop design concepts to get controls from the Toolbox
onto the design surface, drag them around, see snaplines and use the Properties window
to set properties (including data binding). And the Data Sources window works, so
you can drag entire objects or specific properties from a data source (like a CSLA
.NET business object) onto the design surface to create a UI control with the data
binding all set up.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_thumb.png" width="172" height="365" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I’m very excited about this designer, as I think the lack of a good designer has been
the single biggest roadblock to WPF (and now Silverlight) adoption. While some people
are OK with manually typing XAML, I think a lot more people have been (im)patiently
waiting for tooling so they don’t have to work at that level. I’m in the latter camp,
but I’ve been forcing myself to type XAML for a few years now because the results
are so much better than Windows Forms that it has been worth the pain.
&lt;/p&gt;
&lt;p&gt;
However, with the designer being out now (stable and fast in the RC) I’ve been spending
some quality time with it. And what I’m finding is that I have to unlearn a lot of
techniques. Things that work great when you manually type XAML don’t always translate
exactly into the designer metaphor and/or workflow.
&lt;/p&gt;
&lt;h3&gt;CollectionViewSource Indirection
&lt;/h3&gt;
&lt;p&gt;
For example, when you drag something from the Data Sources window to the design surface
the designer creates a CollectionViewSource resource to manage the data object. Suppose
the data source is your business object – the CVS now contains your business object.
Suppose the data source is your viewmodel object – the CVS now contains your viewmodel
object.
&lt;/p&gt;
&lt;p&gt;
It is this last point that is tricky. I have been building my viewmodel objects so &lt;em&gt;they
are the resource&lt;/em&gt;. Now they are &lt;em&gt;contained inside the resource&lt;/em&gt;. There’s
a new level of indirection involved.
&lt;/p&gt;
&lt;p&gt;
Oh, and the CVS only contains a list of objects, never a single object. So when I
drag my single viewmodel onto the designer it ends up in a list of 1 item in the CVS.
And that’s OK, it just means your binding expressions need to take this into account.
Instead of setting the DataContext directly to the resource, you must set it to the &lt;em&gt;current
item&lt;/em&gt; in the resource:
&lt;/p&gt;
&lt;p&gt;
DataContext=”{Binding Source={StaticResource viewModelViewSource}, Path=/}”
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_thumb_1.png" width="341" height="209" /&gt;&lt;/a&gt; It
is the &lt;em&gt;Path=/&lt;/em&gt; part that is new and different. Of course you don’t really
type that binding expression – the designer has a dialog where you set up or edit
the DataContext and other binding details.
&lt;/p&gt;
&lt;p&gt;
In the screen shot to the left you can see some regions on the form. The top, where
the button and checkbox are visible, is bound to the / path. The bottom, where the
datagrid is visible, is bound to the Model property – which means the datagrid is
bound directly to the business object, and that’s a fine thing since CSLA 4 BusinessListBase
objects derive from ObservableCollection&amp;lt;T&amp;gt; and are fully bindable in XAML.
&lt;/p&gt;
&lt;h3&gt;Executing ViewModel Verbs
&lt;/h3&gt;
&lt;p&gt;
The other area of challenge I’ve encountered is with triggering viewmodel verbs/commands/actions/methods
when a UI event occurs. Remember that Silverlight doesn’t have commanding, and even
in WPF commanding is not a complete solution to this problem.
&lt;/p&gt;
&lt;p&gt;
Blend 3 introduced the concept of trigger actions and behaviors, and CSLA .NET 3.8
has an Execute trigger action that executes a method on the viewmodel when an event
occurs on a UI control. Prior to that, in version 3.6, there was the InvokeMethod
attached property that did the same basic thing.
&lt;/p&gt;
&lt;p&gt;
The problem with both InvokeMethod and the Blend 3 trigger action concept is that
there’s no access to these concepts from the VS10 designer. You can use them, but
you have to manually type the XAML. My personal goal and hope with the designer is
to never type (or even see) XAML.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/ApplyingMVVMintheVS10XAMLdesigner_12483/image_thumb_2.png" width="341" height="99" /&gt;&lt;/a&gt; So
this evening I took the ideas from InvokeMethod and Execute and created a new control
I’m calling TriggerAction (&lt;a href="http://www.lhotka.net/cslacvs/viewvc.cgi/core/branches/V4-0-0-RC/Source/Csla.Xaml/TriggerAction.cs?view=markup"&gt;see
code here&lt;/a&gt;). The TriggerAction control is a real control – it shows up in the Toolbox
and you can drag it onto the design surface. It is invisible (collapsed), as it really
has no UI aspect. But it does have some important properties:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
TargetControl – use element binding to connect it to the UI control that’ll raise
the event&lt;/li&gt;
&lt;li&gt;
TriggerEvent – the name of the event raised by the UI control&lt;/li&gt;
&lt;li&gt;
MethodName – the name of the method/verb/action on the viewmodel (DataContext) object
to invoke in response to the trigger event&lt;/li&gt;
&lt;li&gt;
MethodParameter – a bindable parameter value that can optionally be passed to the
viewmodel method&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In short, TriggerAction does exactly what InvokeMethod and Execute do, but in a way
that is friendly to the XAML designer. This means not requiring any manual editing
of XAML.
&lt;/p&gt;
&lt;p&gt;
I’m not done yet, but I’m becoming increasingly convinced that the VS10 designer really
will allow creation of XAML interfaces using patterns like MVVM and requiring zero
code-behind the XAML – without the developer ever having to see (much less edit) XAML
directly. Happiness!!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=edb9472e-03c9-4b40-9330-7c2e8a722906" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,edb9472e-03c9-4b40-9330-7c2e8a722906.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=281b1609-4802-4a1e-b9e9-d62d7e0a906b</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,281b1609-4802-4a1e-b9e9-d62d7e0a906b.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,281b1609-4802-4a1e-b9e9-d62d7e0a906b.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=281b1609-4802-4a1e-b9e9-d62d7e0a906b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
CSLA .NET 3.8.2 is now available for Windows and Silverlight
</p>
        <ul>
          <li>
            <a href="http://www.lhotka.net/cslanet/download.aspx">Download for Windows</a>
          </li>
          <li>
            <a href="http://www.lhotka.net/cslalight/download.aspx">Download for Silverlight</a>
          </li>
        </ul>
        <p>
This is a bug-fix release, and has been in beta for several months. 
</p>
        <p>
There is only one real functional (and breaking) change, which affects only people
building WPF or Silverlight applications and using the design-time data support built
into the data portal. This feature has been disabled in 3.8.2 because there’s an issue
in WPF (and possibly Silverlight) where detecting design time vs runtime in a high
volume runtime scenario would cause a Win32 exception in the .NET runtime.
</p>
        <p>
Since Visual Studio 2010 and .NET 4.0 have a different way of handling design time
data, this was going to change anyway; but making this change now helps avoid this
WPF runtime issue, and so was important.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=281b1609-4802-4a1e-b9e9-d62d7e0a906b" />
      </body>
      <title>CSLA .NET 3.8.2 released</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,281b1609-4802-4a1e-b9e9-d62d7e0a906b.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANET382Released.aspx</link>
      <pubDate>Mon, 01 Feb 2010 17:35:17 GMT</pubDate>
      <description>&lt;p&gt;
CSLA .NET 3.8.2 is now available for Windows and Silverlight
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;Download for Windows&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslalight/download.aspx"&gt;Download for Silverlight&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
This is a bug-fix release, and has been in beta for several months. 
&lt;/p&gt;
&lt;p&gt;
There is only one real functional (and breaking) change, which affects only people
building WPF or Silverlight applications and using the design-time data support built
into the data portal. This feature has been disabled in 3.8.2 because there’s an issue
in WPF (and possibly Silverlight) where detecting design time vs runtime in a high
volume runtime scenario would cause a Win32 exception in the .NET runtime.
&lt;/p&gt;
&lt;p&gt;
Since Visual Studio 2010 and .NET 4.0 have a different way of handling design time
data, this was going to change anyway; but making this change now helps avoid this
WPF runtime issue, and so was important.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=281b1609-4802-4a1e-b9e9-d62d7e0a906b" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,281b1609-4802-4a1e-b9e9-d62d7e0a906b.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=ad9abccc-b4f1-48a1-a6c2-83d7e1e31187</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,ad9abccc-b4f1-48a1-a6c2-83d7e1e31187.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,ad9abccc-b4f1-48a1-a6c2-83d7e1e31187.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ad9abccc-b4f1-48a1-a6c2-83d7e1e31187</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m often asked whether CSLA .NET supports the MVC, MVP, MVVM or other “M” patterns.
</p>
        <p>
The answer is an absolute YES! Of course it does, because CSLA .NET is all about the
“M”.
</p>
        <p>
The “M” in all these patterns stands for Model – the business layer that is supposed
to encapsulate all your business logic and the data required for that logic to work.
</p>
        <p>
Since its inception 13+ years ago, CSLA has been primarily focused on helping people
build a powerful business layer composed of business domain objects. This implies
strong separation of concerns where UI issues are (as much as possible) kept out of
the business layer, as are data access concerns.
</p>
        <p>
The various “M” patterns also support separation of concerns. Their perspective is
from the UI level, as they are all UI patterns. But at the core of each of them is
the idea that the “M” should encapsulate all the business logic, business processing
and data required to perform that processing.
</p>
        <p>
Whether you want a Controller-View or a Presenter-View or a View-ViewModel to organize
your UI code, in every case you need a clearly separate Model against which the UI
will work.
</p>
        <p>
CSLA .NET 3.8 specifically added a bunch of features to simplify the use of MVVM in
Silverlight and WPF, but that’s just simplification. MVVM worked fine without those
enhancements, it is just a little easier now. Of course you still need an MVVM UI
framework, because CSLA isn’t about the UI, it is about the Model.
</p>
        <p>
CSLA .NET 3.8.2 includes a CslaModelBinder for ASP.NET MVC. Again, this simplifies
one aspect of using ASP.NET MVC for your UI framework, but it isn’t strictly necessary
– it just makes life easier. The same rule applies, CSLA isn’t a UI framework and
so does as little as possible at the “V” and “C” level because its focus is all about
the “M”.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ad9abccc-b4f1-48a1-a6c2-83d7e1e31187" />
      </body>
      <title>All about the &amp;ldquo;M&amp;rdquo;</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,ad9abccc-b4f1-48a1-a6c2-83d7e1e31187.aspx</guid>
      <link>http://www.lhotka.net/weblog/AllAboutTheLdquoMrdquo.aspx</link>
      <pubDate>Wed, 13 Jan 2010 18:39:46 GMT</pubDate>
      <description>&lt;p&gt;
I’m often asked whether CSLA .NET supports the MVC, MVP, MVVM or other “M” patterns.
&lt;/p&gt;
&lt;p&gt;
The answer is an absolute YES! Of course it does, because CSLA .NET is all about the
“M”.
&lt;/p&gt;
&lt;p&gt;
The “M” in all these patterns stands for Model – the business layer that is supposed
to encapsulate all your business logic and the data required for that logic to work.
&lt;/p&gt;
&lt;p&gt;
Since its inception 13+ years ago, CSLA has been primarily focused on helping people
build a powerful business layer composed of business domain objects. This implies
strong separation of concerns where UI issues are (as much as possible) kept out of
the business layer, as are data access concerns.
&lt;/p&gt;
&lt;p&gt;
The various “M” patterns also support separation of concerns. Their perspective is
from the UI level, as they are all UI patterns. But at the core of each of them is
the idea that the “M” should encapsulate all the business logic, business processing
and data required to perform that processing.
&lt;/p&gt;
&lt;p&gt;
Whether you want a Controller-View or a Presenter-View or a View-ViewModel to organize
your UI code, in every case you need a clearly separate Model against which the UI
will work.
&lt;/p&gt;
&lt;p&gt;
CSLA .NET 3.8 specifically added a bunch of features to simplify the use of MVVM in
Silverlight and WPF, but that’s just simplification. MVVM worked fine without those
enhancements, it is just a little easier now. Of course you still need an MVVM UI
framework, because CSLA isn’t about the UI, it is about the Model.
&lt;/p&gt;
&lt;p&gt;
CSLA .NET 3.8.2 includes a CslaModelBinder for ASP.NET MVC. Again, this simplifies
one aspect of using ASP.NET MVC for your UI framework, but it isn’t strictly necessary
– it just makes life easier. The same rule applies, CSLA isn’t a UI framework and
so does as little as possible at the “V” and “C” level because its focus is all about
the “M”.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ad9abccc-b4f1-48a1-a6c2-83d7e1e31187" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,ad9abccc-b4f1-48a1-a6c2-83d7e1e31187.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>Web</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=35c7572b-1e4a-4e3d-9d6c-ae8410012596</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,35c7572b-1e4a-4e3d-9d6c-ae8410012596.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,35c7572b-1e4a-4e3d-9d6c-ae8410012596.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=35c7572b-1e4a-4e3d-9d6c-ae8410012596</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are doing Silverlight development and have SL unit tests, you should probably
take a look at <a href="http://statlight.net/">StatLight</a>.
</p>
        <p>
As CSLA .NET developers are aware, when we created CSLA .NET for Silverlight we had
to create our own unit test framework, which we made as a separate open source project
called <a href="http://www.codeplex.com/UnitDriven">UnitDriven</a>. 
</p>
        <p>
Creating UnitDriven was necessary to allow us to write exactly the same test code
to run on both .NET and SL. After all, CSLA .NET works the same (mostly) on both platforms,
so having a unified set of tests was critical. And since SL requires a lot of async
testing, we also needed a way to implement async unit tests that are exactly the same
on .NET and SL.
</p>
        <p>
The big drawback with UnitDriven is that it has an interactive runner – you actually
run the SL test app and run the tests by clicking a button. Very nice in some ways,
but not useful for continuous integration (CI). And having CI is so very nice…
</p>
        <p>
StatLight works with numerous technologies, including UnitDriven, and enables CI with
Silverlight. Absolutely worth checking out!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=35c7572b-1e4a-4e3d-9d6c-ae8410012596" />
      </body>
      <title>StatLight</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,35c7572b-1e4a-4e3d-9d6c-ae8410012596.aspx</guid>
      <link>http://www.lhotka.net/weblog/StatLight.aspx</link>
      <pubDate>Mon, 11 Jan 2010 21:32:31 GMT</pubDate>
      <description>&lt;p&gt;
If you are doing Silverlight development and have SL unit tests, you should probably
take a look at &lt;a href="http://statlight.net/"&gt;StatLight&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
As CSLA .NET developers are aware, when we created CSLA .NET for Silverlight we had
to create our own unit test framework, which we made as a separate open source project
called &lt;a href="http://www.codeplex.com/UnitDriven"&gt;UnitDriven&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
Creating UnitDriven was necessary to allow us to write exactly the same test code
to run on both .NET and SL. After all, CSLA .NET works the same (mostly) on both platforms,
so having a unified set of tests was critical. And since SL requires a lot of async
testing, we also needed a way to implement async unit tests that are exactly the same
on .NET and SL.
&lt;/p&gt;
&lt;p&gt;
The big drawback with UnitDriven is that it has an interactive runner – you actually
run the SL test app and run the tests by clicking a button. Very nice in some ways,
but not useful for continuous integration (CI). And having CI is so very nice…
&lt;/p&gt;
&lt;p&gt;
StatLight works with numerous technologies, including UnitDriven, and enables CI with
Silverlight. Absolutely worth checking out!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=35c7572b-1e4a-4e3d-9d6c-ae8410012596" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,35c7572b-1e4a-4e3d-9d6c-ae8410012596.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=89d338dc-9021-45b3-9c53-839762ea0b5d</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,89d338dc-9021-45b3-9c53-839762ea0b5d.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,89d338dc-9021-45b3-9c53-839762ea0b5d.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=89d338dc-9021-45b3-9c53-839762ea0b5d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Of course I’m referring to Windows Forms, which is about 8 years old. Even in dog
years that’s not old. But in <em>software years</em> it is pretty old I’m afraid…
</p>
        <p>
I’m writing this post because here and in other venues I’ve recently referred to Windows
Forms as “legacy”, along with asmx and even possibly Web Forms. This has caused a
certain amount of alarm, but I’m not here to apologize or mollify.
</p>
        <p>
Technologies come and go. That’s just life in our industry. I was a DEC VAX guy for
many years (I hear Ted Neward laughing now, he loves these stories), but I could see
the end coming years before it faded away, so I switched to the woefully immature
Windows platform (Windows 3.0 – what a step backward from the VAX!). I know many FoxPro
people who transitioned, albeit painfully, to VB or other tools/languages. The same
with Clipper/dBase/etc. Most PowerBuilder people transitioned to Java or .NET (though
much to my surprise I recently learned that PowerBuilder still actually exists – like
you can still buy it!!).
</p>
        <p>
All through my career I’ve been lucky or observant enough to jump ship before any
technology came down on my head. I switched to Windows before the VAX collapsed, and
switched to .NET before VB6 collapsed, etc. And honestly I can’t think of a case where
I didn’t feel like I was stepping back in time to use the “new technology” because
it was so immature compared to the old stuff. But every single time it was worth the
effort, because I avoided being trapped on a slowly fading platform/technology with
my skills becoming less relevant every day.
</p>
        <p>
But what is “legacy”? I once heard a consultant say “legacy is anything you’ve put
in production”. Which might be good for a laugh, but isn’t terribly useful in any
practical sense.
</p>
        <p>
I think “legacy” refers to a technology or platform that is no longer an area of focus
or investment by the creator/maintainer. In our world that mostly means Microsoft,
and so the question is where is Microsoft focused, where are they spending their money
and what are they enhancing?
</p>
        <p>
The answers are pretty clear:
</p>
        <ul>
          <li>
Azure</li>
          <li>
Silverlight</li>
          <li>
ASP.NET MVC</li>
          <li>
WPF (to a lesser degree)</li>
          <li>
ADO.NET EF</li>
          <li>
WCF</li>
        </ul>
        <p>
These are the areas where the research, development, marketing and general energy
are all focused. Ask a Microsoft guy what’s cool or hot and you’ll hear about Azure
or Silverlight, maybe ADO.NET EF or ASP.NET MVC and possibly WPF or WCF. But you won’t
hear Windows Forms, Web Forms, asmx web services, Enterprise Services, Remoting, LINQ
to SQL, DataSet/TableAdapter/DataTable or numerous other technologies.
</p>
        <p>
Some of those other technologies aren’t legacy – they aren’t going away, they just
aren’t sexy. Raw ADO.NET, for example. Nobody talks about that, but ADO.NET EF can’t
exist without it, so it is safe. But in theory ADO.NET EF competes with the DataSet
(poorly, but still) and so the DataSet is a strong candidate for the “legacy” label.
</p>
        <p>
Silverlight and WPF both compete with Windows Forms. Poor Windows Forms is getting
no love, no meaningful enhancements or new features. It is just there. At the same
time, Silverlight gets a new release in less than 12 month cycles, and WPF gets all
sorts of amazingly cool new features for Windows 7. You tell me whether Windows Forms
is legacy. But whatever you decide, I’m surely spending zero cycles of my time on
it.
</p>
        <p>
asmx is obvious legacy too. Has been ever since WCF showed up, though WCF’s configuration
issues have been a plague on its existence. I rather suspect .NET 4.0 will address
those shortcomings though, making WCF as easy to use as asmx and driving the final
nail in the asmx coffin.
</p>
        <p>
Web Forms isn’t so clear to me. All the buzz is on ASP.NET MVC. That’s the technology
all the cool kids are using, and it really is some nice technology – I like it as
much as I’ll probably ever like a web technology. But if you look at .NET 4.0, Microsoft
has done some really nice things in Web Forms. So while it isn’t getting the hype
of MVC, it is still getting some very real love from the Microsoft development group
that owns the technology. So I don’t think Web Forms is legacy now or in .NET 4.0,
but beyond that it is hard to say. I strongly suspect the fate of Web Forms lies mostly
in its user base and whether they fight for it, whether they make Microsoft believe
it continues to be worth serious investment and improvement into the .NET 5.0 timeframe.
</p>
        <p>
For my part, I can tell you that it is amazingly (impossibly?) time-consuming to be
an expert on 7-9 different interface technologies (UI, service, workflow, etc). Sure
CSLA .NET supports <em>all of them</em>, but there are increasing tensions between
the stagnant technologies (most notably Windows Forms) and the vibrant technologies
like Silverlight and WPF. It is no longer possible, for example, to create a collection
object that works with all the interface technologies – you just can’t do it. And
the time needed to deeply understand the different binding models and subtle differences
grows with each release of .NET.
</p>
        <p>
CSLA .NET 4.0 will absolutely still support all the interface technologies. But it
would be foolish to cut off the future to protect the past – that way lies doom. So
in CSLA .NET 4.0 you should expect to see support for Windows Forms still there, but
probably moved into another namespace (Csla.Windows or something), while the main
Csla namespace provides support for modern interface technologies like WPF, ASP.NET
MVC, Silverlight, etc.
</p>
        <p>
I am absolutely committed to providing a window of time where Windows Forms users
can migrate their apps to WPF or Silverlight while still enjoying the value of CSLA
.NET. And I really hope to make that reasonably smooth – ideally you’ll just have
to change your base class types for your business objects when you switch the UI for
the object from Windows Forms to XAML – though I suspect other minor tweaks may be
necessary as well in some edge cases.
</p>
        <p>
But let’s face it, at some point CSLA .NET does have to drop legacy technologies.
I’m just one guy, and even with Magenic being such a great patron it isn’t realistic
to support every technology ever invented for .NET :)  I don’t think the time
to drop Windows Forms is in 4.0, because there are way too many people who need to
migrate to WPF over the next 2-3 years.
</p>
        <p>
On the other hand, if you and your organization aren’t developing a strategy to move
off Windows Forms in the next few years I suspect you’ll eventually wake up one day
and realize you are in a bad spot. One of those spots where you can’t hire anyone
because no one else has done your technology for years, and nobody really remembers
how it works (or at least won’t admit they do unless you offer them huge sums of money).
</p>
        <p>
I don’t see this as bad. People who want stability shouldn’t be in computing. They
should be in something like accounts receivable or accounts payable – parts of business
that haven’t changed substantially for decades, or perhaps centuries.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=89d338dc-9021-45b3-9c53-839762ea0b5d" />
      </body>
      <title>It is only 8, how can it be legacy???</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,89d338dc-9021-45b3-9c53-839762ea0b5d.aspx</guid>
      <link>http://www.lhotka.net/weblog/ItIsOnly8HowCanItBeLegacy.aspx</link>
      <pubDate>Thu, 05 Nov 2009 03:20:16 GMT</pubDate>
      <description>&lt;p&gt;
Of course I’m referring to Windows Forms, which is about 8 years old. Even in dog
years that’s not old. But in &lt;em&gt;software years&lt;/em&gt; it is pretty old I’m afraid…
&lt;/p&gt;
&lt;p&gt;
I’m writing this post because here and in other venues I’ve recently referred to Windows
Forms as “legacy”, along with asmx and even possibly Web Forms. This has caused a
certain amount of alarm, but I’m not here to apologize or mollify.
&lt;/p&gt;
&lt;p&gt;
Technologies come and go. That’s just life in our industry. I was a DEC VAX guy for
many years (I hear Ted Neward laughing now, he loves these stories), but I could see
the end coming years before it faded away, so I switched to the woefully immature
Windows platform (Windows 3.0 – what a step backward from the VAX!). I know many FoxPro
people who transitioned, albeit painfully, to VB or other tools/languages. The same
with Clipper/dBase/etc. Most PowerBuilder people transitioned to Java or .NET (though
much to my surprise I recently learned that PowerBuilder still actually exists – like
you can still buy it!!).
&lt;/p&gt;
&lt;p&gt;
All through my career I’ve been lucky or observant enough to jump ship before any
technology came down on my head. I switched to Windows before the VAX collapsed, and
switched to .NET before VB6 collapsed, etc. And honestly I can’t think of a case where
I didn’t feel like I was stepping back in time to use the “new technology” because
it was so immature compared to the old stuff. But every single time it was worth the
effort, because I avoided being trapped on a slowly fading platform/technology with
my skills becoming less relevant every day.
&lt;/p&gt;
&lt;p&gt;
But what is “legacy”? I once heard a consultant say “legacy is anything you’ve put
in production”. Which might be good for a laugh, but isn’t terribly useful in any
practical sense.
&lt;/p&gt;
&lt;p&gt;
I think “legacy” refers to a technology or platform that is no longer an area of focus
or investment by the creator/maintainer. In our world that mostly means Microsoft,
and so the question is where is Microsoft focused, where are they spending their money
and what are they enhancing?
&lt;/p&gt;
&lt;p&gt;
The answers are pretty clear:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Azure&lt;/li&gt;
&lt;li&gt;
Silverlight&lt;/li&gt;
&lt;li&gt;
ASP.NET MVC&lt;/li&gt;
&lt;li&gt;
WPF (to a lesser degree)&lt;/li&gt;
&lt;li&gt;
ADO.NET EF&lt;/li&gt;
&lt;li&gt;
WCF&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
These are the areas where the research, development, marketing and general energy
are all focused. Ask a Microsoft guy what’s cool or hot and you’ll hear about Azure
or Silverlight, maybe ADO.NET EF or ASP.NET MVC and possibly WPF or WCF. But you won’t
hear Windows Forms, Web Forms, asmx web services, Enterprise Services, Remoting, LINQ
to SQL, DataSet/TableAdapter/DataTable or numerous other technologies.
&lt;/p&gt;
&lt;p&gt;
Some of those other technologies aren’t legacy – they aren’t going away, they just
aren’t sexy. Raw ADO.NET, for example. Nobody talks about that, but ADO.NET EF can’t
exist without it, so it is safe. But in theory ADO.NET EF competes with the DataSet
(poorly, but still) and so the DataSet is a strong candidate for the “legacy” label.
&lt;/p&gt;
&lt;p&gt;
Silverlight and WPF both compete with Windows Forms. Poor Windows Forms is getting
no love, no meaningful enhancements or new features. It is just there. At the same
time, Silverlight gets a new release in less than 12 month cycles, and WPF gets all
sorts of amazingly cool new features for Windows 7. You tell me whether Windows Forms
is legacy. But whatever you decide, I’m surely spending zero cycles of my time on
it.
&lt;/p&gt;
&lt;p&gt;
asmx is obvious legacy too. Has been ever since WCF showed up, though WCF’s configuration
issues have been a plague on its existence. I rather suspect .NET 4.0 will address
those shortcomings though, making WCF as easy to use as asmx and driving the final
nail in the asmx coffin.
&lt;/p&gt;
&lt;p&gt;
Web Forms isn’t so clear to me. All the buzz is on ASP.NET MVC. That’s the technology
all the cool kids are using, and it really is some nice technology – I like it as
much as I’ll probably ever like a web technology. But if you look at .NET 4.0, Microsoft
has done some really nice things in Web Forms. So while it isn’t getting the hype
of MVC, it is still getting some very real love from the Microsoft development group
that owns the technology. So I don’t think Web Forms is legacy now or in .NET 4.0,
but beyond that it is hard to say. I strongly suspect the fate of Web Forms lies mostly
in its user base and whether they fight for it, whether they make Microsoft believe
it continues to be worth serious investment and improvement into the .NET 5.0 timeframe.
&lt;/p&gt;
&lt;p&gt;
For my part, I can tell you that it is amazingly (impossibly?) time-consuming to be
an expert on 7-9 different interface technologies (UI, service, workflow, etc). Sure
CSLA .NET supports &lt;em&gt;all of them&lt;/em&gt;, but there are increasing tensions between
the stagnant technologies (most notably Windows Forms) and the vibrant technologies
like Silverlight and WPF. It is no longer possible, for example, to create a collection
object that works with all the interface technologies – you just can’t do it. And
the time needed to deeply understand the different binding models and subtle differences
grows with each release of .NET.
&lt;/p&gt;
&lt;p&gt;
CSLA .NET 4.0 will absolutely still support all the interface technologies. But it
would be foolish to cut off the future to protect the past – that way lies doom. So
in CSLA .NET 4.0 you should expect to see support for Windows Forms still there, but
probably moved into another namespace (Csla.Windows or something), while the main
Csla namespace provides support for modern interface technologies like WPF, ASP.NET
MVC, Silverlight, etc.
&lt;/p&gt;
&lt;p&gt;
I am absolutely committed to providing a window of time where Windows Forms users
can migrate their apps to WPF or Silverlight while still enjoying the value of CSLA
.NET. And I really hope to make that reasonably smooth – ideally you’ll just have
to change your base class types for your business objects when you switch the UI for
the object from Windows Forms to XAML – though I suspect other minor tweaks may be
necessary as well in some edge cases.
&lt;/p&gt;
&lt;p&gt;
But let’s face it, at some point CSLA .NET does have to drop legacy technologies.
I’m just one guy, and even with Magenic being such a great patron it isn’t realistic
to support every technology ever invented for .NET :)&amp;#160; I don’t think the time
to drop Windows Forms is in 4.0, because there are way too many people who need to
migrate to WPF over the next 2-3 years.
&lt;/p&gt;
&lt;p&gt;
On the other hand, if you and your organization aren’t developing a strategy to move
off Windows Forms in the next few years I suspect you’ll eventually wake up one day
and realize you are in a bad spot. One of those spots where you can’t hire anyone
because no one else has done your technology for years, and nobody really remembers
how it works (or at least won’t admit they do unless you offer them huge sums of money).
&lt;/p&gt;
&lt;p&gt;
I don’t see this as bad. People who want stability shouldn’t be in computing. They
should be in something like accounts receivable or accounts payable – parts of business
that haven’t changed substantially for decades, or perhaps centuries.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=89d338dc-9021-45b3-9c53-839762ea0b5d" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,89d338dc-9021-45b3-9c53-839762ea0b5d.aspx</comments>
      <category>CSLA .NET</category>
      <category>Microsoft .NET</category>
      <category>Silverlight</category>
      <category>WCF</category>
      <category>Web</category>
      <category>Windows Forms</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=e269f649-a4e9-44aa-955a-61125704f056</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,e269f649-a4e9-44aa-955a-61125704f056.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,e269f649-a4e9-44aa-955a-61125704f056.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=e269f649-a4e9-44aa-955a-61125704f056</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve blogged about MVVM several times over the past few months. If you watch my posts
you’ll see that I started out pretty skeptical of the pattern, and then worked through
it trying to find the shiny silver lining that was promised.
</p>
        <p>
One of the biggest challenges with patterns is that people expect them to be a recipe,
when in reality they are just a vague formalization of a concept. Just look at MVC,
an incredibly mature pattern, and all the radically different ways it gets implemented
(for better or often worse) in applications. While MVVM isn’t nearly as mature as
MVC, it turns out that it really is a good concept – when “applied correctly”.
</p>
        <p>
In my view a pattern should only be used if its positive consequences outweigh its
negative consequences. Many patterns, oddly enough, require extra code and/or configuration
over what you’d normally write – which is a negative consequence. And in some interpretations
of MVVM this is very much the case – which was the primary reason for my initial skepticism.
</p>
        <p>
On the other hand, with some thought, foresight and work it is often possible to mitigate
some of the more negative consequences of many of the more popular patterns. This
turns out to be absolutely true for MVVM.
</p>
        <p>
To me, the real sweet spot for a pattern is if it can provide its positive consequences
with little or no negative impact at all.
</p>
        <p>
My time with CSLA .NET 3.8 has been divided into just a few areas:
</p>
        <ul>
          <li>
Bug fixes (minor)</li>
          <li>
DataAnnotations (minor – but really nice)</li>
          <li>
Silverlight 3 element binding (major – also really nice)</li>
          <li>
MVVM support (major – and very cool)</li>
        </ul>
        <p>
In the end, I think I’ve got something that enables the use of the MVVM design pattern,
probably in several variations, to work swimmingly with CSLA .NET. I’ll go so far
as to say that I think this implementation of MVVM makes developing Silverlight and
WPF apps <i>easier</i> than out-of-the-box coding (drag-and-drop, handling UI events,
using data provider controls). And by easier I mean no more code, often less code,
and easier to read/test/maintain code. So the pattern is purely helpful, with no negative
consequences of note. Exactly what you’d hope for.
</p>
        <p>
What does this look like?
</p>
        <p>
          <b>CSLA .NET MVVM Support</b>
        </p>
        <p>
First, you must realize that CSLA .NET helps you create what’s called a <i>rich model</i> as
opposed to various other technologies (like Add Service Reference) that help you create
an <i>anemic model</i>. Using MVVM with an anemic model is useful, but can require
a lot of work, because your viewmodel object needs to compensate for all the stuff
the model doesn’t do. But with a rich model, the viewmodel requires far less work
because the model is already first-class citizen.
</p>
        <p>
To this end, CSLA .NET provides some helper types that you may optionally use to enable
a rich model MVVM implementation. At the same time, I fully recognize that many (most?)
people will find/build and use an MVVM UI framework, so the CSLA .NET helper types
can be used individually, all together or not at all – as you choose.
</p>
        <p>
Two parts of MVVM already (mostly) exist if you are using CSLA .NET and Silverlight
or WPF. CSLA .NET helps you create business domain objects that are your Model, and
XAML helps you create your View (with a little help). So in my mind those are essentially
a given. What’s left is the need to create the ViewModel.
</p>
        <p>
Notice that I said XAML gives you the view – <i>with a little help</i>. This is because
WPF commanding isn’t quite enough to do MVVM, and Silverlight doesn’t even have commanding.
So the “little help” is something that handles arbitrary UI events and transforms
them into arbitrary method calls on the DataContext (presumably your viewmodel). I
would expect any decent MVVM UI framework to solve this most basic problem, and of
course they do. Sadly there’s no standard solution, so each UI framework does their
own thing.
</p>
        <p>
          <b>View Event Handling</b>
        </p>
        <p>
While not a UI framework, CSLA .NET does provide a basic solution to this one critical
problem with using XAML to create a view. In fact it provides <i>two solutions</i>:
InvokeMethod and Execute.
</p>
        <p>
InvokeMethod is an attached property that understands how to handle an arbitrary UI
event and to call an arbitrary method on the DataContext when that event is raised.
As an attached property, you can attach it to any UIElement (FrameworkElement in Silverlight)
to handle any event to call any method on the DataContext. Here’s a simple example:
</p>
        <blockquote>
          <p>
&lt;Button Content=”Save” 
<br />
            csla:InvokeMethod.TriggerEvent=”Click” 
<br />
            csla:InvokeMethod.MethodName=”SaveData”
/&gt;
</p>
        </blockquote>
        <p>
Execute is similar, but relies on the Blend 3 System.Windows.Interactivity event trigger
concept to detect that the event was raised:
</p>
        <blockquote>
          <p>
&lt;Button Content="Save"&gt; 
<br />
  &lt;i:Interaction.Triggers&gt; 
<br />
    &lt;i:EventTrigger EventName="Click"&gt; 
<br />
      &lt;csla:Execute MethodName="SaveData" /&gt; 
<br />
    &lt;/i:EventTrigger&gt; 
<br />
  &lt;/i:Interaction.Triggers&gt; 
<br />
&lt;/Button&gt; 
</p>
        </blockquote>
        <p>
The advantage of using InvokeMethod is that it has several options around data binding
that simply aren’t available to a trigger action like Execute. Most notably, InvokeMethod
has a MethodParameter property that can be bound using a binding expression – so it
can pull values from other UI controls, resources, the DataContext, etc. There’s no
way to do this with a trigger action like Execute.
</p>
        <p>
The advantage of using Execute is that trigger actions are something the Blend 3 designer
understands. So InvokeMethod pretty much requires typing XAML, while Execute integrates
more naturally into the Blend design experience.
</p>
        <p>
In either case, the method on your viewmodel looks like this:
</p>
        <blockquote>
          <p>
public void SaveData() 
<br />
{ 
<br />
}
</p>
        </blockquote>
        <p>
Or this:
</p>
        <blockquote>
          <p>
public void SaveData(object sender, ExecuteEventArgs e) 
<br />
{ 
<br />
}
</p>
        </blockquote>
        <p>
Either one is fine, as InvokeMethod and Execute will work with either method signature.
If you use the second option, the args parameter contains information about the control
the raises the event, the event’s args and an optional MethodParameter value.
</p>
        <p>
          <b>Creating a ViewModel</b>
        </p>
        <p>
When using a rich model, I believe that a good viewmodel object will expose the model
as a property, so the View can bind directly against the Model <i>and still have access
to the viewmodel</i>. This way the viewmodel can extend and enhance the model without
any extra effort. This works particularly well if the model already understands data
binding – which is one of the primary features of CSLA .NET.
</p>
        <p>
CSLA .NET includes ViewModelBase&lt;T&gt; and ViewModel&lt;T&gt;, both of which are
base classes designed to make it easy to build a viewmodel for a CSLA .NET business
object.
</p>
        <p>
ViewModelBase has a public Model property, a handful of other useful public properties
(like CanSave), and a whole bunch of protected methods. Again, my assumption is that
many people will use some MVVM UI framework, and that framework will have its own
constraints on how public methods must be implemented for their particular “commanding
equivalent” functionality. The ViewModelBase class allows you to create public methods
matching your UI framework’s requirements, but you can usually just delegate those
calls to existing protected methods that do most of the work. These methods include: 
<table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td valign="top" width="200"><p>
DoRefresh
</p></td><td valign="top" width="377"><p>
(WPF only) Synchronously invokes a static factory method to create/fetch the Model.
</p></td></tr><tr><td valign="top" width="200"><p>
BeginRefresh
</p></td><td valign="top" width="377"><p>
Asynchronously invokes a static factory method to create/fetch the Model.
</p></td></tr><tr><td valign="top" width="200"><p>
DoSave
</p></td><td valign="top" width="377"><p>
(WPF only) Synchronously saves the Model (if it is a root object).
</p></td></tr><tr><td valign="top" width="200"><p>
BeginSave
</p></td><td valign="top" width="377"><p>
Asynchronously saves the Model (if it is a root object).
</p></td></tr><tr><td valign="top" width="200"><p>
AddItem
</p></td><td valign="top" width="377"><p>
Adds an item to the collection (if the Model is a BusinessListBase).
</p></td></tr><tr><td valign="top" width="200"><p>
Remove
</p></td><td valign="top" width="377"><p>
Removes an item from the collection (if the Model is a BusinessListBase).
</p></td></tr><tr><td valign="top" width="200"><p>
Delete
</p></td><td valign="top" width="377"><p>
Marks the Model for deletion (if the Model is a root BusinessBase).
</p></td></tr><tr><td valign="top" width="200"><p>
Cancel
</p></td><td valign="top" width="377"><p>
Cancels any changes that have been made to the Model (if ManageObjectLifetime is true).
</p></td></tr></tbody></table></p>
        <p>
ViewModel is a subclass of ViewModelBase that implements public methods for use by
InvokeMethod and/or Execute. If you use InvokeMethod/Execute, then you’ll want to
create your viewmodel objects by subclassing ViewModel:
</p>
        <blockquote>
          <p>
public class CustomerViewModel : ViewModel&lt;Customer&gt; 
<br />
{ 
<br />
  public CustomerViewModel() 
<br />
  { 
<br />
    BeginRefresh(“NewCustomer”); 
<br />
  } 
<br />
}
</p>
        </blockquote>
        <p>
In many cases the constructor is all you’ll need to write, since the ViewModel&lt;T&gt;
base class already implements the methods necessary to build a standard data entry
form.
</p>
        <p>
Again, if you are using an MVVM UI framework, you’ll probably want to create your
own base class, somewhat like ViewModel&lt;T&gt;, by subclassing ViewModelBase&lt;T&gt;
and implementing your public methods to match the requirements of the UI framework.
You can use the code in ViewModel&lt;T&gt; as an example of how to do this.
</p>
        <p>
I should also point out that the Model property is bindable. This means you can create
“child viewmodel” objects that get their Model value by being bound to the property
of some “parent viewmodel” or parent model. For example, you might have a form for
working with SalesOrder objects, so your top level viewmodel exposes a SalesOrder
object through its Model property. The following would be the XAML to set up the viewmodel
for the form:
</p>
        <blockquote>
          <p>
&lt;UserControl.Resources&gt; 
<br />
  &lt;this:SalesOrderViewModel x:Key="ViewModel" /&gt; 
<br />
&lt;/UserControl.Resources&gt; 
<br />
&lt;Grid Name=”LayoutRoot” DataContext=”{Binding Source={StaticResource ViewModel}}”&gt;
</p>
        </blockquote>
        <p>
Now you could just bind the detail region of the form (where you show the line items)
to the LineItems property of the business object, and that works fine.
</p>
        <p>
But suppose you want to bind a button or hyperlink control to an AddItem() method
so the user can add items to the LineItems collection. How do you do that without
writing code? The answer is that you set up a viewmodel (probably LineItemsViewModel)
for that child region of the form, and you have the Model property of LineItemsViewModel
bound to the LineItems property of the SalesOrder business object. In the child region
you’d do something like this:
</p>
        <blockquote>
          <p>
&lt;Grid Name=”ChildRegionContainer”&gt; 
<br />
  &lt;Grid.Resources&gt; 
<br />
    &lt;this:LineItemsViewModel x:Key=”LineItemsViewModel” 
<br />
                                          
Model=”{Binding Path=Model.LineItems}”/&gt; 
<br />
  &lt;/Grid.Resources&gt; 
<br />
  &lt;Grid Name=”ChildRegion” DataContext=”{Binding Source={StaticResource LineItemsViewModel}}”&gt;
</p>
        </blockquote>
        <p>
The advantage of this is that any controls inside the ChildRegion grid can invoke
methods on LineItemsViewModel – such as AddItem() or Remove() to add and remove items
from the collection – all with no coding on your part.
</p>
        <p>
          <b>Creating the Model</b>
        </p>
        <p>
This is the part where I just smile. Because you already have the model if you used
CSLA .NET and good object-oriented design to build your business domain objects. The
same business objects you may already be using for Windows Forms or Web Forms will
almost certainly just work in your WPF or Silverlight application (assuming you are
using CSLA .NET 3.5 or higher – and can upgrade to CSLA .NET 3.8).
</p>
        <p>
The primary goal of CSLA .NET, first and foremost, is to enable you to create a business
layer that encapsulates your business, validation and authorization logic into a set
of business domain objects. By doing so, you end up with a formal business layer on
top of which you can build Silverlight, WPF, ASP.NET MVC, Web Forms, Windows Forms,
asmx service or WCF service interfaces.
</p>
        <p>
So the whole point of having this business layer is that when something like XAML
comes along all you need to worry about is how to rebuild the UI, possibly using MVVM.
But you <i>don’t</i> need to worry about rebuilding the business layer, or the data
access layer or the database.
</p>
        <p>
I’m pretty happy with the way CSLA .NET 3.8 enables the MVVM design pattern in Silverlight
and WPF. As I said to start with, you’d hope that a pattern gives you positive consequences
with little or no downside. With the support of InvokeMethod, Execute, ViewModelBase
and ViewModel I think CSLA .NET makes MVVM meet that goal. And in fact, I think it
allows you to build a UI with <i>less code</i> than many, seemingly simpler, alternatives.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=e269f649-a4e9-44aa-955a-61125704f056" />
      </body>
      <title>CSLA .NET 3.8 Beta 2 MVVM support</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,e269f649-a4e9-44aa-955a-61125704f056.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANET38Beta2MVVMSupport.aspx</link>
      <pubDate>Mon, 26 Oct 2009 04:23:04 GMT</pubDate>
      <description>&lt;p&gt;
I’ve blogged about MVVM several times over the past few months. If you watch my posts
you’ll see that I started out pretty skeptical of the pattern, and then worked through
it trying to find the shiny silver lining that was promised.
&lt;/p&gt;
&lt;p&gt;
One of the biggest challenges with patterns is that people expect them to be a recipe,
when in reality they are just a vague formalization of a concept. Just look at MVC,
an incredibly mature pattern, and all the radically different ways it gets implemented
(for better or often worse) in applications. While MVVM isn’t nearly as mature as
MVC, it turns out that it really is a good concept – when “applied correctly”.
&lt;/p&gt;
&lt;p&gt;
In my view a pattern should only be used if its positive consequences outweigh its
negative consequences. Many patterns, oddly enough, require extra code and/or configuration
over what you’d normally write – which is a negative consequence. And in some interpretations
of MVVM this is very much the case – which was the primary reason for my initial skepticism.
&lt;/p&gt;
&lt;p&gt;
On the other hand, with some thought, foresight and work it is often possible to mitigate
some of the more negative consequences of many of the more popular patterns. This
turns out to be absolutely true for MVVM.
&lt;/p&gt;
&lt;p&gt;
To me, the real sweet spot for a pattern is if it can provide its positive consequences
with little or no negative impact at all.
&lt;/p&gt;
&lt;p&gt;
My time with CSLA .NET 3.8 has been divided into just a few areas:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Bug fixes (minor)&lt;/li&gt;
&lt;li&gt;
DataAnnotations (minor – but really nice)&lt;/li&gt;
&lt;li&gt;
Silverlight 3 element binding (major – also really nice)&lt;/li&gt;
&lt;li&gt;
MVVM support (major – and very cool)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In the end, I think I’ve got something that enables the use of the MVVM design pattern,
probably in several variations, to work swimmingly with CSLA .NET. I’ll go so far
as to say that I think this implementation of MVVM makes developing Silverlight and
WPF apps &lt;i&gt;easier&lt;/i&gt; than out-of-the-box coding (drag-and-drop, handling UI events,
using data provider controls). And by easier I mean no more code, often less code,
and easier to read/test/maintain code. So the pattern is purely helpful, with no negative
consequences of note. Exactly what you’d hope for.
&lt;/p&gt;
&lt;p&gt;
What does this look like?
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;CSLA .NET MVVM Support&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
First, you must realize that CSLA .NET helps you create what’s called a &lt;i&gt;rich model&lt;/i&gt; as
opposed to various other technologies (like Add Service Reference) that help you create
an &lt;i&gt;anemic model&lt;/i&gt;. Using MVVM with an anemic model is useful, but can require
a lot of work, because your viewmodel object needs to compensate for all the stuff
the model doesn’t do. But with a rich model, the viewmodel requires far less work
because the model is already first-class citizen.
&lt;/p&gt;
&lt;p&gt;
To this end, CSLA .NET provides some helper types that you may optionally use to enable
a rich model MVVM implementation. At the same time, I fully recognize that many (most?)
people will find/build and use an MVVM UI framework, so the CSLA .NET helper types
can be used individually, all together or not at all – as you choose.
&lt;/p&gt;
&lt;p&gt;
Two parts of MVVM already (mostly) exist if you are using CSLA .NET and Silverlight
or WPF. CSLA .NET helps you create business domain objects that are your Model, and
XAML helps you create your View (with a little help). So in my mind those are essentially
a given. What’s left is the need to create the ViewModel.
&lt;/p&gt;
&lt;p&gt;
Notice that I said XAML gives you the view – &lt;i&gt;with a little help&lt;/i&gt;. This is because
WPF commanding isn’t quite enough to do MVVM, and Silverlight doesn’t even have commanding.
So the “little help” is something that handles arbitrary UI events and transforms
them into arbitrary method calls on the DataContext (presumably your viewmodel). I
would expect any decent MVVM UI framework to solve this most basic problem, and of
course they do. Sadly there’s no standard solution, so each UI framework does their
own thing.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;View Event Handling&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
While not a UI framework, CSLA .NET does provide a basic solution to this one critical
problem with using XAML to create a view. In fact it provides &lt;i&gt;two solutions&lt;/i&gt;:
InvokeMethod and Execute.
&lt;/p&gt;
&lt;p&gt;
InvokeMethod is an attached property that understands how to handle an arbitrary UI
event and to call an arbitrary method on the DataContext when that event is raised.
As an attached property, you can attach it to any UIElement (FrameworkElement in Silverlight)
to handle any event to call any method on the DataContext. Here’s a simple example:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=”Save” 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=”Click” 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=”SaveData”
/&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Execute is similar, but relies on the Blend 3 System.Windows.Interactivity event trigger
concept to detect that the event was raised:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Save&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;i:EventTrigger EventName=&amp;quot;Click&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;csla:Execute MethodName=&amp;quot;SaveData&amp;quot; /&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;/i:EventTrigger&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;/i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;lt;/Button&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The advantage of using InvokeMethod is that it has several options around data binding
that simply aren’t available to a trigger action like Execute. Most notably, InvokeMethod
has a MethodParameter property that can be bound using a binding expression – so it
can pull values from other UI controls, resources, the DataContext, etc. There’s no
way to do this with a trigger action like Execute.
&lt;/p&gt;
&lt;p&gt;
The advantage of using Execute is that trigger actions are something the Blend 3 designer
understands. So InvokeMethod pretty much requires typing XAML, while Execute integrates
more naturally into the Blend design experience.
&lt;/p&gt;
&lt;p&gt;
In either case, the method on your viewmodel looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void SaveData() 
&lt;br /&gt;
{ 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Or this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void SaveData(object sender, ExecuteEventArgs e) 
&lt;br /&gt;
{ 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Either one is fine, as InvokeMethod and Execute will work with either method signature.
If you use the second option, the args parameter contains information about the control
the raises the event, the event’s args and an optional MethodParameter value.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Creating a ViewModel&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
When using a rich model, I believe that a good viewmodel object will expose the model
as a property, so the View can bind directly against the Model &lt;i&gt;and still have access
to the viewmodel&lt;/i&gt;. This way the viewmodel can extend and enhance the model without
any extra effort. This works particularly well if the model already understands data
binding – which is one of the primary features of CSLA .NET.
&lt;/p&gt;
&lt;p&gt;
CSLA .NET includes ViewModelBase&amp;lt;T&amp;gt; and ViewModel&amp;lt;T&amp;gt;, both of which are
base classes designed to make it easy to build a viewmodel for a CSLA .NET business
object.
&lt;/p&gt;
&lt;p&gt;
ViewModelBase has a public Model property, a handful of other useful public properties
(like CanSave), and a whole bunch of protected methods. Again, my assumption is that
many people will use some MVVM UI framework, and that framework will have its own
constraints on how public methods must be implemented for their particular “commanding
equivalent” functionality. The ViewModelBase class allows you to create public methods
matching your UI framework’s requirements, but you can usually just delegate those
calls to existing protected methods that do most of the work. These methods include: 
&lt;table border="0" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
DoRefresh
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
(WPF only) Synchronously invokes a static factory method to create/fetch the Model.
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
BeginRefresh
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
Asynchronously invokes a static factory method to create/fetch the Model.
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
DoSave
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
(WPF only) Synchronously saves the Model (if it is a root object).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
BeginSave
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
Asynchronously saves the Model (if it is a root object).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
AddItem
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
Adds an item to the collection (if the Model is a BusinessListBase).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
Remove
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
Removes an item from the collection (if the Model is a BusinessListBase).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
Delete
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
Marks the Model for deletion (if the Model is a root BusinessBase).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p&gt;
Cancel
&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="377"&gt;
&lt;p&gt;
Cancels any changes that have been made to the Model (if ManageObjectLifetime is true).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
ViewModel is a subclass of ViewModelBase that implements public methods for use by
InvokeMethod and/or Execute. If you use InvokeMethod/Execute, then you’ll want to
create your viewmodel objects by subclassing ViewModel:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public class CustomerViewModel : ViewModel&amp;lt;Customer&amp;gt; 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; public CustomerViewModel() 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; BeginRefresh(“NewCustomer”); 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
In many cases the constructor is all you’ll need to write, since the ViewModel&amp;lt;T&amp;gt;
base class already implements the methods necessary to build a standard data entry
form.
&lt;/p&gt;
&lt;p&gt;
Again, if you are using an MVVM UI framework, you’ll probably want to create your
own base class, somewhat like ViewModel&amp;lt;T&amp;gt;, by subclassing ViewModelBase&amp;lt;T&amp;gt;
and implementing your public methods to match the requirements of the UI framework.
You can use the code in ViewModel&amp;lt;T&amp;gt; as an example of how to do this.
&lt;/p&gt;
&lt;p&gt;
I should also point out that the Model property is bindable. This means you can create
“child viewmodel” objects that get their Model value by being bound to the property
of some “parent viewmodel” or parent model. For example, you might have a form for
working with SalesOrder objects, so your top level viewmodel exposes a SalesOrder
object through its Model property. The following would be the XAML to set up the viewmodel
for the form:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;UserControl.Resources&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;this:SalesOrderViewModel x:Key=&amp;quot;ViewModel&amp;quot; /&amp;gt; 
&lt;br /&gt;
&amp;lt;/UserControl.Resources&amp;gt; 
&lt;br /&gt;
&amp;lt;Grid Name=”LayoutRoot” DataContext=”{Binding Source={StaticResource ViewModel}}”&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Now you could just bind the detail region of the form (where you show the line items)
to the LineItems property of the business object, and that works fine.
&lt;/p&gt;
&lt;p&gt;
But suppose you want to bind a button or hyperlink control to an AddItem() method
so the user can add items to the LineItems collection. How do you do that without
writing code? The answer is that you set up a viewmodel (probably LineItemsViewModel)
for that child region of the form, and you have the Model property of LineItemsViewModel
bound to the LineItems property of the SalesOrder business object. In the child region
you’d do something like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Grid Name=”ChildRegionContainer”&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;Grid.Resources&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;this:LineItemsViewModel x:Key=”LineItemsViewModel” 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Model=”{Binding Path=Model.LineItems}”/&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;/Grid.Resources&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;Grid Name=”ChildRegion” DataContext=”{Binding Source={StaticResource LineItemsViewModel}}”&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The advantage of this is that any controls inside the ChildRegion grid can invoke
methods on LineItemsViewModel – such as AddItem() or Remove() to add and remove items
from the collection – all with no coding on your part.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Creating the Model&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
This is the part where I just smile. Because you already have the model if you used
CSLA .NET and good object-oriented design to build your business domain objects. The
same business objects you may already be using for Windows Forms or Web Forms will
almost certainly just work in your WPF or Silverlight application (assuming you are
using CSLA .NET 3.5 or higher – and can upgrade to CSLA .NET 3.8).
&lt;/p&gt;
&lt;p&gt;
The primary goal of CSLA .NET, first and foremost, is to enable you to create a business
layer that encapsulates your business, validation and authorization logic into a set
of business domain objects. By doing so, you end up with a formal business layer on
top of which you can build Silverlight, WPF, ASP.NET MVC, Web Forms, Windows Forms,
asmx service or WCF service interfaces.
&lt;/p&gt;
&lt;p&gt;
So the whole point of having this business layer is that when something like XAML
comes along all you need to worry about is how to rebuild the UI, possibly using MVVM.
But you &lt;i&gt;don’t&lt;/i&gt; need to worry about rebuilding the business layer, or the data
access layer or the database.
&lt;/p&gt;
&lt;p&gt;
I’m pretty happy with the way CSLA .NET 3.8 enables the MVVM design pattern in Silverlight
and WPF. As I said to start with, you’d hope that a pattern gives you positive consequences
with little or no downside. With the support of InvokeMethod, Execute, ViewModelBase
and ViewModel I think CSLA .NET makes MVVM meet that goal. And in fact, I think it
allows you to build a UI with &lt;i&gt;less code&lt;/i&gt; than many, seemingly simpler, alternatives.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=e269f649-a4e9-44aa-955a-61125704f056" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,e269f649-a4e9-44aa-955a-61125704f056.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=7b05be46-15bf-4388-95b6-14f6d7af08e5</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,7b05be46-15bf-4388-95b6-14f6d7af08e5.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,7b05be46-15bf-4388-95b6-14f6d7af08e5.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=7b05be46-15bf-4388-95b6-14f6d7af08e5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the new features in CSLA .NET 3.8 is the ability to use the data annotation
attributes from System.ComponentModel.DataAnnotations.
</p>
        <p>
The DataAnnotations namespace was added in .NET 3.5 SP1, and includes a ValidationAttribute
class that acts as the base class for validation attributes. An example of a validation
attribute is Required, which is used to indicate that a property is a required value.
</p>
        <p>
DataAnnotations are available in both .NET and Silverlight, though it turns out that
their implementations aren’t quite the same. Still, their <em>usage</em> is the same,
in that you decorate properties with data annotation attributes.
</p>
        <p>
The idea behind DataAnnotations is that they are UI independent. If you put a Required
attribute on a property, and then you build a UI using a technology that understands
these ValidationAttribute subclasses, the UI will honor the attribute. The Silverlight
DataForm is one example of a UI technology that does understand these attributes,
and I suspect we’ll see many more UI technologies start to leverage them.
</p>
        <p>
What’s interesting about this, is that the attribute object itself contains the validation
rule logic. So the UI doesn’t actually implement the Required rule logic – it just
asks the attribute object to do the evaluation. This is where things aren’t the same
on .NET and Silverlight. On .NET ValidationAttribute subclasses override IsValid(),
returning true if the rule is satisfied, false if not. On Silverlight ValidationAttribute
subclasses override GetValidationResult() which returns null if the rule is satisfied,
and a result object if the rule is broken. Either way the basic concept is the same,
but the implementation code is different.
</p>
        <p>
I wanted to support these attributes in CSLA .NET (for Windows and Silverlight). This
is really a two-part process. 
</p>
        <p>
First, I needed to have a way to detect the attribute on a property, and attach a
CSLA validation rule to that property so CSLA knows to execute the attribute’s rule
when appropriate. CSLA .NET already has a business/validation rule subsystem that
knows how to execute rules – I just needed to auto-add rules for data annotation attributes.
</p>
        <p>
Second, I needed a way to execute any ValidationAttribute subclass, since that’s how
one of these rules is evaluated. Again, CSLA .NET already has a validation rule subsystem
that says validation rules are methods. So I just needed to create a CSLA-style rule
method that knows how to invoke a ValidationAttribute to actually evaluate the rule’s
condition.
</p>
        <p>
I added a ValidationRules.AddDataAnnotations() method that you can call in your AddBusinessRules()
override. This method reflects against your properties, detects any ValidationAttribute
subclasses on any of your properties and adds a CSLA-style rule to link that property
to the rule attribute. I also changed BusinessBase.AddBusinessRules() (this is the
base method) so AddDataAnnotations() is called if you don’t override AddBusinessRules()
– effectively making the use of data annotation attributes a default behavior.
</p>
        <p>
Then I created a Csla.Validation.CommonRules.DataAnnotation() rule method. This is
the rule method that is automatically associated with properties by AddDataAnnotations().
The DataAnnotation() rule method is pretty simple – it just executes the attribute
object’s IsValid() or GetValidationResults() methods (depending on whether the code
is running on .NET or Silverlight).
</p>
        <p>
The end result is that when using CSLA .NET 3.8 you can apply data annotation attributes
to your business class properties, and (assuming AddDataAnnotations() is called) they’ll
be automatically linked into the normal CSLA .NET validation subsystem and executed
like any other CSLA .NET business or validation rules.
</p>
        <blockquote>
          <p>
[Serializable] 
<br />
public class Data : BusinessBase&lt;Data&gt; 
<br />
{ 
<br />
  private static PropertyInfo&lt;int&gt; IdProperty =  
<br />
    RegisterProperty&lt;int&gt;(c =&gt; c.Id); 
<br />
  [Range(0, 10, ErrorMessage = "Id must be between 0 and 10")] 
<br />
  public int Id 
<br />
  { 
<br />
    get { return GetProperty(IdProperty); } 
<br />
    set { SetProperty(IdProperty, value); } 
<br />
  } 
</p>
          <p>
  private static PropertyInfo&lt;string&gt; NameProperty = 
<br />
    RegisterProperty&lt;string&gt;(c =&gt; c.Name); 
<br />
  [Required(ErrorMessage = "Name is required")] 
<br />
  public string Name 
<br />
  { 
<br />
    get { return GetProperty(NameProperty); } 
<br />
    set { SetProperty(NameProperty, value); } 
<br />
  } 
<br />
}
</p>
        </blockquote>
        <p>
Notice that this class doesn’t override AddBusinessRules(), so the base implementation
is used, and the base implementation calls ValidationRules.AddDataAnnotations().
</p>
        <p>
When AddDataAnnotations() is called, it detects the Range and Required attributes
on the properties, and those attributes are automatically linked into the normal CSLA
.NET business rule subsystem. This means the rules are automatically checked when
a new instance of the object is created, and any time the property values are set
– exactly the behavior you’d get with regular CSLA .NET rule methods.
</p>
        <p>
But what’s nice about this is that these attributes are also honored by some UI technologies
(like DataForm). This means that you automatically get the UI behaviors (if any) and
yet you <em>know</em> that the rules will be run in the business layer regardless
of whether the UI honors the attributes or not.
</p>
        <p>
So this object will work nicely in the Silverlight DataForm, and will have the same
business behavior in Windows Forms, behind a WCF service or anywhere else the object
is used – even if the UI technology doesn’t honor the attributes.
</p>
        <p>
You can also use this approach to create your own validation attributes by subclassing
the ValidationAttribute base class in System.ComponentModel.DataAnnotations.
</p>
        <p>
The only limitation I’ve found is that these attribute-based rules can only operate
on a single property value. You can’t use this technique to do multi-property rules,
or rules that operate on child collections or across other objects. You’ll need to
use the normal CSLA .NET business/validation rule method approach to implement anything
beyond simple single-property rules.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=7b05be46-15bf-4388-95b6-14f6d7af08e5" />
      </body>
      <title>Leveraging data annotation attributes in CSLA .NET</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,7b05be46-15bf-4388-95b6-14f6d7af08e5.aspx</guid>
      <link>http://www.lhotka.net/weblog/LeveragingDataAnnotationAttributesInCSLANET.aspx</link>
      <pubDate>Mon, 05 Oct 2009 17:06:45 GMT</pubDate>
      <description>&lt;p&gt;
One of the new features in CSLA .NET 3.8 is the ability to use the data annotation
attributes from System.ComponentModel.DataAnnotations.
&lt;/p&gt;
&lt;p&gt;
The DataAnnotations namespace was added in .NET 3.5 SP1, and includes a ValidationAttribute
class that acts as the base class for validation attributes. An example of a validation
attribute is Required, which is used to indicate that a property is a required value.
&lt;/p&gt;
&lt;p&gt;
DataAnnotations are available in both .NET and Silverlight, though it turns out that
their implementations aren’t quite the same. Still, their &lt;em&gt;usage&lt;/em&gt; is the same,
in that you decorate properties with data annotation attributes.
&lt;/p&gt;
&lt;p&gt;
The idea behind DataAnnotations is that they are UI independent. If you put a Required
attribute on a property, and then you build a UI using a technology that understands
these ValidationAttribute subclasses, the UI will honor the attribute. The Silverlight
DataForm is one example of a UI technology that does understand these attributes,
and I suspect we’ll see many more UI technologies start to leverage them.
&lt;/p&gt;
&lt;p&gt;
What’s interesting about this, is that the attribute object itself contains the validation
rule logic. So the UI doesn’t actually implement the Required rule logic – it just
asks the attribute object to do the evaluation. This is where things aren’t the same
on .NET and Silverlight. On .NET ValidationAttribute subclasses override IsValid(),
returning true if the rule is satisfied, false if not. On Silverlight ValidationAttribute
subclasses override GetValidationResult() which returns null if the rule is satisfied,
and a result object if the rule is broken. Either way the basic concept is the same,
but the implementation code is different.
&lt;/p&gt;
&lt;p&gt;
I wanted to support these attributes in CSLA .NET (for Windows and Silverlight). This
is really a two-part process. 
&lt;/p&gt;
&lt;p&gt;
First, I needed to have a way to detect the attribute on a property, and attach a
CSLA validation rule to that property so CSLA knows to execute the attribute’s rule
when appropriate. CSLA .NET already has a business/validation rule subsystem that
knows how to execute rules – I just needed to auto-add rules for data annotation attributes.
&lt;/p&gt;
&lt;p&gt;
Second, I needed a way to execute any ValidationAttribute subclass, since that’s how
one of these rules is evaluated. Again, CSLA .NET already has a validation rule subsystem
that says validation rules are methods. So I just needed to create a CSLA-style rule
method that knows how to invoke a ValidationAttribute to actually evaluate the rule’s
condition.
&lt;/p&gt;
&lt;p&gt;
I added a ValidationRules.AddDataAnnotations() method that you can call in your AddBusinessRules()
override. This method reflects against your properties, detects any ValidationAttribute
subclasses on any of your properties and adds a CSLA-style rule to link that property
to the rule attribute. I also changed BusinessBase.AddBusinessRules() (this is the
base method) so AddDataAnnotations() is called if you don’t override AddBusinessRules()
– effectively making the use of data annotation attributes a default behavior.
&lt;/p&gt;
&lt;p&gt;
Then I created a Csla.Validation.CommonRules.DataAnnotation() rule method. This is
the rule method that is automatically associated with properties by AddDataAnnotations().
The DataAnnotation() rule method is pretty simple – it just executes the attribute
object’s IsValid() or GetValidationResults() methods (depending on whether the code
is running on .NET or Silverlight).
&lt;/p&gt;
&lt;p&gt;
The end result is that when using CSLA .NET 3.8 you can apply data annotation attributes
to your business class properties, and (assuming AddDataAnnotations() is called) they’ll
be automatically linked into the normal CSLA .NET validation subsystem and executed
like any other CSLA .NET business or validation rules.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
[Serializable] 
&lt;br /&gt;
public class Data : BusinessBase&amp;lt;Data&amp;gt; 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; private static PropertyInfo&amp;lt;int&amp;gt; IdProperty =&amp;#160; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; RegisterProperty&amp;lt;int&amp;gt;(c =&amp;gt; c.Id); 
&lt;br /&gt;
&amp;#160; [Range(0, 10, ErrorMessage = &amp;quot;Id must be between 0 and 10&amp;quot;)] 
&lt;br /&gt;
&amp;#160; public int Id 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; get { return GetProperty(IdProperty); } 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; set { SetProperty(IdProperty, value); } 
&lt;br /&gt;
&amp;#160; } 
&lt;/p&gt;
&lt;p&gt;
&amp;#160; private static PropertyInfo&amp;lt;string&amp;gt; NameProperty = 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; RegisterProperty&amp;lt;string&amp;gt;(c =&amp;gt; c.Name); 
&lt;br /&gt;
&amp;#160; [Required(ErrorMessage = &amp;quot;Name is required&amp;quot;)] 
&lt;br /&gt;
&amp;#160; public string Name 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; get { return GetProperty(NameProperty); } 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; set { SetProperty(NameProperty, value); } 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Notice that this class doesn’t override AddBusinessRules(), so the base implementation
is used, and the base implementation calls ValidationRules.AddDataAnnotations().
&lt;/p&gt;
&lt;p&gt;
When AddDataAnnotations() is called, it detects the Range and Required attributes
on the properties, and those attributes are automatically linked into the normal CSLA
.NET business rule subsystem. This means the rules are automatically checked when
a new instance of the object is created, and any time the property values are set
– exactly the behavior you’d get with regular CSLA .NET rule methods.
&lt;/p&gt;
&lt;p&gt;
But what’s nice about this is that these attributes are also honored by some UI technologies
(like DataForm). This means that you automatically get the UI behaviors (if any) and
yet you &lt;em&gt;know&lt;/em&gt; that the rules will be run in the business layer regardless
of whether the UI honors the attributes or not.
&lt;/p&gt;
&lt;p&gt;
So this object will work nicely in the Silverlight DataForm, and will have the same
business behavior in Windows Forms, behind a WCF service or anywhere else the object
is used – even if the UI technology doesn’t honor the attributes.
&lt;/p&gt;
&lt;p&gt;
You can also use this approach to create your own validation attributes by subclassing
the ValidationAttribute base class in System.ComponentModel.DataAnnotations.
&lt;/p&gt;
&lt;p&gt;
The only limitation I’ve found is that these attribute-based rules can only operate
on a single property value. You can’t use this technique to do multi-property rules,
or rules that operate on child collections or across other objects. You’ll need to
use the normal CSLA .NET business/validation rule method approach to implement anything
beyond simple single-property rules.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=7b05be46-15bf-4388-95b6-14f6d7af08e5" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,7b05be46-15bf-4388-95b6-14f6d7af08e5.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=fbf8dab3-4f54-4658-99bc-e5a1f6eb9095</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,fbf8dab3-4f54-4658-99bc-e5a1f6eb9095.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,fbf8dab3-4f54-4658-99bc-e5a1f6eb9095.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=fbf8dab3-4f54-4658-99bc-e5a1f6eb9095</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have put two new pre-releases online, and they are available on the download pages:
</p>
        <ul>
          <li>
            <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA .NET for Windows</a>
          </li>
          <li>
            <a href="http://www.lhotka.net/cslalight/download.aspx">CSLA .NET for Silverlight</a>
          </li>
        </ul>
        <p>
          <strong>CSLA .NET 3.7.1 Beta 3</strong> is near-stable. In fact it would have been
a release, except for one change I just added that I feel needs a beta cycle.
</p>
        <p>
The 3.7.1 release is primarily bug fixes for a few issues in 3.7.0. 
</p>
        <p>
The only <em>new</em> feature is some support for creating custom FieldInfo&lt;T&gt;
subclasses, which requires creating PropertyInfo&lt;T&gt; subclasses. If you are doing
this, the new 3.7.1 changes in Beta 3 may make your life much easier.
</p>
        <p>
          <strong>CSLA .NET 3.8.0 Alpha 2</strong> shows my continuing work and thoughts around
the new Silverlight 3 binding capabilties and MVVM support.
</p>
        <p>
All the new changes in Alpha 2 are on the Silverlight side, and impact:
</p>
        <ul>
          <li>
CslaDataProvider - where the ObjectInstance property is now bindable, so you can "chain"
data provider controls in parent-child relationships. This means you can have a child
region on a form that is bound to a CslaDataProvider that got its data from the child
property of a parent CslaDataProvider.</li>
          <li>
ViewModelBase - a base class that provides protected members you can use to more easily
create a ViewModel class for your CSLA .NET business objects. The approach taken is
one that exposes the Model (your business object) as a Model property of the ViewModel
object; this is the flavor of MVVM that works best with CSLA .NET. 
<br />
This does include a protected method to create/fetch the Model as requested in one
of the recent MVVM threads on the <a href="http://forums.lhotka.net/forums">CSLA .NET
forum</a>.</li>
          <li>
ViewModel - a subclass of ViewModelBase that exposes public members for use with InvokeMethod
or Execute (see below) so the methods can be invoked directly by XAML. <em>Warning:</em> I
may or may not keep this class, depending on <em>your feedback</em>, as I don't know
if it is the best plan overall.</li>
          <li>
InvokeMethod - which has breaking changes, but now automatically binds to the current
DataContext and does a whole bunch of other nice work on your behalf to invoke methods
on a data provider or ViewModel.</li>
          <li>
Execute - a new event trigger action using the new Blend 3 SDK feature of event triggers.
The Execute action is similar to InvokeMethod, but works within the new event trigger
infrastructure.</li>
          <li>
PropertyStatus - which has breaking changes, and is now bindable using element binding,
and binds to the business object property instead of using a string literal for the
property name. It also now exposes properties so a UI control can bind <em>to PropertyStatus</em>,
instead of having PropertyStatus directly alter the UI control - this offers major
new flexibility in UI design.</li>
        </ul>
        <p>
If you are using SL3 and/or are at all interested in MVVM, please take a look at what
I'm doing in 3.8 and provide feedback.
</p>
        <p>
As always, my intent is not for CSLA .NET to become a UI framework. At the same time,
I feel the need to fill in at least the most glaring holes in the UI layer to enable
use of CSLA .NET - and this means providing a basic way for XAML to invoke ViewModel
methods, and for validation/authorization rules to be expressed in a rich manner in
the UI.
</p>
        <p>
It <em>should be the case</em> that any MVVM UI framework will be compatible with
viewmodel objects you create by subclassing ViewModelBase. If that's not true, I'd
like to hear about the issues you run into. Since ViewModelBase exposes nearly all
protected members (except for Model, IsBusy and Error, which are public), I expect
that it will provide an incredibly flexible start point for creating viewmodel objects.
</p>
        <p>
The ViewModel base class is an example of how ViewModelBase can be subclasses to create
a base that works with a specific UI implementation - specifically InvokeMethod and/or
Execute.
</p>
        <p>
Assuming generally positive feedback on the changes I've made on the Silverlight side,
I'll port the appropriate changes to the WPF side, and then release 3.8.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=fbf8dab3-4f54-4658-99bc-e5a1f6eb9095" />
      </body>
      <title>CSLA .NET updates: 3.7.1 Beta 3 and 3.8.0 Alpha 2</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,fbf8dab3-4f54-4658-99bc-e5a1f6eb9095.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANETUpdates371Beta3And380Alpha2.aspx</link>
      <pubDate>Sun, 13 Sep 2009 17:22:15 GMT</pubDate>
      <description>&lt;p&gt;
I have put two new pre-releases online, and they are available on the download pages:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA .NET for Windows&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslalight/download.aspx"&gt;CSLA .NET for Silverlight&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;CSLA .NET 3.7.1 Beta 3&lt;/strong&gt; is near-stable. In fact it would have been
a release, except for one change I just added that I feel needs a beta cycle.
&lt;/p&gt;
&lt;p&gt;
The 3.7.1 release is primarily bug fixes for a few issues in 3.7.0. 
&lt;/p&gt;
&lt;p&gt;
The only &lt;em&gt;new&lt;/em&gt; feature is some support for creating custom FieldInfo&amp;lt;T&amp;gt;
subclasses, which requires creating PropertyInfo&amp;lt;T&amp;gt; subclasses. If you are doing
this, the new 3.7.1 changes in Beta 3 may make your life much easier.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;CSLA .NET 3.8.0 Alpha 2&lt;/strong&gt; shows my continuing work and thoughts around
the new Silverlight 3 binding capabilties and MVVM support.
&lt;/p&gt;
&lt;p&gt;
All the new changes in Alpha 2 are on the Silverlight side, and impact:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
CslaDataProvider - where the ObjectInstance property is now bindable, so you can &amp;quot;chain&amp;quot;
data provider controls in parent-child relationships. This means you can have a child
region on a form that is bound to a CslaDataProvider that got its data from the child
property of a parent CslaDataProvider.&lt;/li&gt;
&lt;li&gt;
ViewModelBase - a base class that provides protected members you can use to more easily
create a ViewModel class for your CSLA .NET business objects. The approach taken is
one that exposes the Model (your business object) as a Model property of the ViewModel
object; this is the flavor of MVVM that works best with CSLA .NET. 
&lt;br /&gt;
This does include a protected method to create/fetch the Model as requested in one
of the recent MVVM threads on the &lt;a href="http://forums.lhotka.net/forums"&gt;CSLA .NET
forum&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
ViewModel - a subclass of ViewModelBase that exposes public members for use with InvokeMethod
or Execute (see below) so the methods can be invoked directly by XAML. &lt;em&gt;Warning:&lt;/em&gt; I
may or may not keep this class, depending on &lt;em&gt;your feedback&lt;/em&gt;, as I don't know
if it is the best plan overall.&lt;/li&gt;
&lt;li&gt;
InvokeMethod - which has breaking changes, but now automatically binds to the current
DataContext and does a whole bunch of other nice work on your behalf to invoke methods
on a data provider or ViewModel.&lt;/li&gt;
&lt;li&gt;
Execute - a new event trigger action using the new Blend 3 SDK feature of event triggers.
The Execute action is similar to InvokeMethod, but works within the new event trigger
infrastructure.&lt;/li&gt;
&lt;li&gt;
PropertyStatus - which has breaking changes, and is now bindable using element binding,
and binds to the business object property instead of using a string literal for the
property name. It also now exposes properties so a UI control can bind &lt;em&gt;to PropertyStatus&lt;/em&gt;,
instead of having PropertyStatus directly alter the UI control - this offers major
new flexibility in UI design.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
If you are using SL3 and/or are at all interested in MVVM, please take a look at what
I'm doing in 3.8 and provide feedback.
&lt;/p&gt;
&lt;p&gt;
As always, my intent is not for CSLA .NET to become a UI framework. At the same time,
I feel the need to fill in at least the most glaring holes in the UI layer to enable
use of CSLA .NET - and this means providing a basic way for XAML to invoke ViewModel
methods, and for validation/authorization rules to be expressed in a rich manner in
the UI.
&lt;/p&gt;
&lt;p&gt;
It &lt;em&gt;should be the case&lt;/em&gt; that any MVVM UI framework will be compatible with
viewmodel objects you create by subclassing ViewModelBase. If that's not true, I'd
like to hear about the issues you run into. Since ViewModelBase exposes nearly all
protected members (except for Model, IsBusy and Error, which are public), I expect
that it will provide an incredibly flexible start point for creating viewmodel objects.
&lt;/p&gt;
&lt;p&gt;
The ViewModel base class is an example of how ViewModelBase can be subclasses to create
a base that works with a specific UI implementation - specifically InvokeMethod and/or
Execute.
&lt;/p&gt;
&lt;p&gt;
Assuming generally positive feedback on the changes I've made on the Silverlight side,
I'll port the appropriate changes to the WPF side, and then release 3.8.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=fbf8dab3-4f54-4658-99bc-e5a1f6eb9095" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,fbf8dab3-4f54-4658-99bc-e5a1f6eb9095.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=2580a48b-cb25-439a-be46-2b22b657fbf8</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,2580a48b-cb25-439a-be46-2b22b657fbf8.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,2580a48b-cb25-439a-be46-2b22b657fbf8.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2580a48b-cb25-439a-be46-2b22b657fbf8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I keep plucking away at the MVVM ideas, trying to make sure CSLA .NET allows people
to implement the pattern in a smooth manner.
</p>
        <p>
But I keep fighting with UI stuff in the process…
</p>
        <p>
My scenarios center around the ListBox, because I find it to be nicely problematic.
And common. Most apps have lists of stuff, and users select n items from the list
and then do something with the items. So single-select and multi-select ListBox scenarios,
where actions are triggered by the selection changing, or when a button is clicked
– this is my current problem domain. Pure UI stuff.
</p>
        <p>
I updated my existing InvokeMethod component to solve these problems, with some challenges,
but it works nicely to invoke a method on a ViewModel. I’ve also played with the EventTrigger
concepts from Blend 3, creating an Execute trigger action that invokes a method on
the ViewModel, but there are some serious limitations here.
</p>
        <p>
One scenario is pretty easy – triggering an action from the SelectionChanged event
of the ListBox itself. The InvokeMethod and Execute solutions can both be handled
with zero code-behind – just XAML interacting with the ViewModel.
</p>
        <h4>Single-select with InvokeMethod
</h4>
        <p>
With InvokeMethod it looks like this:
</p>
        <blockquote>
          <p>
&lt;ListBox ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource
DataList}" 
<br />
         Name="DataListBox" 
<br />
         csla:InvokeMethod.Target="{Binding
Source={StaticResource ListModel}}" 
<br />
         csla:InvokeMethod.TriggerEvent="SelectionChanged" 
<br />
         csla:InvokeMethod.MethodName="ShowItem" 
<br />
         csla:InvokeMethod.MethodParameter="{Binding
RelativeSource={RelativeSource Self}, Path=SelectedItem}" /&gt; 
</p>
        </blockquote>
        <p>
And the ViewModel has a ShowItem() method like this:
</p>
        <blockquote>
          <p>
public void ShowItem(Data methodParameter) 
<br />
{ 
<br />
  // process methodParameter 
<br />
} 
</p>
        </blockquote>
        <p>
Very simple and easy, and I like it a lot – except that InvokeMethod is fairly verbose
and isn’t supported by Blend. I do like that the selected item is passed into the
method as a strongly typed parameter though.
</p>
        <h4>Single-select with event trigger
</h4>
        <p>
Using the event trigger model (which is supported by Blend) the ListBox looks like
this:
</p>
        <blockquote>
          <p>
&lt;ListBox ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource
DataList}" 
<br />
         SelectedItem="{Binding Path=SelectedData,
Mode=TwoWay}" 
<br />
         Name="DataListBox"&gt; 
<br />
  &lt;i:Interaction.Triggers&gt; 
<br />
    &lt;i:EventTrigger EventName="SelectionChanged"&gt; 
<br />
      &lt;csla:Execute MethodName="ShowItem2" /&gt; 
<br />
    &lt;/i:EventTrigger&gt; 
<br />
  &lt;/i:Interaction.Triggers&gt; 
<br />
&lt;/ListBox&gt; 
</p>
        </blockquote>
        <p>
Notice that the ListBox.SelectedItem property is now bound to the SelectedData ViewModel
property: 
</p>
        <blockquote>
          <p>
public static readonly DependencyProperty SelectedDataProperty = 
<br />
    DependencyProperty.Register("SelectedData", typeof(Data),
typeof(DataListViewModel), new PropertyMetadata(null)); 
<br />
public Data SelectedData 
<br />
{ 
<br />
  get { return (Data)GetValue(SelectedDataProperty); } 
<br />
  set { SetValue(SelectedDataProperty, value); OnPropertyChanged("SelectedData");
} 
<br />
} 
</p>
        </blockquote>
        <p>
And the ViewModel method looks like this:
</p>
        <blockquote>
          <p>
public void ShowItem2(object sender, Csla.Silverlight.ExecuteEventArgs e) 
<br />
{ 
<br />
  // process this.SelectedData 
<br />
}
</p>
        </blockquote>
        <p>
While this is supported by Blend, I dislike the fact that the command method (ShowItem2())
has an invisible side-effect in that it requires the SelectedData property to be set
before it will work. No one could know this without looking at the code or at documentation,
so the overall readability is reduced in my opinion.
</p>
        <p>
However, both solutions end up with a ShowItem() method that has the strongly-typed
selected item, and the XAML uses binding to interact with the ViewModel in a reasonably
clean manner – so I think either way is perfectly acceptable.
</p>
        <h4>Multi-select with InvokeMethod
</h4>
        <p>
The multi-select ListBox scenario requires a Button (or similar control). The user
selects multiple items in the ListBox, then clicks the Button to trigger processing
of those items.
</p>
        <p>
This scenario is not nearly so nice. Partly this is because of the way the ListBox
works I think (or binding). The problem is that the SelectedItems property of the
ListBox returns an ObservableCollection&lt;object&gt;, and when a binding is established
between SelectedItems and another property it gets a reference to a collection <em>that
is not the collection you ultimately want</em>.
</p>
        <p>
In other words, when the form loads, SelectedItems points to an empty collection,
and anything bound to it gets connected to that collection. When items are later selected
the SelectedItems property seems to end up pointing to a <em>different collection</em>,
and the binding has no idea this happened. The binding is still pointing to the original
empty collection.
</p>
        <p>
This means the binding to SelectedItems must be refreshed <em>at the time the event
trigger occurs</em>, such as the Button control’s Click event.
</p>
        <p>
I made InvokeMethod take care of this, so when using InvokeMethod the ListBox looks
like this:
</p>
        <blockquote>
          <p>
&lt;ListBox ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource
DataList}" 
<br />
         SelectionMode="Multiple" 
<br />
         Name="DataListBox" /&gt; 
</p>
        </blockquote>
        <p>
And the Button looks like this:
</p>
        <blockquote>
          <p>
&lt;Button Content="Process items" 
<br />
        csla:InvokeMethod.TriggerEvent="Click" 
<br />
        csla:InvokeMethod.MethodName="ProcessItems" 
<br />
        csla:InvokeMethod.MethodParameter="{Binding
ElementName=DataListBox, Path=SelectedItems}"/&gt;
</p>
        </blockquote>
        <p>
And the ViewModel method looks like this:
</p>
        <blockquote>
          <p>
public void ProcessItems(System.Collections.ObjectModel.ObservableCollection&lt;object&gt;
methodParameter) 
<br />
{ 
<br />
  // process methodParameter 
<br />
} 
</p>
        </blockquote>
        <p>
This only works because InvokeMethod refreshes the binding of its MethodParameter
property when it gets the Click event from the Button. If it just took the normal
binding value, it would always return an empty collection…
</p>
        <p>
But the fact is that InvokeMethod does make this work in a very smooth and easy manner,
allowing the ViewModel to implement a method that accepts the list of selected items
as a parameter.
</p>
        <h4>Multi-select with event trigger
</h4>
        <p>
Using the trigger action approach things are really messy, because there’s no way
to force a refresh of anything that is bound to SelectedItems.
</p>
        <p>
Worse, you can’t actually bind SelectedItems on the ListBox itself like you bind SelectedItem.
In other words, the ListBox ends up looking like this:
</p>
        <blockquote>
          <p>
&lt;ListBox ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource
DataList}" 
<br />
         SelectionMode="Multiple" 
<br />
         Name="DataListBox"&gt; 
<br />
&lt;/ListBox&gt; 
</p>
        </blockquote>
        <p>
Where you’d want to bind SelectedItems to a property of the ViewModel, that’s not
possible.
</p>
        <p>
So I thought I’d use a bit of a hack and bind it to the Tag property of the Button:
</p>
        <blockquote>
          <p>
&lt;Button Content="Process items" 
<br />
        Tag="{Binding ElementName=DataListBox,
Path=SelectedItems}"&gt; 
<br />
  &lt;i:Interaction.Triggers&gt; 
<br />
    &lt;i:EventTrigger EventName="Click"&gt; 
<br />
      &lt;csla:Execute MethodName="ProcessItems2"
/&gt; 
<br />
    &lt;/i:EventTrigger&gt; 
<br />
  &lt;/i:Interaction.Triggers&gt; 
<br />
&lt;/Button&gt; 
</p>
        </blockquote>
        <p>
While this “works”, it doesn’t really. The problem is that the binding is established
when SelectedItems is an empty collection, and it never changes. So this is NOT a
useful way to get the list of selected items. 
</p>
        <p>
In the end, the solution appears to be that the ViewModel must know that it is dealing
with a ListBox so it can get the items directly in the command method. That means
the Button must provide a link to the ListBox (via Tag):
</p>
        <blockquote>
          <p>
&lt;Button Content="Process items" 
<br />
        <strong>Tag="{Binding ElementName=DataListBox}"</strong>&gt; 
</p>
        </blockquote>
        <p>
This way the command method can interact with the Tag property to get a reference
to the ListBox to get at the SelectedItems collection:
</p>
        <blockquote>
          <p>
public void ProcessItems2(object sender, Csla.Silverlight.ExecuteEventArgs e) 
<br />
{ 
<br />
  var listBox = ((System.Windows.Controls.Control)e.TriggerSource).Tag as System.Windows.Controls.ListBox; 
<br />
  var selection = listBox.SelectedItems; 
<br />
  // process selection 
<br />
} 
</p>
        </blockquote>
        <p>
This is bad because now the ViewModel must know details about the control in the View.
It is directly using the ListBox type, which means that the XAML can’t be easily changed
to use some other type of list-oriented UI control – at least not without coming back
here and changing this code.
</p>
        <p>
I guess one solution would be to create a custom Button subclass that refreshes the
binding of its Tag property when the button is clicked – but that’s not a good general
solution by any means…
</p>
        <p>
So in the multi-select scenario InvokeMethod is a decent solution, but trigger actions
really fall down and the solution seems very inadequate. I think this is primarily
due to the implementation of ListBox.SelectedItems, but I also think it is safe to
assume that other UI controls will have similarly ill-behaved properties that make
trigger actions harder to use than they should be.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2580a48b-cb25-439a-be46-2b22b657fbf8" />
      </body>
      <title>More Silverlight MVVM fun</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,2580a48b-cb25-439a-be46-2b22b657fbf8.aspx</guid>
      <link>http://www.lhotka.net/weblog/MoreSilverlightMVVMFun.aspx</link>
      <pubDate>Wed, 02 Sep 2009 21:25:26 GMT</pubDate>
      <description>&lt;p&gt;
I keep plucking away at the MVVM ideas, trying to make sure CSLA .NET allows people
to implement the pattern in a smooth manner.
&lt;/p&gt;
&lt;p&gt;
But I keep fighting with UI stuff in the process…
&lt;/p&gt;
&lt;p&gt;
My scenarios center around the ListBox, because I find it to be nicely problematic.
And common. Most apps have lists of stuff, and users select n items from the list
and then do something with the items. So single-select and multi-select ListBox scenarios,
where actions are triggered by the selection changing, or when a button is clicked
– this is my current problem domain. Pure UI stuff.
&lt;/p&gt;
&lt;p&gt;
I updated my existing InvokeMethod component to solve these problems, with some challenges,
but it works nicely to invoke a method on a ViewModel. I’ve also played with the EventTrigger
concepts from Blend 3, creating an Execute trigger action that invokes a method on
the ViewModel, but there are some serious limitations here.
&lt;/p&gt;
&lt;p&gt;
One scenario is pretty easy – triggering an action from the SelectionChanged event
of the ListBox itself. The InvokeMethod and Execute solutions can both be handled
with zero code-behind – just XAML interacting with the ViewModel.
&lt;/p&gt;
&lt;h4&gt;Single-select with InvokeMethod
&lt;/h4&gt;
&lt;p&gt;
With InvokeMethod it looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox ItemsSource=&amp;quot;{Binding Path=Model}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemTemplate=&amp;quot;{StaticResource
DataList}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Name=&amp;quot;DataListBox&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.Target=&amp;quot;{Binding
Source={StaticResource ListModel}}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=&amp;quot;SelectionChanged&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=&amp;quot;ShowItem&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodParameter=&amp;quot;{Binding
RelativeSource={RelativeSource Self}, Path=SelectedItem}&amp;quot; /&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And the ViewModel has a ShowItem() method like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ShowItem(Data methodParameter) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; // process methodParameter 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Very simple and easy, and I like it a lot – except that InvokeMethod is fairly verbose
and isn’t supported by Blend. I do like that the selected item is passed into the
method as a strongly typed parameter though.
&lt;/p&gt;
&lt;h4&gt;Single-select with event trigger
&lt;/h4&gt;
&lt;p&gt;
Using the event trigger model (which is supported by Blend) the ListBox looks like
this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox ItemsSource=&amp;quot;{Binding Path=Model}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemTemplate=&amp;quot;{StaticResource
DataList}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectedItem=&amp;quot;{Binding Path=SelectedData,
Mode=TwoWay}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Name=&amp;quot;DataListBox&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;i:EventTrigger EventName=&amp;quot;SelectionChanged&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;csla:Execute MethodName=&amp;quot;ShowItem2&amp;quot; /&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;/i:EventTrigger&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;/i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;lt;/ListBox&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Notice that the ListBox.SelectedItem property is now bound to the SelectedData ViewModel
property: 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public static readonly DependencyProperty SelectedDataProperty = 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; DependencyProperty.Register(&amp;quot;SelectedData&amp;quot;, typeof(Data),
typeof(DataListViewModel), new PropertyMetadata(null)); 
&lt;br /&gt;
public Data SelectedData 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; get { return (Data)GetValue(SelectedDataProperty); } 
&lt;br /&gt;
&amp;#160; set { SetValue(SelectedDataProperty, value); OnPropertyChanged(&amp;quot;SelectedData&amp;quot;);
} 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And the ViewModel method looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ShowItem2(object sender, Csla.Silverlight.ExecuteEventArgs e) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; // process this.SelectedData 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
While this is supported by Blend, I dislike the fact that the command method (ShowItem2())
has an invisible side-effect in that it requires the SelectedData property to be set
before it will work. No one could know this without looking at the code or at documentation,
so the overall readability is reduced in my opinion.
&lt;/p&gt;
&lt;p&gt;
However, both solutions end up with a ShowItem() method that has the strongly-typed
selected item, and the XAML uses binding to interact with the ViewModel in a reasonably
clean manner – so I think either way is perfectly acceptable.
&lt;/p&gt;
&lt;h4&gt;Multi-select with InvokeMethod
&lt;/h4&gt;
&lt;p&gt;
The multi-select ListBox scenario requires a Button (or similar control). The user
selects multiple items in the ListBox, then clicks the Button to trigger processing
of those items.
&lt;/p&gt;
&lt;p&gt;
This scenario is not nearly so nice. Partly this is because of the way the ListBox
works I think (or binding). The problem is that the SelectedItems property of the
ListBox returns an ObservableCollection&amp;lt;object&amp;gt;, and when a binding is established
between SelectedItems and another property it gets a reference to a collection &lt;em&gt;that
is not the collection you ultimately want&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
In other words, when the form loads, SelectedItems points to an empty collection,
and anything bound to it gets connected to that collection. When items are later selected
the SelectedItems property seems to end up pointing to a &lt;em&gt;different collection&lt;/em&gt;,
and the binding has no idea this happened. The binding is still pointing to the original
empty collection.
&lt;/p&gt;
&lt;p&gt;
This means the binding to SelectedItems must be refreshed &lt;em&gt;at the time the event
trigger occurs&lt;/em&gt;, such as the Button control’s Click event.
&lt;/p&gt;
&lt;p&gt;
I made InvokeMethod take care of this, so when using InvokeMethod the ListBox looks
like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox ItemsSource=&amp;quot;{Binding Path=Model}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemTemplate=&amp;quot;{StaticResource
DataList}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectionMode=&amp;quot;Multiple&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Name=&amp;quot;DataListBox&amp;quot; /&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And the Button looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Process items&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=&amp;quot;Click&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=&amp;quot;ProcessItems&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodParameter=&amp;quot;{Binding
ElementName=DataListBox, Path=SelectedItems}&amp;quot;/&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And the ViewModel method looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ProcessItems(System.Collections.ObjectModel.ObservableCollection&amp;lt;object&amp;gt;
methodParameter) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; // process methodParameter 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This only works because InvokeMethod refreshes the binding of its MethodParameter
property when it gets the Click event from the Button. If it just took the normal
binding value, it would always return an empty collection…
&lt;/p&gt;
&lt;p&gt;
But the fact is that InvokeMethod does make this work in a very smooth and easy manner,
allowing the ViewModel to implement a method that accepts the list of selected items
as a parameter.
&lt;/p&gt;
&lt;h4&gt;Multi-select with event trigger
&lt;/h4&gt;
&lt;p&gt;
Using the trigger action approach things are really messy, because there’s no way
to force a refresh of anything that is bound to SelectedItems.
&lt;/p&gt;
&lt;p&gt;
Worse, you can’t actually bind SelectedItems on the ListBox itself like you bind SelectedItem.
In other words, the ListBox ends up looking like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox ItemsSource=&amp;quot;{Binding Path=Model}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemTemplate=&amp;quot;{StaticResource
DataList}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectionMode=&amp;quot;Multiple&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Name=&amp;quot;DataListBox&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;lt;/ListBox&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Where you’d want to bind SelectedItems to a property of the ViewModel, that’s not
possible.
&lt;/p&gt;
&lt;p&gt;
So I thought I’d use a bit of a hack and bind it to the Tag property of the Button:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Process items&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Tag=&amp;quot;{Binding ElementName=DataListBox,
Path=SelectedItems}&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;i:EventTrigger EventName=&amp;quot;Click&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;csla:Execute MethodName=&amp;quot;ProcessItems2&amp;quot;
/&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;/i:EventTrigger&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;/i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;lt;/Button&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
While this “works”, it doesn’t really. The problem is that the binding is established
when SelectedItems is an empty collection, and it never changes. So this is NOT a
useful way to get the list of selected items. 
&lt;/p&gt;
&lt;p&gt;
In the end, the solution appears to be that the ViewModel must know that it is dealing
with a ListBox so it can get the items directly in the command method. That means
the Button must provide a link to the ListBox (via Tag):
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Process items&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Tag=&amp;quot;{Binding ElementName=DataListBox}&amp;quot;&lt;/strong&gt;&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This way the command method can interact with the Tag property to get a reference
to the ListBox to get at the SelectedItems collection:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ProcessItems2(object sender, Csla.Silverlight.ExecuteEventArgs e) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; var listBox = ((System.Windows.Controls.Control)e.TriggerSource).Tag as System.Windows.Controls.ListBox; 
&lt;br /&gt;
&amp;#160; var selection = listBox.SelectedItems; 
&lt;br /&gt;
&amp;#160; // process selection 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This is bad because now the ViewModel must know details about the control in the View.
It is directly using the ListBox type, which means that the XAML can’t be easily changed
to use some other type of list-oriented UI control – at least not without coming back
here and changing this code.
&lt;/p&gt;
&lt;p&gt;
I guess one solution would be to create a custom Button subclass that refreshes the
binding of its Tag property when the button is clicked – but that’s not a good general
solution by any means…
&lt;/p&gt;
&lt;p&gt;
So in the multi-select scenario InvokeMethod is a decent solution, but trigger actions
really fall down and the solution seems very inadequate. I think this is primarily
due to the implementation of ListBox.SelectedItems, but I also think it is safe to
assume that other UI controls will have similarly ill-behaved properties that make
trigger actions harder to use than they should be.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=2580a48b-cb25-439a-be46-2b22b657fbf8" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,2580a48b-cb25-439a-be46-2b22b657fbf8.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=95dad38d-6893-4aaa-806a-b4a6fa892505</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,95dad38d-6893-4aaa-806a-b4a6fa892505.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,95dad38d-6893-4aaa-806a-b4a6fa892505.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=95dad38d-6893-4aaa-806a-b4a6fa892505</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Based on my recent posts regarding Silverlight, MVVM and invoking methods on arbitrary
target objects, a couple people suggested that behaviors or trigger actions might
be a good solution.
</p>
        <p>
These are new concepts introduced through the System.Windows.Interaction assembly
that comes with Expression Blend 3. That’s somewhat of a drawback, since this means
a developer is required to install Blend 3 to get the assembly before these features
are available. It would be nicer if they were part of the standard Silverlight (and
WPF) development platform.
</p>
        <p>
The other challenge I’ve encountered in working with this technology is a limitation
when it comes to data binding. Silverlight only full binds with dependency properties
of FrameworkElement objects. Since classes like TriggerAction&lt;T&gt; don’t inherit
from FrameworkElement, their dependency properties aren’t bindable. This means you
can’t define a property on a trigger and then bind it to other elements in the UI,
which is really an unfortunate limitation.
</p>
        <p>
For example, I created an <a href="http://www.lhotka.net/cslacvs/viewvc.cgi/trunk/cslalightcs/Csla/Silverlight/Execute.cs?revision=4141&amp;view=markup">Execute
trigger action</a> that defines MethodName and MethodParameter properties. If I have
a ListBox and a Button, and I want the Button to trigger some method that acts on
the SelectedItem property of the ListBox, what I’d really like to do is this:
</p>
        <blockquote>
          <p>
&lt;Button Content="Refresh"&gt; 
<br />
  &lt;i:Interaction.Triggers&gt; 
<br />
    &lt;i:EventTrigger EventName="Click"&gt; 
<br />
      &lt;csla:Execute MethodName="Load" <strong>MethodParameter="{Binding
ElementName=MyListBox, Path=SelectedItem}"</strong> /&gt; 
<br />
    &lt;/i:EventTrigger&gt; 
<br />
  &lt;/i:Interaction.Triggers&gt; 
<br />
&lt;/Button&gt; 
</p>
        </blockquote>
        <p>
(in this code the ‘i’ prefix refers to System.Windows.Interactivity from Blend 3 and
the ‘csla’ prefix refers to Csla.Silverlight from CSLA .NET)
</p>
        <p>
Unfortunately this won’t get past the Silverlight XAML parser, because a binding expression
isn’t allowed for MethodParameter…
</p>
        <p>
I also wanted to implement a MethodTarget property so the Execute trigger could invoke
methods on some object other than the current DataContext. Unfortunately that puts
us back to needed the ability to use binding to specify the value of MethodTarget,
which isn’t possible. So my current implementation can only invoke methods on the
DataContext of the associated control (the Button in this case).
</p>
        <p>
To get around the MethodParameter limitation I’m using a Tag hack
</p>
        <blockquote>
          <p>
&lt;Button Content="Refresh" <strong>Tag="{Binding ElementName=NewIdTextBox,
Path=Text}"</strong>&gt; 
<br />
  &lt;i:Interaction.Triggers&gt; 
<br />
    &lt;i:EventTrigger EventName="Click"&gt; 
<br />
      &lt;csla:Execute MethodName="Load" /&gt; 
<br />
    &lt;/i:EventTrigger&gt; 
<br />
  &lt;/i:Interaction.Triggers&gt; 
<br />
&lt;/Button&gt; 
</p>
        </blockquote>
        <p>
When the Execute trigger invokes the method, it passes an <a href="http://www.lhotka.net/cslacvs/viewvc.cgi/trunk/cslalightcs/Csla/Silverlight/ExecuteEventArgs.cs?revision=4141&amp;view=markup">ExecuteEventArgs
parameter</a> to the method, which includes a TriggerSource property of type FrameworkElement.
This means the method, in the view model class, can access the Tag property of the
associated control (the Button), which <em>can be bound</em> because the Button is
a FrameworkElement:
</p>
        <blockquote>
          <p>
public void Load(object sender, ExecuteEventArgs e) 
<br />
{ 
<br />
  var tag =<strong> e.TriggerSource.Tag</strong>.ToString(); 
<br />
  int id = 0; 
<br />
  if (!string.IsNullOrEmpty(tag)) 
<br />
    id = int.Parse(tag); 
<br />
  Load(id); 
<br />
} 
</p>
        </blockquote>
        <p>
Sure this is somewhat hacky, but since the trigger action can’t define bindable properties
of its own, this seems like a workable solution.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=95dad38d-6893-4aaa-806a-b4a6fa892505" />
      </body>
      <title>Silverlight triggers</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,95dad38d-6893-4aaa-806a-b4a6fa892505.aspx</guid>
      <link>http://www.lhotka.net/weblog/SilverlightTriggers.aspx</link>
      <pubDate>Fri, 14 Aug 2009 18:44:31 GMT</pubDate>
      <description>&lt;p&gt;
Based on my recent posts regarding Silverlight, MVVM and invoking methods on arbitrary
target objects, a couple people suggested that behaviors or trigger actions might
be a good solution.
&lt;/p&gt;
&lt;p&gt;
These are new concepts introduced through the System.Windows.Interaction assembly
that comes with Expression Blend 3. That’s somewhat of a drawback, since this means
a developer is required to install Blend 3 to get the assembly before these features
are available. It would be nicer if they were part of the standard Silverlight (and
WPF) development platform.
&lt;/p&gt;
&lt;p&gt;
The other challenge I’ve encountered in working with this technology is a limitation
when it comes to data binding. Silverlight only full binds with dependency properties
of FrameworkElement objects. Since classes like TriggerAction&amp;lt;T&amp;gt; don’t inherit
from FrameworkElement, their dependency properties aren’t bindable. This means you
can’t define a property on a trigger and then bind it to other elements in the UI,
which is really an unfortunate limitation.
&lt;/p&gt;
&lt;p&gt;
For example, I created an &lt;a href="http://www.lhotka.net/cslacvs/viewvc.cgi/trunk/cslalightcs/Csla/Silverlight/Execute.cs?revision=4141&amp;amp;view=markup"&gt;Execute
trigger action&lt;/a&gt; that defines MethodName and MethodParameter properties. If I have
a ListBox and a Button, and I want the Button to trigger some method that acts on
the SelectedItem property of the ListBox, what I’d really like to do is this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Refresh&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;i:EventTrigger EventName=&amp;quot;Click&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;csla:Execute MethodName=&amp;quot;Load&amp;quot; &lt;strong&gt;MethodParameter=&amp;quot;{Binding
ElementName=MyListBox, Path=SelectedItem}&amp;quot;&lt;/strong&gt; /&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;/i:EventTrigger&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;/i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;lt;/Button&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
(in this code the ‘i’ prefix refers to System.Windows.Interactivity from Blend 3 and
the ‘csla’ prefix refers to Csla.Silverlight from CSLA .NET)
&lt;/p&gt;
&lt;p&gt;
Unfortunately this won’t get past the Silverlight XAML parser, because a binding expression
isn’t allowed for MethodParameter…
&lt;/p&gt;
&lt;p&gt;
I also wanted to implement a MethodTarget property so the Execute trigger could invoke
methods on some object other than the current DataContext. Unfortunately that puts
us back to needed the ability to use binding to specify the value of MethodTarget,
which isn’t possible. So my current implementation can only invoke methods on the
DataContext of the associated control (the Button in this case).
&lt;/p&gt;
&lt;p&gt;
To get around the MethodParameter limitation I’m using a Tag hack
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Refresh&amp;quot; &lt;strong&gt;Tag=&amp;quot;{Binding ElementName=NewIdTextBox,
Path=Text}&amp;quot;&lt;/strong&gt;&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;i:EventTrigger EventName=&amp;quot;Click&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;csla:Execute MethodName=&amp;quot;Load&amp;quot; /&amp;gt; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &amp;lt;/i:EventTrigger&amp;gt; 
&lt;br /&gt;
&amp;#160; &amp;lt;/i:Interaction.Triggers&amp;gt; 
&lt;br /&gt;
&amp;lt;/Button&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
When the Execute trigger invokes the method, it passes an &lt;a href="http://www.lhotka.net/cslacvs/viewvc.cgi/trunk/cslalightcs/Csla/Silverlight/ExecuteEventArgs.cs?revision=4141&amp;amp;view=markup"&gt;ExecuteEventArgs
parameter&lt;/a&gt; to the method, which includes a TriggerSource property of type FrameworkElement.
This means the method, in the view model class, can access the Tag property of the
associated control (the Button), which &lt;em&gt;can be bound&lt;/em&gt; because the Button is
a FrameworkElement:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void Load(object sender, ExecuteEventArgs e) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; var tag =&lt;strong&gt; e.TriggerSource.Tag&lt;/strong&gt;.ToString(); 
&lt;br /&gt;
&amp;#160; int id = 0; 
&lt;br /&gt;
&amp;#160; if (!string.IsNullOrEmpty(tag)) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; id = int.Parse(tag); 
&lt;br /&gt;
&amp;#160; Load(id); 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Sure this is somewhat hacky, but since the trigger action can’t define bindable properties
of its own, this seems like a workable solution.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=95dad38d-6893-4aaa-806a-b4a6fa892505" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,95dad38d-6893-4aaa-806a-b4a6fa892505.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=6a9565f6-2914-4958-aea6-c12e60cb158c</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,6a9565f6-2914-4958-aea6-c12e60cb158c.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,6a9565f6-2914-4958-aea6-c12e60cb158c.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=6a9565f6-2914-4958-aea6-c12e60cb158c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
CSLA .NET 3.6 introduced the InvokeMethod component for Silverlight, which was intended
to replace at least the basic WPF commanding functionality I tend to use to trigger
actions on a CslaDataProvider when buttons are clicked. And it did that.
</p>
        <p>
It turns out however, that with a few tweaks, InvokeMethod is much more broadly useful
than just triggering actions on a CslaDataProvider. In a more general sense, InvokeMethod
can be used to call a method on nearly any object in response to nearly any event
being raised by a UI control.
</p>
        <p>
I’ve been reworking InvokeMethod quite a bit over the past few days, and whatever
I end up doing will be in CSLA .NET 3.8. And it will be a breaking change over the
3.6 and 3.7 functionality, which is unfortunate, but I think it is worth it.
</p>
        <p>
This blog post is not the final word, just kind of a “state of the control” post to
solicit thoughts and feedback as I work on version 3.8.
</p>
        <p>
In the new model, InvokeMethod can still invoke methods on a CslaDataProvider, so
no functionality is lost.
</p>
        <p>
But in the new model, InvokeMethod can invoke methods on other arbitrary objects,
as long as they can be described through a binding expression. In other words, any
bindable object that has a method becomes a valid target. And the range of trigger
events is much broader; in fact any event should now work, though I’ve only tested
a handful of common events (click, doubleclick, selectionchanged, etc).
</p>
        <p>
Using some data binding trickery I’ve made the Target property (used to be the Resource
property) optional. If you don’t set the Target property, InvokeMethod will target
the DataContext of the control to which it is attached. This is not so useful with
a data provider model, but is very useful with a ViewModel model.
</p>
        <h3>Simple scenario
</h3>
        <p>
So an example of triggering an action on a ViewModel when a button is clicked:
</p>
        <blockquote>
          <p>
&lt;Button Content="Refresh" 
<br />
        csla:InvokeMethod.TriggerEvent="Click" 
<br />
        csla:InvokeMethod.MethodName="Load"
/&gt; 
</p>
        </blockquote>
        <p>
When the button is clicked a Load() method is invoked on the current DataContext,
which is probably a ViewModel class with a Load() method:
</p>
        <blockquote>
          <p>
public class DataListViewModel : CslaViewModel&lt;DataList&gt; 
<br />
{ 
<br />
  public void Load() 
<br />
  {  
<br />
  } 
<br />
}
</p>
        </blockquote>
        <p>
That’s the simplest example, and could be handled by commanding in WPF.
</p>
        <h3>ListBox doubleclick scenario
</h3>
        <p>
A more interesting example is where the UI needs to do something in response to a
doubleclick of an item in a ListBox. This is interesting because there’s a temporal
issue where the user could select an item in the list, and not doubleclick on it ever,
or for a long time. In my mind, the ViewModel would handle the doubleclick through
a method that accepts the selected item as a parameter:
</p>
        <blockquote>
          <p>
public void ProcessItem(Data item) 
<br />
{ 
<br />
}
</p>
        </blockquote>
        <p>
That implies that InvokeMethod can pass the selected item as a parameter, and in the
current incarnation it can do this:
</p>
        <blockquote>
          <p>
&lt;ListBox 
<br />
         ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource
DataList}" 
<br />
         csla:InvokeMethod.TriggerEvent="MouseDoubleClick" 
<br />
         csla:InvokeMethod.MethodName="ProcessItem" 
<br />
         csla:InvokeMethod.MethodParameter="{Binding
SelectedItem, RelativeSource={RelativeSource Self}}"/&gt; 
</p>
        </blockquote>
        <p>
The ambient DataContext here is the ViewModel object, and you can see that the ListBox
loads its items from the Model property (where the Model is a collection of Data objects).
The only really interesting thing here is that the MethodParameter property is using
binding to pick up the SelectedItem property from the UI control – so from the ListBox.
This directly meets my requirement of being able to pass the selected item to the
ViewModel method.
</p>
        <p>
The ViewModel doesn’t care what type of UI control is used, as long as it gets a selected
Data item. This also means the ViewModel is quite testable, because it is a simple
method that accepts a strongly typed parameter.
</p>
        <h3>MultiSelect ListBox scenario
</h3>
        <p>
This even works with a multiselect ListBox control (though my solution seems a <a href="http://www.lhotka.net/weblog/SilverlightElementBindingIssue.aspx">bit
messy</a>).
</p>
        <p>
Obviously this requires a Button or some other control outside the ListBox, since
a multiselect ListBox doesn’t raise events quite the same way. The user gets to select
arbitrary items in the ListBox, then click a Button to trigger processing of all selected
items.
</p>
        <p>
The ViewModel has a method to handle this:
</p>
        <blockquote>
          <p>
public void ProcessItems(ObservableCollection&lt;object&gt; items) 
<br />
{ 
<br />
}
</p>
        </blockquote>
        <p>
And the XAML invokes this method from the Button (assuming the ListBox has an explicit
name):
</p>
        <blockquote>
          <p>
&lt;Button Content="Process items" 
<br />
        csla:InvokeMethod.TriggerEvent="Click" 
<br />
        csla:InvokeMethod.MethodName="ProcessItems" 
<br />
        csla:InvokeMethod.MethodParameter="{Binding
ElementName=DataListBox, Path=SelectedItems}"/&gt; 
</p>
        </blockquote>
        <p>
Again, the ViewModel just accepts a (relatively) strongly typed parameter, not caring
about the type of UI control that generated that value. There’s no real type-level
coupling between the XAML and the ViewModel.
</p>
        <p>
In all these cases the XAML knows nothing more than that there’s a Model to bind to,
and some actions (methods) on the ViewModel that can be invoked.
</p>
        <p>
And the ViewModel knows nothing more than that it is being invoked by something. XAML,
a test harness, it doesn’t really matter, it just does its thing.
</p>
        <p>
Whether this is “MVVM” or not, I think it is pretty darn cool :)
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=6a9565f6-2914-4958-aea6-c12e60cb158c" />
      </body>
      <title>Streamlining Csla.Silverlight.InvokeMethod</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,6a9565f6-2914-4958-aea6-c12e60cb158c.aspx</guid>
      <link>http://www.lhotka.net/weblog/StreamliningCslaSilverlightInvokeMethod.aspx</link>
      <pubDate>Wed, 05 Aug 2009 03:30:44 GMT</pubDate>
      <description>&lt;p&gt;
CSLA .NET 3.6 introduced the InvokeMethod component for Silverlight, which was intended
to replace at least the basic WPF commanding functionality I tend to use to trigger
actions on a CslaDataProvider when buttons are clicked. And it did that.
&lt;/p&gt;
&lt;p&gt;
It turns out however, that with a few tweaks, InvokeMethod is much more broadly useful
than just triggering actions on a CslaDataProvider. In a more general sense, InvokeMethod
can be used to call a method on nearly any object in response to nearly any event
being raised by a UI control.
&lt;/p&gt;
&lt;p&gt;
I’ve been reworking InvokeMethod quite a bit over the past few days, and whatever
I end up doing will be in CSLA .NET 3.8. And it will be a breaking change over the
3.6 and 3.7 functionality, which is unfortunate, but I think it is worth it.
&lt;/p&gt;
&lt;p&gt;
This blog post is not the final word, just kind of a “state of the control” post to
solicit thoughts and feedback as I work on version 3.8.
&lt;/p&gt;
&lt;p&gt;
In the new model, InvokeMethod can still invoke methods on a CslaDataProvider, so
no functionality is lost.
&lt;/p&gt;
&lt;p&gt;
But in the new model, InvokeMethod can invoke methods on other arbitrary objects,
as long as they can be described through a binding expression. In other words, any
bindable object that has a method becomes a valid target. And the range of trigger
events is much broader; in fact any event should now work, though I’ve only tested
a handful of common events (click, doubleclick, selectionchanged, etc).
&lt;/p&gt;
&lt;p&gt;
Using some data binding trickery I’ve made the Target property (used to be the Resource
property) optional. If you don’t set the Target property, InvokeMethod will target
the DataContext of the control to which it is attached. This is not so useful with
a data provider model, but is very useful with a ViewModel model.
&lt;/p&gt;
&lt;h3&gt;Simple scenario
&lt;/h3&gt;
&lt;p&gt;
So an example of triggering an action on a ViewModel when a button is clicked:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Refresh&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=&amp;quot;Click&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=&amp;quot;Load&amp;quot;
/&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
When the button is clicked a Load() method is invoked on the current DataContext,
which is probably a ViewModel class with a Load() method:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public class DataListViewModel : CslaViewModel&amp;lt;DataList&amp;gt; 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; public void Load() 
&lt;br /&gt;
&amp;#160; {&amp;#160; 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
That’s the simplest example, and could be handled by commanding in WPF.
&lt;/p&gt;
&lt;h3&gt;ListBox doubleclick scenario
&lt;/h3&gt;
&lt;p&gt;
A more interesting example is where the UI needs to do something in response to a
doubleclick of an item in a ListBox. This is interesting because there’s a temporal
issue where the user could select an item in the list, and not doubleclick on it ever,
or for a long time. In my mind, the ViewModel would handle the doubleclick through
a method that accepts the selected item as a parameter:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ProcessItem(Data item) 
&lt;br /&gt;
{ 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
That implies that InvokeMethod can pass the selected item as a parameter, and in the
current incarnation it can do this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemsSource=&amp;quot;{Binding Path=Model}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemTemplate=&amp;quot;{StaticResource
DataList}&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=&amp;quot;MouseDoubleClick&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=&amp;quot;ProcessItem&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodParameter=&amp;quot;{Binding
SelectedItem, RelativeSource={RelativeSource Self}}&amp;quot;/&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The ambient DataContext here is the ViewModel object, and you can see that the ListBox
loads its items from the Model property (where the Model is a collection of Data objects).
The only really interesting thing here is that the MethodParameter property is using
binding to pick up the SelectedItem property from the UI control – so from the ListBox.
This directly meets my requirement of being able to pass the selected item to the
ViewModel method.
&lt;/p&gt;
&lt;p&gt;
The ViewModel doesn’t care what type of UI control is used, as long as it gets a selected
Data item. This also means the ViewModel is quite testable, because it is a simple
method that accepts a strongly typed parameter.
&lt;/p&gt;
&lt;h3&gt;MultiSelect ListBox scenario
&lt;/h3&gt;
&lt;p&gt;
This even works with a multiselect ListBox control (though my solution seems a &lt;a href="http://www.lhotka.net/weblog/SilverlightElementBindingIssue.aspx"&gt;bit
messy&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
Obviously this requires a Button or some other control outside the ListBox, since
a multiselect ListBox doesn’t raise events quite the same way. The user gets to select
arbitrary items in the ListBox, then click a Button to trigger processing of all selected
items.
&lt;/p&gt;
&lt;p&gt;
The ViewModel has a method to handle this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ProcessItems(ObservableCollection&amp;lt;object&amp;gt; items) 
&lt;br /&gt;
{ 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And the XAML invokes this method from the Button (assuming the ListBox has an explicit
name):
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Process items&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=&amp;quot;Click&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=&amp;quot;ProcessItems&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodParameter=&amp;quot;{Binding
ElementName=DataListBox, Path=SelectedItems}&amp;quot;/&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Again, the ViewModel just accepts a (relatively) strongly typed parameter, not caring
about the type of UI control that generated that value. There’s no real type-level
coupling between the XAML and the ViewModel.
&lt;/p&gt;
&lt;p&gt;
In all these cases the XAML knows nothing more than that there’s a Model to bind to,
and some actions (methods) on the ViewModel that can be invoked.
&lt;/p&gt;
&lt;p&gt;
And the ViewModel knows nothing more than that it is being invoked by something. XAML,
a test harness, it doesn’t really matter, it just does its thing.
&lt;/p&gt;
&lt;p&gt;
Whether this is “MVVM” or not, I think it is pretty darn cool :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=6a9565f6-2914-4958-aea6-c12e60cb158c" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,6a9565f6-2914-4958-aea6-c12e60cb158c.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=8250578a-f9fa-4258-8175-880d65388b80</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,8250578a-f9fa-4258-8175-880d65388b80.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,8250578a-f9fa-4258-8175-880d65388b80.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=8250578a-f9fa-4258-8175-880d65388b80</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m trying to do something that seems like it should be so simple and obvious.
</p>
        <p>
I have an attached property, MethodParameter, which I’m applying to a Button, but
I’m binding to a ListBox control:
</p>
        <blockquote>
          <p>
&lt;Button Content="Process items" 
<br />
        csla:InvokeMethod.TriggerEvent="Click" 
<br />
        csla:InvokeMethod.MethodName="ProcessItems" 
<br />
        csla:InvokeMethod.MethodParameter="{Binding
ElementName=DataListBox, Path=SelectedItems}"/&gt; 
</p>
        </blockquote>
        <p>
This works, and does bind. But it appears to bind only when the Button control is
instantiated, not when the Click event is handled.
</p>
        <p>
In other words, the binding occurs. The user then interacts with the ListBox control
and selects some items, and then clicks the Button. That triggers the Click event,
which causes the InvokeMethod object to actually use the MethodParameter value.
</p>
        <p>
However, at that point in time the binding appears to still be using the original
collection from when the form was being loaded, and so the collection is empty.
</p>
        <p>
If I actually examine the SelectedItems property it has multiple items of course –
but it is a different collection than the one from when the form was loaded.
</p>
        <p>
In other words, ListBox seems to create a whole new collection each time SelectedItems
is invoked, and that’s apparently totally messing up data binding.
</p>
        <p>
I don’t know if this problem is unique to ListBox, or if it is a broader problem with
element binding, but it is making my life very unpleasant…
</p>
        <p>
To solve this, I’m hijacking the binding process like this:
</p>
        <blockquote>
          <p>
public static object GetMethodParameter(UIElement ctrl) 
<br />
{ 
<br />
  var fe = ctrl as FrameworkElement; 
<br />
  if (fe != null) 
<br />
  { 
<br />
    var be = fe.GetBindingExpression(MethodParameterProperty); 
<br />
    var dataItem = be.DataItem; 
<br />
    string path = be.ParentBinding.Path.Path; 
<br />
    if (dataItem != null &amp;&amp; !string.IsNullOrEmpty(path)) 
<br />
    { 
<br />
      var pi = Csla.Reflection.MethodCaller.GetProperty(dataItem.GetType(),
path); 
<br />
      return Csla.Reflection.MethodCaller.GetPropertyValue(dataItem,
pi); 
<br />
    } 
<br />
  } 
<br />
  return ctrl.GetValue(MethodParameterProperty); 
<br />
} 
</p>
        </blockquote>
        <p>
Basically I’m using reflection to manually go get the property value of the target
object. This works, but feels really wrong.
</p>
        <p>
If we’re dealing with a nasty idiosyncrasy of the ListBox I can probably restrict
this to only be messy when talking to a ListBox control, but I rather suspect ListBox
isn’t the only issue.
</p>
        <p>
I’ve tried all sorts of things on the binding expression - Mode=TwoWay and BindsDirectlyToSource=True.
But they had no impact. It appears that the binding gets a reference to the property
value when it is created and never knows enough to re-read the value later when I
actually need it.
</p>
        <p>
Any ideas?
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=8250578a-f9fa-4258-8175-880d65388b80" />
      </body>
      <title>Silverlight element binding issue</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,8250578a-f9fa-4258-8175-880d65388b80.aspx</guid>
      <link>http://www.lhotka.net/weblog/SilverlightElementBindingIssue.aspx</link>
      <pubDate>Wed, 05 Aug 2009 03:13:49 GMT</pubDate>
      <description>&lt;p&gt;
I’m trying to do something that seems like it should be so simple and obvious.
&lt;/p&gt;
&lt;p&gt;
I have an attached property, MethodParameter, which I’m applying to a Button, but
I’m binding to a ListBox control:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button Content=&amp;quot;Process items&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.TriggerEvent=&amp;quot;Click&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodName=&amp;quot;ProcessItems&amp;quot; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; csla:InvokeMethod.MethodParameter=&amp;quot;{Binding
ElementName=DataListBox, Path=SelectedItems}&amp;quot;/&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This works, and does bind. But it appears to bind only when the Button control is
instantiated, not when the Click event is handled.
&lt;/p&gt;
&lt;p&gt;
In other words, the binding occurs. The user then interacts with the ListBox control
and selects some items, and then clicks the Button. That triggers the Click event,
which causes the InvokeMethod object to actually use the MethodParameter value.
&lt;/p&gt;
&lt;p&gt;
However, at that point in time the binding appears to still be using the original
collection from when the form was being loaded, and so the collection is empty.
&lt;/p&gt;
&lt;p&gt;
If I actually examine the SelectedItems property it has multiple items of course –
but it is a different collection than the one from when the form was loaded.
&lt;/p&gt;
&lt;p&gt;
In other words, ListBox seems to create a whole new collection each time SelectedItems
is invoked, and that’s apparently totally messing up data binding.
&lt;/p&gt;
&lt;p&gt;
I don’t know if this problem is unique to ListBox, or if it is a broader problem with
element binding, but it is making my life very unpleasant…
&lt;/p&gt;
&lt;p&gt;
To solve this, I’m hijacking the binding process like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public static object GetMethodParameter(UIElement ctrl) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; var fe = ctrl as FrameworkElement; 
&lt;br /&gt;
&amp;#160; if (fe != null) 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var be = fe.GetBindingExpression(MethodParameterProperty); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var dataItem = be.DataItem; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; string path = be.ParentBinding.Path.Path; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; if (dataItem != null &amp;amp;&amp;amp; !string.IsNullOrEmpty(path)) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var pi = Csla.Reflection.MethodCaller.GetProperty(dataItem.GetType(),
path); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return Csla.Reflection.MethodCaller.GetPropertyValue(dataItem,
pi); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; } 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
&amp;#160; return ctrl.GetValue(MethodParameterProperty); 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Basically I’m using reflection to manually go get the property value of the target
object. This works, but feels really wrong.
&lt;/p&gt;
&lt;p&gt;
If we’re dealing with a nasty idiosyncrasy of the ListBox I can probably restrict
this to only be messy when talking to a ListBox control, but I rather suspect ListBox
isn’t the only issue.
&lt;/p&gt;
&lt;p&gt;
I’ve tried all sorts of things on the binding expression - Mode=TwoWay and BindsDirectlyToSource=True.
But they had no impact. It appears that the binding gets a reference to the property
value when it is created and never knows enough to re-read the value later when I
actually need it.
&lt;/p&gt;
&lt;p&gt;
Any ideas?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=8250578a-f9fa-4258-8175-880d65388b80" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,8250578a-f9fa-4258-8175-880d65388b80.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=dac13621-c936-4a6e-88d0-c228fa3aebd6</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,dac13621-c936-4a6e-88d0-c228fa3aebd6.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,dac13621-c936-4a6e-88d0-c228fa3aebd6.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=dac13621-c936-4a6e-88d0-c228fa3aebd6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There’s no DataContextChanged event in Silverlight. And that’s a serious problem for
creating certain types of control, because sometimes you just need to know when your
data context has been changed!
</p>
        <p>
In my case I have the Csla.Silverlight.PropertyStatus control, which listens for events
from the underlying data context object so it knows when to refresh the UI. If the
data context changes, PropertyStatus needs to unhook the events from the old object,
and hook the events on the new object. That means knowing when the data context has
changed.
</p>
        <p>
In version 3.6 we implemented a Source property and required that the data source
be explicitly provided. That was unfortunate, but since it was our own property we
could detect when the value was changed.
</p>
        <p>
I recently did a bunch of research into this topic, trying to find a better answer.
I’d rather hoped that Silverlight 3 would provide an answer, but no such luck…
</p>
        <p>
It turns out that there’s a <strike>hack</strike> solution that does work. Actually
there are a few, but most of them seem terribly complex, and this one seems somewhat
easier to follow.
</p>
        <p>
The basic idea is to create a data binding connection between your DataContext property
and another of your properties. Then when DataContext changes, data binding will change
your property, and you can detect that your property has changed. Rather a hack, but
it works.
</p>
        <p>
In its distilled form, the structure looks like this. First there’s the control class,
which inherits from some framework base class:
</p>
        <blockquote>
          <p>
public class PropertyStatus : ContentControl 
<br />
{ 
</p>
        </blockquote>
        <p>
Then there’s the constructor, which includes a handler for the Loaded event, which
is where the real magic occurs:
</p>
        <blockquote>
          <p>
public PropertyStatus() 
<br />
{ 
<br />
  Loaded += (o, e) =&gt; 
<br />
  { 
<br />
    var b = new System.Windows.Data.Binding(); 
<br />
    this.SetBinding(SourceProperty, b); 
<br />
  }; 
<br />
} 
</p>
        </blockquote>
        <p>
When the control is loaded, a new Binding object is created. This Binding object picks
up the default DataContext value. The Source property is then bound to this new Binding,
which effectively binds it to the default DataContext. Definitely a bit of hackery
here…
</p>
        <p>
Obviously this means there’s a Source property – or at least the shell of one. I don’t
really want a visible Source property, because that would be confusing, but I must
at least implement the DependencyProperty as a public member:
</p>
        <blockquote>
          <p>
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( 
<br />
  "Source", 
<br />
  typeof(object), 
<br />
  typeof(PropertyStatus), 
<br />
  new PropertyMetadata((o, e) =&gt; ((PropertyStatus)o).SetSource(e.OldValue,
e.NewValue))); 
</p>
        </blockquote>
        <p>
I do have a private Source property, though I’ve never found that it is invoked (breakpoints
in the get/set blocks are never hit):
</p>
        <blockquote>
          <p>
private object Source 
<br />
{ 
<br />
  get { return GetValue(SourceProperty); } 
<br />
  set 
<br />
  { 
<br />
    object old = Source; 
<br />
    SetValue(SourceProperty, value); 
<br />
    SetSource(old, value); 
<br />
  } 
<br />
} 
</p>
        </blockquote>
        <p>
The lambda in the static DependencyProperty declaration calls SetSource(), and this
is my “data context changed” notification:
</p>
        <blockquote>
          <p>
private void SetSource(object old, object @new) 
<br />
{ 
<br />
  DetachSource(old); 
<br />
  AttachSource(@new); 
<br />
... 
<br />
} 
</p>
        </blockquote>
        <p>
I suppose this could be generalized into a base class, where SetSource() really raises
a DataContextChanged event. I didn’t find the need for that, as I’ve only got a couple
controls that need to know the data context has changed, and they inherit from different
framework base classes.
</p>
        <p>
The point being, with a little data binding hackery, it is not terribly hard to implement
a method that is invoked when the data context changes. Not as nice as having the
actual event like in WPF, but much nicer than forcing the XAML to explicitly set some
data source property on every control.
</p>
        <p>
(for those interested, this will be changed in CSLA .NET 3.7.1, and it will be a breaking
change because the Source property will go away)
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=dac13621-c936-4a6e-88d0-c228fa3aebd6" />
      </body>
      <title>Adding DataContextChanged in Silverlight</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,dac13621-c936-4a6e-88d0-c228fa3aebd6.aspx</guid>
      <link>http://www.lhotka.net/weblog/AddingDataContextChangedInSilverlight.aspx</link>
      <pubDate>Fri, 31 Jul 2009 21:41:57 GMT</pubDate>
      <description>&lt;p&gt;
There’s no DataContextChanged event in Silverlight. And that’s a serious problem for
creating certain types of control, because sometimes you just need to know when your
data context has been changed!
&lt;/p&gt;
&lt;p&gt;
In my case I have the Csla.Silverlight.PropertyStatus control, which listens for events
from the underlying data context object so it knows when to refresh the UI. If the
data context changes, PropertyStatus needs to unhook the events from the old object,
and hook the events on the new object. That means knowing when the data context has
changed.
&lt;/p&gt;
&lt;p&gt;
In version 3.6 we implemented a Source property and required that the data source
be explicitly provided. That was unfortunate, but since it was our own property we
could detect when the value was changed.
&lt;/p&gt;
&lt;p&gt;
I recently did a bunch of research into this topic, trying to find a better answer.
I’d rather hoped that Silverlight 3 would provide an answer, but no such luck…
&lt;/p&gt;
&lt;p&gt;
It turns out that there’s a &lt;strike&gt;hack&lt;/strike&gt; solution that does work. Actually
there are a few, but most of them seem terribly complex, and this one seems somewhat
easier to follow.
&lt;/p&gt;
&lt;p&gt;
The basic idea is to create a data binding connection between your DataContext property
and another of your properties. Then when DataContext changes, data binding will change
your property, and you can detect that your property has changed. Rather a hack, but
it works.
&lt;/p&gt;
&lt;p&gt;
In its distilled form, the structure looks like this. First there’s the control class,
which inherits from some framework base class:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public class PropertyStatus : ContentControl 
&lt;br /&gt;
{ 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Then there’s the constructor, which includes a handler for the Loaded event, which
is where the real magic occurs:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public PropertyStatus() 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; Loaded += (o, e) =&amp;gt; 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; var b = new System.Windows.Data.Binding(); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; this.SetBinding(SourceProperty, b); 
&lt;br /&gt;
&amp;#160; }; 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
When the control is loaded, a new Binding object is created. This Binding object picks
up the default DataContext value. The Source property is then bound to this new Binding,
which effectively binds it to the default DataContext. Definitely a bit of hackery
here…
&lt;/p&gt;
&lt;p&gt;
Obviously this means there’s a Source property – or at least the shell of one. I don’t
really want a visible Source property, because that would be confusing, but I must
at least implement the DependencyProperty as a public member:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( 
&lt;br /&gt;
&amp;#160; &amp;quot;Source&amp;quot;, 
&lt;br /&gt;
&amp;#160; typeof(object), 
&lt;br /&gt;
&amp;#160; typeof(PropertyStatus), 
&lt;br /&gt;
&amp;#160; new PropertyMetadata((o, e) =&amp;gt; ((PropertyStatus)o).SetSource(e.OldValue,
e.NewValue))); 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I do have a private Source property, though I’ve never found that it is invoked (breakpoints
in the get/set blocks are never hit):
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
private object Source 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; get { return GetValue(SourceProperty); } 
&lt;br /&gt;
&amp;#160; set 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; object old = Source; 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; SetValue(SourceProperty, value); 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; SetSource(old, value); 
&lt;br /&gt;
&amp;#160; } 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The lambda in the static DependencyProperty declaration calls SetSource(), and this
is my “data context changed” notification:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
private void SetSource(object old, object @new) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;#160; DetachSource(old); 
&lt;br /&gt;
&amp;#160; AttachSource(@new); 
&lt;br /&gt;
... 
&lt;br /&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I suppose this could be generalized into a base class, where SetSource() really raises
a DataContextChanged event. I didn’t find the need for that, as I’ve only got a couple
controls that need to know the data context has changed, and they inherit from different
framework base classes.
&lt;/p&gt;
&lt;p&gt;
The point being, with a little data binding hackery, it is not terribly hard to implement
a method that is invoked when the data context changes. Not as nice as having the
actual event like in WPF, but much nicer than forcing the XAML to explicitly set some
data source property on every control.
&lt;/p&gt;
&lt;p&gt;
(for those interested, this will be changed in CSLA .NET 3.7.1, and it will be a breaking
change because the Source property will go away)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=dac13621-c936-4a6e-88d0-c228fa3aebd6" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,dac13621-c936-4a6e-88d0-c228fa3aebd6.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=e550e8f1-9d50-41ed-8ffe-ef87a11f90f6</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,e550e8f1-9d50-41ed-8ffe-ef87a11f90f6.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,e550e8f1-9d50-41ed-8ffe-ef87a11f90f6.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=e550e8f1-9d50-41ed-8ffe-ef87a11f90f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The current contender for the pattern to displace IoC as “the trendy pattern” is MVVM:
Model-View-ViewModel.
</p>
        <p>
MVVM, often called the ViewModel pattern, <strike>has its origins in Silverlight,
and to a lesser degree WPF</strike> has murky origins (maybe Expression Blend,
Smalltalk or from aliens in the 8th dimension). It applies well to Silverlight
and WPF, because those environments use XAML to describe the actual user presentation,
and there’s a very valid desire to avoid having any code-behind a XAML page. A traditional
MVC or MVP model isn’t sufficient to accomplish that goal (at least not efficiently),
because it is often necessary to have some “glue code” between the View and the Model,
even when using data binding.
</p>
        <p>
The challenge is that some Models aren’t shaped correctly to support the View, so
something needs to reshape them. And ideally there’d be some way (WPF commanding or
similar) to “data bind” button click events, and other events, to some code other
than code-behind. The idea being that when a user selects an item in a ListBox, the
code that runs in response isn’t in the code-behind.
</p>
        <p>
The idea behind ViewModel is to create a XAML-friendly object that sits between the
View and the Model, so there’s a place for what would have been code-behind to go
into a testable object. The ViewModel becomes the container for the code-behind, but
it isn’t code-behind. Clearly the ViewModel object is part of the UI layer, so the
architecture is something like this.
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_2.png">
            <img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_thumb.png" width="341" height="141" />
          </a>
        </p>
        <p>
It turns out that there are various ways of thinking about the role of a ViewModel.
I think there are two broad approaches worth considering.
</p>
        <h3>ViewModel as Sole Data Source
</h3>
        <p>
You can set up the ViewModel to be the sole data source for the View. In this case
the ViewModel exposes all the properties and methods necessary to make the View function.
This can work well with an anemic Model, where the Model is composed of a bunch of
dumb data container objects (think DataTable, DTO and most entity objects).
</p>
        <p>
With an anemic data-centric Model it is common to reshape the Model to fit the needs
of the View. And since the Model is anemic, <em>something</em> needs to apply any
business, validation and authorization rules and it surely won’t be the Model itself.
</p>
        <p>
Creating this type of ViewModel is non-trivial, because the ViewModel must use <em>containment
and delegation</em> (a concept familiar to VB6 developers) to literally wrap, reshape
and alter/enhance the behavior of the underlying Model. 
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_4.png">
            <img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_thumb_1.png" width="372" height="77" />
          </a>
        </p>
        <p>
Every Model property must be reimplemented in the ViewModel, or the View won’t have
access to that property. The ViewModel must implement INotifyPropertyChanged, and
very possibly the other data binding interfaces (IDataErrorInfo, IEditableObject,
etc).
</p>
        <p>
In short, the ViewModel will almost certainly become quite large and complex to overcome
the fact that the Model is anemic. 
</p>
        <p>
What’s really sad about this approach, is that the end result will almost certainly
require more code than if you’d just used code-behind. Arguably the result is more
testable, but even that is debatable, since the ViewModel now implements all sorts
of data binding goo and you’ll need to test that as well.
</p>
        <h3>ViewModel as Action Repository
</h3>
        <p>
Another way to think about a ViewModel is to have it be a repository for actions/commands/verbs.
Don’t have it reimplement all the properties from the Model, just have it <em>augment
the Model</em>.
</p>
        <p>
This works well if you already have a rich Model, such as one created using CSLA .NET.
If the Model is composed of objects that already fully support data binding and have
business, validation and authorization rules, it seems silly to reimplement large
chunks of that functionality in a ViewModel.
</p>
        <p>
Instead, have the ViewModel expose the Model as a property, alongside any additional
methods or properties exposed purely by the ViewModel itself.
</p>
        <p>
          <a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_6.png">
            <img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_thumb_2.png" width="367" height="76" />
          </a>
        </p>
        <p>
Again, this presupposes the Model is powerful enough to support direct data binding
to the View, which is the case with CSLA .NET business objects, but may not be the
case with simpler DTO or entity objects (which probably don’t implement IEditableObject,
etc).
</p>
        <p>
        </p>
        <p>
The value to this approach is that the ViewModel is much simpler and doesn’t replicate
large amounts of code that was already written in the Model. Instead, the ViewModel
augments the existing Model functionality by implementing methods to handle View requirements
that aren’t handled by the Model.
</p>
        <p>
For example, the Model may be a list of objects that can be bound to a ListBox control
in the View. When the user double-clicks an item in the ListBox it might be necessary
for the UI to navigate to another form. Clearly that’s not a business layer issue,
so the Model knows nothing about navigation between forms. Typically this would be
handled by a MouseDoubleClick event handler in code-behind the XAML, but we want no
code-behind, so that option is off limits.
</p>
        <p>
Since neither the View nor the Model can handle this double-click scenario, it is
clearly in the purview of the ViewModel. Assuming some way of routing the MouseDoubleClick
event from the XAML to a method on the ViewModel, the ViewModel can simply implement
the method that responds to the user’s action.
</p>
        <p>
This is nice, because the View remains pure XAML, and the Model remains pure business.
The presentation layer concept of navigation is handled by an object (the ViewModel)
who’s sole job is to deal with such presentation layer issues.
</p>
        <h3>Routing XAML Events to a ViewModel
</h3>
        <p>
Regardless of which kind of ViewModel you build, there’s a core assumption that your
XAML can somehow invoke arbitrary methods on the ViewModel in response to arbitrary
actions by the user (basically in response to arbitrary events from XAML controls).
WPF commanding gets you part way there, but it can’t handle arbitrary events from
any XAML control, and so it isn’t a complete answer. And Silverlight has no commanding,
so there’s no answer there.
</p>
        <p>
When we built CSLA .NET for Silverlight, we created something called InvokeMethod,
which is somewhat like WPF commanding, but more flexible. In the upcoming CSLA .NET
3.7.1 release I’m enhancing InvokeMethod to be more flexible, and porting it to WPF
as well. My goal is for InvokeMethod to be able to handle common events from a ListBox,
Button and other common XAML controls to invoke methods on a target object in response.
For the purposes of this blog post, the target object would be a ViewModel.
</p>
        <p>
The ListBox control is interesting to work with, because events like SelectionChanged
or MouseDoubleClick occur on the ListBox control itself, not inside the data template.
There’s no clear or obvious way for the XAML code to pass the selected item(s) as
a parameter to the ViewModel, so what you really need to do is pass a reference to
the ListBox control itself so the ViewModel can pull required information from the
control in response to the event. In my current code, the solution looks like this:
</p>
        <blockquote>
          <p>
&lt;ListBox ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource DataList}" 
<br />
         csla:InvokeMethod.TriggerEvent="SelectionChanged" 
<br />
         csla:InvokeMethod.Resource="{StaticResource
ListModel}" 
<br />
         csla:InvokeMethod.MethodName="ShowItem"/&gt; 
</p>
        </blockquote>
        <p>
Notice that the ItemsSource is a property named Model. This is because the overall
DataContext is my ViewModel object, and it has a Model property that exposes the actual
CSLA .NET business object model. In fact, I have a CslaViewModel&lt;T&gt; base class
that exposes that property, along with a set of actions (Save, Cancel, AddNew, Remove,
Delete) supported by nearly all CSLA .NET objects.
</p>
        <p>
For the InvokeMethod behaviors, the ListModel resource is the ViewModel object, and
it has a method called ShowItem(), which is invoked when the ListBox control raises
a SelectionChanged event:
</p>
        <blockquote>
          <p>
public void ShowItem(object sender, object parameterValue) 
<br />
{ 
<br />
  var lb = (System.Windows.Controls.ListBox)sender; 
<br />
  SelectedData = (Data)lb.SelectedItem; 
<br />
} 
</p>
        </blockquote>
        <p>
The ShowItem() method gets the selected item from the ListBox control and exposes
it via a SelectedData property. I have a detail area of my form that is databound
to SelectedData, so when the user clicks an item in the ListBox, the details of that
item appear in that area of the form. But the ShowItem() method could navigate to
a different form, or bring up a dialog, or do whatever is appropriate for the user
experience.
</p>
        <p>
The point is that the SelectionChanged, or other event, from a XAML control is used
to invoke an arbitrary method on the ViewModel object, thus eliminating the need for
code-behind the XAML.
</p>
        <h3>Why this isn’t Ideal
</h3>
        <p>
My problem with this implementation is that the View and ViewModel are terribly tightly
coupled. The ShowItem() implementation only works if the XAML control is a ListBox.
It feels like all I’ve done here is moved code-behind into another file, which is
not terribly satisfying.
</p>
        <p>
What I really want is for the XAML to pick out the selected item – something like
this pseudocode:
</p>
        <blockquote>
          <p>
&lt;ListBox ItemsSource="{Binding Path=Model}" 
<br />
         ItemTemplate="{StaticResource DataList}" 
<br />
         csla:InvokeMethod.TriggerEvent="SelectionChanged" 
<br />
         csla:InvokeMethod.Resource="{StaticResource
ListModel}" 
<br />
         csla:InvokeMethod.MethodName="ShowItem" 
<br /><strong>         csla:InvokeMethod.MethodParameter="{Element.SelectedItem}"</strong>/&gt;
</p>
        </blockquote>
        <p>
Where “Element” refers to the current XAML control, and “SelectedItem” refers to a
property on that control.
</p>
        <p>
Then the ShowItem() code could be like this:
</p>
        <blockquote>
          <p>
public void ShowItem(object parameterValue) 
<br />
{ 
<br />
  SelectedData = (Data)parameterValue; 
<br />
} 
</p>
        </blockquote>
        <p>
Which would be much better, since the ViewModel is now unaware of the XAML control
that triggered this method, so there’s much looser coupling.
</p>
        <p>
There’s no direct concept for what I’m suggesting built into XAML, so I can’t quite
do what I’m showing above. The “{}” syntax is reserved by XAML for data binding. But
I’m hopeful that I can make InvokeMethod do something similar by having a special
syntax for the MethodParameter value, using characters that aren’t reserved by XAML
data binding. Perhaps:
</p>
        <blockquote>
          <p>
csla:InvokeMethod.MethodParameter=”[[Element.SelectedItem]]”
</p>
        </blockquote>
        <p>
Or maybe more elegant would be a different property:
</p>
        <blockquote>
          <p>
csla:InvokeMethod.ElementParameter=”SelectedItem”
</p>
        </blockquote>
        <p>
Anyway, I think this is an important thing to solve, otherwise the ViewModel is just
a more complicated form of code-behind, which seems counter-productive.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=e550e8f1-9d50-41ed-8ffe-ef87a11f90f6" />
      </body>
      <title>Initial thoughts on MVVM</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,e550e8f1-9d50-41ed-8ffe-ef87a11f90f6.aspx</guid>
      <link>http://www.lhotka.net/weblog/InitialThoughtsOnMVVM.aspx</link>
      <pubDate>Fri, 31 Jul 2009 15:44:09 GMT</pubDate>
      <description>&lt;p&gt;
The current contender for the pattern to displace IoC as “the trendy pattern” is MVVM:
Model-View-ViewModel.
&lt;/p&gt;
&lt;p&gt;
MVVM, often called the ViewModel pattern, &lt;strike&gt;has its origins in Silverlight,
and to a lesser degree WPF&lt;/strike&gt; has&amp;nbsp;murky origins (maybe Expression Blend,
Smalltalk or from aliens in the 8th dimension).&amp;nbsp;It applies well to Silverlight
and WPF, because those environments use XAML to describe the actual user presentation,
and there’s a very valid desire to avoid having any code-behind a XAML page. A traditional
MVC or MVP model isn’t sufficient to accomplish that goal (at least not efficiently),
because it is often necessary to have some “glue code” between the View and the Model,
even when using data binding.
&lt;/p&gt;
&lt;p&gt;
The challenge is that some Models aren’t shaped correctly to support the View, so
something needs to reshape them. And ideally there’d be some way (WPF commanding or
similar) to “data bind” button click events, and other events, to some code other
than code-behind. The idea being that when a user selects an item in a ListBox, the
code that runs in response isn’t in the code-behind.
&lt;/p&gt;
&lt;p&gt;
The idea behind ViewModel is to create a XAML-friendly object that sits between the
View and the Model, so there’s a place for what would have been code-behind to go
into a testable object. The ViewModel becomes the container for the code-behind, but
it isn’t code-behind. Clearly the ViewModel object is part of the UI layer, so the
architecture is something like this.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_2.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_thumb.png" width=341 height=141&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
It turns out that there are various ways of thinking about the role of a ViewModel.
I think there are two broad approaches worth considering.
&lt;/p&gt;
&lt;h3&gt;ViewModel as Sole Data Source
&lt;/h3&gt;
&lt;p&gt;
You can set up the ViewModel to be the sole data source for the View. In this case
the ViewModel exposes all the properties and methods necessary to make the View function.
This can work well with an anemic Model, where the Model is composed of a bunch of
dumb data container objects (think DataTable, DTO and most entity objects).
&lt;/p&gt;
&lt;p&gt;
With an anemic data-centric Model it is common to reshape the Model to fit the needs
of the View. And since the Model is anemic, &lt;em&gt;something&lt;/em&gt; needs to apply any
business, validation and authorization rules and it surely won’t be the Model itself.
&lt;/p&gt;
&lt;p&gt;
Creating this type of ViewModel is non-trivial, because the ViewModel must use &lt;em&gt;containment
and delegation&lt;/em&gt; (a concept familiar to VB6 developers) to literally wrap, reshape
and alter/enhance the behavior of the underlying Model. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_4.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_thumb_1.png" width=372 height=77&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Every Model property must be reimplemented in the ViewModel, or the View won’t have
access to that property. The ViewModel must implement INotifyPropertyChanged, and
very possibly the other data binding interfaces (IDataErrorInfo, IEditableObject,
etc).
&lt;/p&gt;
&lt;p&gt;
In short, the ViewModel will almost certainly become quite large and complex to overcome
the fact that the Model is anemic. 
&lt;/p&gt;
&lt;p&gt;
What’s really sad about this approach, is that the end result will almost certainly
require more code than if you’d just used code-behind. Arguably the result is more
testable, but even that is debatable, since the ViewModel now implements all sorts
of data binding goo and you’ll need to test that as well.
&lt;/p&gt;
&lt;h3&gt;ViewModel as Action Repository
&lt;/h3&gt;
&lt;p&gt;
Another way to think about a ViewModel is to have it be a repository for actions/commands/verbs.
Don’t have it reimplement all the properties from the Model, just have it &lt;em&gt;augment
the Model&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
This works well if you already have a rich Model, such as one created using CSLA .NET.
If the Model is composed of objects that already fully support data binding and have
business, validation and authorization rules, it seems silly to reimplement large
chunks of that functionality in a ViewModel.
&lt;/p&gt;
&lt;p&gt;
Instead, have the ViewModel expose the Model as a property, alongside any additional
methods or properties exposed purely by the ViewModel itself.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_6.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/InitialthoughtsonMVVM_96DC/image_thumb_2.png" width=367 height=76&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Again, this presupposes the Model is powerful enough to support direct data binding
to the View, which is the case with CSLA .NET business objects, but may not be the
case with simpler DTO or entity objects (which probably don’t implement IEditableObject,
etc).
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The value to this approach is that the ViewModel is much simpler and doesn’t replicate
large amounts of code that was already written in the Model. Instead, the ViewModel
augments the existing Model functionality by implementing methods to handle View requirements
that aren’t handled by the Model.
&lt;/p&gt;
&lt;p&gt;
For example, the Model may be a list of objects that can be bound to a ListBox control
in the View. When the user double-clicks an item in the ListBox it might be necessary
for the UI to navigate to another form. Clearly that’s not a business layer issue,
so the Model knows nothing about navigation between forms. Typically this would be
handled by a MouseDoubleClick event handler in code-behind the XAML, but we want no
code-behind, so that option is off limits.
&lt;/p&gt;
&lt;p&gt;
Since neither the View nor the Model can handle this double-click scenario, it is
clearly in the purview of the ViewModel. Assuming some way of routing the MouseDoubleClick
event from the XAML to a method on the ViewModel, the ViewModel can simply implement
the method that responds to the user’s action.
&lt;/p&gt;
&lt;p&gt;
This is nice, because the View remains pure XAML, and the Model remains pure business.
The presentation layer concept of navigation is handled by an object (the ViewModel)
who’s sole job is to deal with such presentation layer issues.
&lt;/p&gt;
&lt;h3&gt;Routing XAML Events to a ViewModel
&lt;/h3&gt;
&lt;p&gt;
Regardless of which kind of ViewModel you build, there’s a core assumption that your
XAML can somehow invoke arbitrary methods on the ViewModel in response to arbitrary
actions by the user (basically in response to arbitrary events from XAML controls).
WPF commanding gets you part way there, but it can’t handle arbitrary events from
any XAML control, and so it isn’t a complete answer. And Silverlight has no commanding,
so there’s no answer there.
&lt;/p&gt;
&lt;p&gt;
When we built CSLA .NET for Silverlight, we created something called InvokeMethod,
which is somewhat like WPF commanding, but more flexible. In the upcoming CSLA .NET
3.7.1 release I’m enhancing InvokeMethod to be more flexible, and porting it to WPF
as well. My goal is for InvokeMethod to be able to handle common events from a ListBox,
Button and other common XAML controls to invoke methods on a target object in response.
For the purposes of this blog post, the target object would be a ViewModel.
&lt;/p&gt;
&lt;p&gt;
The ListBox control is interesting to work with, because events like SelectionChanged
or MouseDoubleClick occur on the ListBox control itself, not inside the data template.
There’s no clear or obvious way for the XAML code to pass the selected item(s) as
a parameter to the ViewModel, so what you really need to do is pass a reference to
the ListBox control itself so the ViewModel can pull required information from the
control in response to the event. In my current code, the solution looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox ItemsSource="{Binding Path=Model}" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ItemTemplate="{StaticResource DataList}" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.TriggerEvent="SelectionChanged" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.Resource="{StaticResource
ListModel}" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.MethodName="ShowItem"/&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Notice that the ItemsSource is a property named Model. This is because the overall
DataContext is my ViewModel object, and it has a Model property that exposes the actual
CSLA .NET business object model. In fact, I have a CslaViewModel&amp;lt;T&amp;gt; base class
that exposes that property, along with a set of actions (Save, Cancel, AddNew, Remove,
Delete) supported by nearly all CSLA .NET objects.
&lt;/p&gt;
&lt;p&gt;
For the InvokeMethod behaviors, the ListModel resource is the ViewModel object, and
it has a method called ShowItem(), which is invoked when the ListBox control raises
a SelectionChanged event:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ShowItem(object sender, object parameterValue) 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp; var lb = (System.Windows.Controls.ListBox)sender; 
&lt;br&gt;
&amp;nbsp; SelectedData = (Data)lb.SelectedItem; 
&lt;br&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The ShowItem() method gets the selected item from the ListBox control and exposes
it via a SelectedData property. I have a detail area of my form that is databound
to SelectedData, so when the user clicks an item in the ListBox, the details of that
item appear in that area of the form. But the ShowItem() method could navigate to
a different form, or bring up a dialog, or do whatever is appropriate for the user
experience.
&lt;/p&gt;
&lt;p&gt;
The point is that the SelectionChanged, or other event, from a XAML control is used
to invoke an arbitrary method on the ViewModel object, thus eliminating the need for
code-behind the XAML.
&lt;/p&gt;
&lt;h3&gt;Why this isn’t Ideal
&lt;/h3&gt;
&lt;p&gt;
My problem with this implementation is that the View and ViewModel are terribly tightly
coupled. The ShowItem() implementation only works if the XAML control is a ListBox.
It feels like all I’ve done here is moved code-behind into another file, which is
not terribly satisfying.
&lt;/p&gt;
&lt;p&gt;
What I really want is for the XAML to pick out the selected item – something like
this pseudocode:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;ListBox ItemsSource="{Binding Path=Model}" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ItemTemplate="{StaticResource DataList}" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.TriggerEvent="SelectionChanged" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.Resource="{StaticResource
ListModel}" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.MethodName="ShowItem" 
&lt;br&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.MethodParameter="{Element.SelectedItem}"&lt;/strong&gt;/&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Where “Element” refers to the current XAML control, and “SelectedItem” refers to a
property on that control.
&lt;/p&gt;
&lt;p&gt;
Then the ShowItem() code could be like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ShowItem(object parameterValue) 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp; SelectedData = (Data)parameterValue; 
&lt;br&gt;
} 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Which would be much better, since the ViewModel is now unaware of the XAML control
that triggered this method, so there’s much looser coupling.
&lt;/p&gt;
&lt;p&gt;
There’s no direct concept for what I’m suggesting built into XAML, so I can’t quite
do what I’m showing above. The “{}” syntax is reserved by XAML for data binding. But
I’m hopeful that I can make InvokeMethod do something similar by having a special
syntax for the MethodParameter value, using characters that aren’t reserved by XAML
data binding. Perhaps:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
csla:InvokeMethod.MethodParameter=”[[Element.SelectedItem]]”
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Or maybe more elegant would be a different property:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
csla:InvokeMethod.ElementParameter=”SelectedItem”
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Anyway, I think this is an important thing to solve, otherwise the ViewModel is just
a more complicated form of code-behind, which seems counter-productive.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=e550e8f1-9d50-41ed-8ffe-ef87a11f90f6" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,e550e8f1-9d50-41ed-8ffe-ef87a11f90f6.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=4393f064-af1b-41df-b733-8ade3949b4d8</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,4393f064-af1b-41df-b733-8ade3949b4d8.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,4393f064-af1b-41df-b733-8ade3949b4d8.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=4393f064-af1b-41df-b733-8ade3949b4d8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have released CSLA .NET version 3.7, with support for Silverlight 3.
</p>
        <p>
This is really version 3.6.3, just tweaked slightly to build on Silverlight 3. It
turns out that the Visual Studio upgrade wizard didn’t properly update the WCF service
reference from Silverlight 2 to Silverlight 3, so I had to rereference the data portal
service. I also took this opportunity to fix a couple minor bugs, so check the change
logs.
</p>
        <ol>
          <li>
If you are a CSLA .NET for Windows user, there’s just one minor change to CslaDataProvider,
otherwise 3.7 really is 3.6.3. 
</li>
          <li>
If you are a CSLA .NET for Silverlight user, there are a couple minor bug fixes in
CslaDataProvider and Navigator, and 3.7 builds with Silverlight 3. Otherwise 3.7 is
3.6.3. 
</li>
        </ol>
        <p>
In other words, moving from 3.6.3 to 3.7 should be painless.
</p>
        <p>
Downloads are here:
</p>
        <ul>
          <li>
            <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA .NET for Windows</a>
          </li>
          <li>
            <a href="http://www.lhotka.net/cslalight/download.aspx">CSLA .NET for Silverlight</a>
          </li>
        </ul>
        <p>
At this point the 3.6.x branch is frozen, and all future work will occur in 3.7.x
until I start working on 4.0 later this year.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4393f064-af1b-41df-b733-8ade3949b4d8" />
      </body>
      <title>CSLA .NET 3.7 released with Silverlight 3 support</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,4393f064-af1b-41df-b733-8ade3949b4d8.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANET37ReleasedWithSilverlight3Support.aspx</link>
      <pubDate>Tue, 21 Jul 2009 15:45:08 GMT</pubDate>
      <description>&lt;p&gt;
I have released CSLA .NET version 3.7, with support for Silverlight 3.
&lt;/p&gt;
&lt;p&gt;
This is really version 3.6.3, just tweaked slightly to build on Silverlight 3. It
turns out that the Visual Studio upgrade wizard didn’t properly update the WCF service
reference from Silverlight 2 to Silverlight 3, so I had to rereference the data portal
service. I also took this opportunity to fix a couple minor bugs, so check the change
logs.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
If you are a CSLA .NET for Windows user, there’s just one minor change to CslaDataProvider,
otherwise 3.7 really is 3.6.3. 
&lt;li&gt;
If you are a CSLA .NET for Silverlight user, there are a couple minor bug fixes in
CslaDataProvider and Navigator, and 3.7 builds with Silverlight 3. Otherwise 3.7 is
3.6.3. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
In other words, moving from 3.6.3 to 3.7 should be painless.
&lt;/p&gt;
&lt;p&gt;
Downloads are here:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA .NET for Windows&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslalight/download.aspx"&gt;CSLA .NET for Silverlight&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
At this point the 3.6.x branch is frozen, and all future work will occur in 3.7.x
until I start working on 4.0 later this year.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4393f064-af1b-41df-b733-8ade3949b4d8" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,4393f064-af1b-41df-b733-8ade3949b4d8.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=abdcc896-a0f8-4f41-95d8-d4886c29ffbe</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,abdcc896-a0f8-4f41-95d8-d4886c29ffbe.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,abdcc896-a0f8-4f41-95d8-d4886c29ffbe.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=abdcc896-a0f8-4f41-95d8-d4886c29ffbe</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
You’ve probably noticed that Microsoft released Silverlight 3 today. More information
can be found at
</p>
        <ul>
          <li>
            <a href="http://www.silverlight.net">www.silverlight.net</a>
          </li>
          <li>
            <a href="http://www.seethelight.com">www.seethelight.com</a>
          </li>
        </ul>
        <p>
I’ve put a very stable beta of CSLA .NET 3.7 online as well
</p>
        <ul>
          <li>
            <a href="http://www.lhotka.net/cslalight/download.aspx">CSLA .NET for Silverlight</a>
          </li>
          <li>
            <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA .NET for Windows</a>
          </li>
        </ul>
        <p>
Version 3.7 is really the same code as 3.6.3, but it builds with the Silverlight 3
tools for Visual Studio 2008. So while I’m calling it a beta, it is really release-quality
code for all intents and purposes.
</p>
        <p>
If you are a Windows/.NET user of CSLA .NET, you’ll find that all future bug fixes,
enhancements and so forth will be in version 3.7. Version 3.6.3 is the last 3.6 version.
</p>
        <p>
If you are a Silverlight user of CSLA .NET, and continue to use the Silverlight 2
tools, 3.6.x is still for you, but I plan to address only the most critical bugs in
that version – and I’m not currently aware of anything at that level. So 3.6.3 is
really the end for Silverilght 2 as well.
</p>
        <p>
In short, 3.7 is now the active development target for any real work, and you should
plan to upgrade to it when possible.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=abdcc896-a0f8-4f41-95d8-d4886c29ffbe" />
      </body>
      <title>Silverlight 3 and CSLA .NET 3.7</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,abdcc896-a0f8-4f41-95d8-d4886c29ffbe.aspx</guid>
      <link>http://www.lhotka.net/weblog/Silverlight3AndCSLANET37.aspx</link>
      <pubDate>Fri, 10 Jul 2009 17:46:31 GMT</pubDate>
      <description>&lt;p&gt;
You’ve probably noticed that Microsoft released Silverlight 3 today. More information
can be found at
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.silverlight.net"&gt;www.silverlight.net&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.seethelight.com"&gt;www.seethelight.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I’ve put a very stable beta of CSLA .NET 3.7 online as well
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslalight/download.aspx"&gt;CSLA .NET for Silverlight&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA .NET for Windows&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Version 3.7 is really the same code as 3.6.3, but it builds with the Silverlight 3
tools for Visual Studio 2008. So while I’m calling it a beta, it is really release-quality
code for all intents and purposes.
&lt;/p&gt;
&lt;p&gt;
If you are a Windows/.NET user of CSLA .NET, you’ll find that all future bug fixes,
enhancements and so forth will be in version 3.7. Version 3.6.3 is the last 3.6 version.
&lt;/p&gt;
&lt;p&gt;
If you are a Silverlight user of CSLA .NET, and continue to use the Silverlight 2
tools, 3.6.x is still for you, but I plan to address only the most critical bugs in
that version – and I’m not currently aware of anything at that level. So 3.6.3 is
really the end for Silverilght 2 as well.
&lt;/p&gt;
&lt;p&gt;
In short, 3.7 is now the active development target for any real work, and you should
plan to upgrade to it when possible.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=abdcc896-a0f8-4f41-95d8-d4886c29ffbe" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,abdcc896-a0f8-4f41-95d8-d4886c29ffbe.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=4e53f604-e94e-40ec-810d-6ca6d76220bb</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,4e53f604-e94e-40ec-810d-6ca6d76220bb.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,4e53f604-e94e-40ec-810d-6ca6d76220bb.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=4e53f604-e94e-40ec-810d-6ca6d76220bb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve observed, in broad strokes, a pattern over the past 20 years or so.
</p>
        <p>
At one time there was DOS (though I was a happy VAX/VMS developer at the time, and
so didn’t suffer the pain of DOS).
</p>
        <p>
Then there was Windows, which ran on DOS (sadly I did have to deal with this world).
</p>
        <p>
Then we booted into Windows, which had a “DOS command prompt” window, so DOS ran on
Windows (and the world got better).
</p>
        <p>
Windows lasted a long time, but then came .NET, which ran on Windows.
</p>
        <p>
I always expected that we’d see the time come when we’d boot into .NET, and Windows
would run on .NET.
</p>
        <p>
I no longer think that’s likely. Which is too bad, because that would have been cool.
</p>
        <p>
But in the late 1990’s there was the very real possibility that the <em>browser would
become the OS</em>. The dot-bomb crash eliminated that debate, robbing the browser-based
company’s of their funding and allowing Windows, Linux and Mac OS to continue to dominate.
</p>
        <p>
In the past 2-3 years though, we’ve seen something different. Flash/Flex/Air, Silverlight
and Google Gears have shown that the “browser as the OS” idea didn’t go away, it just
went to sleep for a while.
</p>
        <p>
Now I’ll suggest that there are really two camps here. There’s the Google camp that
really wants the browser as the OS. And there’s the Adobe/Microsoft camp (can I put
them together?) that realizes that the technology of the web is really a stack of
hacks, and that it is high time to move on to the next big thing. My bias is clearly
toward the next big thing, and has been since the web started being misused as an
app platform in the 1990’s. They are proposing the mini-runtime-as-the-OS concept,
using the browser as a simple launch-pad for the real runtime.
</p>
        <p>
But either way, the concept of a “client OS” has been fading for some years now in
my view. Or conversely, the concept of “all my apps run in ‘the browser’” has been
ascending steadily and rapidly over the past 2-3 years.
</p>
        <p>
And I’m OK with this, because we’re not talking about reducing all apps to stupid
browser-based mainframe-with-color architectures like the web has tried to do for
over a decade.
</p>
        <p>
No! We’re talking about full-blown smart-client technologies like Silverlight, where
the client application can be an edge application in a service-oriented system, or
the client tier of an n-tier application. We’re talking about the resurgence of the
incredible productivity and scalability offered by the n-tier technologies of 1997-98.
We’re talking about getting our industry back on track, so we can look back at 1999-2009
as nothing more than a “lost decade”.
</p>
        <p>
(can you tell I think the terminal-based browser model is really lame?)
</p>
        <p>
Does this mean that Windows, Mac OS and Linux become less relevant? I think so. Does
this mean that Silverlight is the most important technology Microsoft is currently
building? I think so.
</p>
        <p>
Consider that Silverlight, in a &lt;5 meg runtime, provides everything you need to
build most types of powerful smart-client business applications. And consider that
these applications auto-deploy and auto-update in a way that the user never sees the
deploy/update process. Totally smooth and transparent.
</p>
        <p>
Consider that you can write your C# or VB code and run it on the client. Or on the
server. Or both (see <a href="http://www.lhotka.net/cslalight/">CSLA .NET for Silverlight</a> if
you want to know more). You don’t need to learn JavaScript. You don’t need a totally
different language and runtime on the client from the server. Silverlight provides
a decent level of consistency between client and server, so you can reuse code, and
absolutely reuse skills, knowledge and tools.
</p>
        <p>
Google is totally on the bandwagon of course. Many people have seen their strategy
for months, if not years. And we’re now seeing it come through, as they start to make
their <em>browser is the OS</em> play in earnest.
</p>
        <p>
What’s interesting to me, is that in either case – the browser-as-OS (Google) or the
mini-runtime-as-OS (Silverlight) – leaves the previous generation OS concept (Windows/Mac/Linux)
out of the loop.
</p>
        <p>
Windows 7, perhaps the best version of Windows ever created, might be the last great
hurrah for the legacy OS concept.
</p>
        <p>
I mean all we need now is a Silverlight-based version of Office (to compete with Google
Apps) and the underlying “OS” beneath Silverlight becomes rapidly irrelevant...
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4e53f604-e94e-40ec-810d-6ca6d76220bb" />
      </body>
      <title>OS evolution</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,4e53f604-e94e-40ec-810d-6ca6d76220bb.aspx</guid>
      <link>http://www.lhotka.net/weblog/OSEvolution.aspx</link>
      <pubDate>Wed, 08 Jul 2009 16:45:44 GMT</pubDate>
      <description>&lt;p&gt;
I’ve observed, in broad strokes, a pattern over the past 20 years or so.
&lt;/p&gt;
&lt;p&gt;
At one time there was DOS (though I was a happy VAX/VMS developer at the time, and
so didn’t suffer the pain of DOS).
&lt;/p&gt;
&lt;p&gt;
Then there was Windows, which ran on DOS (sadly I did have to deal with this world).
&lt;/p&gt;
&lt;p&gt;
Then we booted into Windows, which had a “DOS command prompt” window, so DOS ran on
Windows (and the world got better).
&lt;/p&gt;
&lt;p&gt;
Windows lasted a long time, but then came .NET, which ran on Windows.
&lt;/p&gt;
&lt;p&gt;
I always expected that we’d see the time come when we’d boot into .NET, and Windows
would run on .NET.
&lt;/p&gt;
&lt;p&gt;
I no longer think that’s likely. Which is too bad, because that would have been cool.
&lt;/p&gt;
&lt;p&gt;
But in the late 1990’s there was the very real possibility that the &lt;em&gt;browser would
become the OS&lt;/em&gt;. The dot-bomb crash eliminated that debate, robbing the browser-based
company’s of their funding and allowing Windows, Linux and Mac OS to continue to dominate.
&lt;/p&gt;
&lt;p&gt;
In the past 2-3 years though, we’ve seen something different. Flash/Flex/Air, Silverlight
and Google Gears have shown that the “browser as the OS” idea didn’t go away, it just
went to sleep for a while.
&lt;/p&gt;
&lt;p&gt;
Now I’ll suggest that there are really two camps here. There’s the Google camp that
really wants the browser as the OS. And there’s the Adobe/Microsoft camp (can I put
them together?) that realizes that the technology of the web is really a stack of
hacks, and that it is high time to move on to the next big thing. My bias is clearly
toward the next big thing, and has been since the web started being misused as an
app platform in the 1990’s. They are proposing the mini-runtime-as-the-OS concept,
using the browser as a simple launch-pad for the real runtime.
&lt;/p&gt;
&lt;p&gt;
But either way, the concept of a “client OS” has been fading for some years now in
my view. Or conversely, the concept of “all my apps run in ‘the browser’” has been
ascending steadily and rapidly over the past 2-3 years.
&lt;/p&gt;
&lt;p&gt;
And I’m OK with this, because we’re not talking about reducing all apps to stupid
browser-based mainframe-with-color architectures like the web has tried to do for
over a decade.
&lt;/p&gt;
&lt;p&gt;
No! We’re talking about full-blown smart-client technologies like Silverlight, where
the client application can be an edge application in a service-oriented system, or
the client tier of an n-tier application. We’re talking about the resurgence of the
incredible productivity and scalability offered by the n-tier technologies of 1997-98.
We’re talking about getting our industry back on track, so we can look back at 1999-2009
as nothing more than a “lost decade”.
&lt;/p&gt;
&lt;p&gt;
(can you tell I think the terminal-based browser model is really lame?)
&lt;/p&gt;
&lt;p&gt;
Does this mean that Windows, Mac OS and Linux become less relevant? I think so. Does
this mean that Silverlight is the most important technology Microsoft is currently
building? I think so.
&lt;/p&gt;
&lt;p&gt;
Consider that Silverlight, in a &amp;lt;5 meg runtime, provides everything you need to
build most types of powerful smart-client business applications. And consider that
these applications auto-deploy and auto-update in a way that the user never sees the
deploy/update process. Totally smooth and transparent.
&lt;/p&gt;
&lt;p&gt;
Consider that you can write your C# or VB code and run it on the client. Or on the
server. Or both (see &lt;a href="http://www.lhotka.net/cslalight/"&gt;CSLA .NET for Silverlight&lt;/a&gt; if
you want to know more). You don’t need to learn JavaScript. You don’t need a totally
different language and runtime on the client from the server. Silverlight provides
a decent level of consistency between client and server, so you can reuse code, and
absolutely reuse skills, knowledge and tools.
&lt;/p&gt;
&lt;p&gt;
Google is totally on the bandwagon of course. Many people have seen their strategy
for months, if not years. And we’re now seeing it come through, as they start to make
their &lt;em&gt;browser is the OS&lt;/em&gt; play in earnest.
&lt;/p&gt;
&lt;p&gt;
What’s interesting to me, is that in either case – the browser-as-OS (Google) or the
mini-runtime-as-OS (Silverlight) – leaves the previous generation OS concept (Windows/Mac/Linux)
out of the loop.
&lt;/p&gt;
&lt;p&gt;
Windows 7, perhaps the best version of Windows ever created, might be the last great
hurrah for the legacy OS concept.
&lt;/p&gt;
&lt;p&gt;
I mean all we need now is a Silverlight-based version of Office (to compete with Google
Apps) and the underlying “OS” beneath Silverlight becomes rapidly irrelevant...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4e53f604-e94e-40ec-810d-6ca6d76220bb" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,4e53f604-e94e-40ec-810d-6ca6d76220bb.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=4eccb682-3766-4ee1-85ba-1e261da85b64</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,4eccb682-3766-4ee1-85ba-1e261da85b64.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,4eccb682-3766-4ee1-85ba-1e261da85b64.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=4eccb682-3766-4ee1-85ba-1e261da85b64</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" border="0" align="right" src="http://download.lhotka.net/images/csla_light_video.png" />The <a href="http://store.lhotka.net/">CSLA
.NET for Silverlight video series</a> is now complete! Segment 7, covering authentication
and authorization, is now online and this completes all video segments – over 8 hours
of content!
</p>
        <p>
The CSLA .NET for Silverlight video series is an invaluable resource for getting started
with CSLA .NET on the Silverlight platform. The series starts with the basics of setting
up a Silverlight solution, covers the creation of client-only applications using CSLA
.NET and then moves to a discussion of creating 2-, 3- and 4-tier applications using
CSLA .NET on the client and on the server(s).
</p>
        <p>
Segments 5 and 6 cover CSLA .NET object stereotypes and data access respectively.
These segments are also available for <a href="http://store.lhotka.net/">purchase
as individual videos</a>, because they are useful to any CSLA .NET developer, including
ASP.NET, WPF, Windows Forms and more.
</p>
        <p>
Segment 7 covers the use of Windows authentication, MembershipProvider authentication
and custom authentication using CSLA .NET for Silverlight against an ASP.NET web or
application server. It also covers the use of per-property and per-type authorization
in business classes, and talks about how the PropertyStatus, ObjectStatus and CslaDataProvider
controls interact with those rules.
</p>
        <p>
          <a href="http://store.lhotka.net/">Buy the video series before June 20</a> and save
$50 off the regular purchase price of $300.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4eccb682-3766-4ee1-85ba-1e261da85b64" />
      </body>
      <title>CSLA .NET for Silverlight video series is complete</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,4eccb682-3766-4ee1-85ba-1e261da85b64.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANETForSilverlightVideoSeriesIsComplete.aspx</link>
      <pubDate>Wed, 10 Jun 2009 19:09:50 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" border="0" align="right" src="http://download.lhotka.net/images/csla_light_video.png" /&gt;The &lt;a href="http://store.lhotka.net/"&gt;CSLA
.NET for Silverlight video series&lt;/a&gt; is now complete! Segment 7, covering authentication
and authorization, is now online and this completes all video segments – over 8 hours
of content!
&lt;/p&gt;
&lt;p&gt;
The CSLA .NET for Silverlight video series is an invaluable resource for getting started
with CSLA .NET on the Silverlight platform. The series starts with the basics of setting
up a Silverlight solution, covers the creation of client-only applications using CSLA
.NET and then moves to a discussion of creating 2-, 3- and 4-tier applications using
CSLA .NET on the client and on the server(s).
&lt;/p&gt;
&lt;p&gt;
Segments 5 and 6 cover CSLA .NET object stereotypes and data access respectively.
These segments are also available for &lt;a href="http://store.lhotka.net/"&gt;purchase
as individual videos&lt;/a&gt;, because they are useful to any CSLA .NET developer, including
ASP.NET, WPF, Windows Forms and more.
&lt;/p&gt;
&lt;p&gt;
Segment 7 covers the use of Windows authentication, MembershipProvider authentication
and custom authentication using CSLA .NET for Silverlight against an ASP.NET web or
application server. It also covers the use of per-property and per-type authorization
in business classes, and talks about how the PropertyStatus, ObjectStatus and CslaDataProvider
controls interact with those rules.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://store.lhotka.net/"&gt;Buy the video series before June 20&lt;/a&gt; and save
$50 off the regular purchase price of $300.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4eccb682-3766-4ee1-85ba-1e261da85b64" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,4eccb682-3766-4ee1-85ba-1e261da85b64.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=c0f18c2d-151c-449e-83cc-83b5e295bc29</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,c0f18c2d-151c-449e-83cc-83b5e295bc29.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,c0f18c2d-151c-449e-83cc-83b5e295bc29.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=c0f18c2d-151c-449e-83cc-83b5e295bc29</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" border="0" align="right" src="http://download.lhotka.net/images/csla_light_video.png" />Segment
6 of the <a href="http://store.lhotka.net/">CSLA .NET for Silverlight video series</a> is
now available.
</p>
        <p>
Also, both the <em>Business Object Types</em> and <em>N-Tier Data Access</em> videos
(segments 5 and 6) can now be purchased separately, as each of these segments contains
information valuable to any CSLA .NET developer.
</p>
        <p>
Segment 6 details the various options supported by CSLA .NET for data access in n-tier
scenarios. Watching this video, you will learn how to put data access code into your
business class, or into a separate data access assembly, along with the pros and cons
of each technique. You will also learn about the ObjectFactory attribute and base
class, that can be used to create pluggable data access layers for an application.
</p>
        <p>
This video is 1 hour and 49 minutes in length, so you can imagine just how much great
content exists!
</p>
        <p>
Not only does the video talk about editable objects and child objects and lists, it
covers the common parent-child-grandchild scenario.
</p>
        <p>
And it includes data access code using raw ADO.NET (for performance and long-term
stability) as well as a complete walkthrough using ADO.NET Entity Framework as a data
access layer.
</p>
        <p>
The <a href="http://www.lhotka.net/weblog/ct.ashx?id=0830c6ae-6c93-4b42-8979-1e7dc42ab452&amp;url=http%3a%2f%2fstore.lhotka.net%2f">pre-release
purchase offer</a> of <strong>$50 off the regular price</strong> of $300 is still
available. If you buy before June 20, your price is $250 for the entire video series,
and you get the first 6 (of 7) video segments, nearly 7 hours of content, immediately!
</p>
        <p>
And again, you can purchase segments 5 and 6 individually if you are not interested
in the complete Silverlight video series.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c0f18c2d-151c-449e-83cc-83b5e295bc29" />
      </body>
      <title>CSLA .NET for Silverlight: N-Tier Data Access video available</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,c0f18c2d-151c-449e-83cc-83b5e295bc29.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANETForSilverlightNTierDataAccessVideoAvailable.aspx</link>
      <pubDate>Fri, 05 Jun 2009 22:30:24 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" border="0" align="right" src="http://download.lhotka.net/images/csla_light_video.png" /&gt;Segment
6 of the &lt;a href="http://store.lhotka.net/"&gt;CSLA .NET for Silverlight video series&lt;/a&gt; is
now available.
&lt;/p&gt;
&lt;p&gt;
Also, both the &lt;em&gt;Business Object Types&lt;/em&gt; and &lt;em&gt;N-Tier Data Access&lt;/em&gt; videos
(segments 5 and 6) can now be purchased separately, as each of these segments contains
information valuable to any CSLA .NET developer.
&lt;/p&gt;
&lt;p&gt;
Segment 6 details the various options supported by CSLA .NET for data access in n-tier
scenarios. Watching this video, you will learn how to put data access code into your
business class, or into a separate data access assembly, along with the pros and cons
of each technique. You will also learn about the ObjectFactory attribute and base
class, that can be used to create pluggable data access layers for an application.
&lt;/p&gt;
&lt;p&gt;
This video is 1 hour and 49 minutes in length, so you can imagine just how much great
content exists!
&lt;/p&gt;
&lt;p&gt;
Not only does the video talk about editable objects and child objects and lists, it
covers the common parent-child-grandchild scenario.
&lt;/p&gt;
&lt;p&gt;
And it includes data access code using raw ADO.NET (for performance and long-term
stability) as well as a complete walkthrough using ADO.NET Entity Framework as a data
access layer.
&lt;/p&gt;
&lt;p&gt;
The &lt;a href="http://www.lhotka.net/weblog/ct.ashx?id=0830c6ae-6c93-4b42-8979-1e7dc42ab452&amp;amp;url=http%3a%2f%2fstore.lhotka.net%2f"&gt;pre-release
purchase offer&lt;/a&gt; of &lt;strong&gt;$50 off the regular price&lt;/strong&gt; of $300 is still
available. If you buy before June 20, your price is $250 for the entire video series,
and you get the first 6 (of 7) video segments, nearly 7 hours of content, immediately!
&lt;/p&gt;
&lt;p&gt;
And again, you can purchase segments 5 and 6 individually if you are not interested
in the complete Silverlight video series.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c0f18c2d-151c-449e-83cc-83b5e295bc29" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,c0f18c2d-151c-449e-83cc-83b5e295bc29.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
    </item>
  </channel>
</rss>