<?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 - WPF</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=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=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=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=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=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=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=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=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=b68b1fb2-ee8c-478b-a565-8ceba56faedb</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,b68b1fb2-ee8c-478b-a565-8ceba56faedb.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,b68b1fb2-ee8c-478b-a565-8ceba56faedb.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=b68b1fb2-ee8c-478b-a565-8ceba56faedb</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here’s a link to an article I wrote on using code-gen vs building a more dynamic runtime:
</p>
        <p>
          <a title="http://msdn.microsoft.com/en-us/library/ff621668.aspx" href="http://msdn.microsoft.com/en-us/library/ff621668.aspx">http://msdn.microsoft.com/en-us/library/ff621668.aspx</a>
        </p>
        <p>
          <strong>Update: </strong>There doesn't appear to be a code download on the Microsoft
site. <a href="http://www.lhotka.net/files/CodeGen-100510.zip">Click here</a> to download
the code.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=b68b1fb2-ee8c-478b-a565-8ceba56faedb" />
      </body>
      <title>Design Time Code Generation and Runtime Model-Driven Generation</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,b68b1fb2-ee8c-478b-a565-8ceba56faedb.aspx</guid>
      <link>http://www.lhotka.net/weblog/DesignTimeCodeGenerationAndRuntimeModelDrivenGeneration.aspx</link>
      <pubDate>Mon, 19 Apr 2010 05:30:24 GMT</pubDate>
      <description>&lt;p&gt;
Here’s a link to an article I wrote on using code-gen vs building a more dynamic runtime:
&lt;/p&gt;
&lt;p&gt;
&lt;a title=http://msdn.microsoft.com/en-us/library/ff621668.aspx href="http://msdn.microsoft.com/en-us/library/ff621668.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff621668.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Update: &lt;/strong&gt;There doesn't appear to be a code download on the Microsoft
site. &lt;a href="http://www.lhotka.net/files/CodeGen-100510.zip"&gt;Click here&lt;/a&gt; to download
the code.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=b68b1fb2-ee8c-478b-a565-8ceba56faedb" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,b68b1fb2-ee8c-478b-a565-8ceba56faedb.aspx</comments>
      <category>Microsoft .NET</category>
      <category>Programming</category>
      <category>WPF</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=53472720-e2f0-40f2-847b-0ef4736ee6d6</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,53472720-e2f0-40f2-847b-0ef4736ee6d6.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,53472720-e2f0-40f2-847b-0ef4736ee6d6.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=53472720-e2f0-40f2-847b-0ef4736ee6d6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In Visual Studio 2010 and .NET 4.0 Microsoft is amping up the visibility of the “client
profile” concept. In fact, when you install the 4.0 client profile on a machine, it
doesn’t drag the rest of the framework to that client later – they just get the client
profile. And when you create a WPF or Windows Forms project in VS10 you default to
targeting the client profile.
</p>
        <p>
That’s all good – great in fact!!
</p>
        <p>
But I’ve fallen in love with the validation attribute concepts in System.ComponentModel.DataAnnotations.dll.
These attributes are designed specifically to enable a UI framework author (or a business
layer framework author – like me with CSLA .NET) to automatically create a rich user
experience based on the attributes decorating business objects.
</p>
        <p>
This concept was first fully realized in Silverlight 3 – a client technology – and
is now fully supported in .NET 4.0 <em>full profile</em>. But it is a <em>client side
technology</em>, and so should be in the client profile.
</p>
        <p>
I’ve logged this issue on connect, and recommend you vote for this to be resolved:
</p>
        <p>
          <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=502807">https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=502807</a>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=53472720-e2f0-40f2-847b-0ef4736ee6d6" />
      </body>
      <title>DataAnnotations not in the client profile</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,53472720-e2f0-40f2-847b-0ef4736ee6d6.aspx</guid>
      <link>http://www.lhotka.net/weblog/DataAnnotationsNotInTheClientProfile.aspx</link>
      <pubDate>Fri, 06 Nov 2009 21:41:13 GMT</pubDate>
      <description>&lt;p&gt;
In Visual Studio 2010 and .NET 4.0 Microsoft is amping up the visibility of the “client
profile” concept. In fact, when you install the 4.0 client profile on a machine, it
doesn’t drag the rest of the framework to that client later – they just get the client
profile. And when you create a WPF or Windows Forms project in VS10 you default to
targeting the client profile.
&lt;/p&gt;
&lt;p&gt;
That’s all good – great in fact!!
&lt;/p&gt;
&lt;p&gt;
But I’ve fallen in love with the validation attribute concepts in System.ComponentModel.DataAnnotations.dll.
These attributes are designed specifically to enable a UI framework author (or a business
layer framework author – like me with CSLA .NET) to automatically create a rich user
experience based on the attributes decorating business objects.
&lt;/p&gt;
&lt;p&gt;
This concept was first fully realized in Silverlight 3 – a client technology – and
is now fully supported in .NET 4.0 &lt;em&gt;full profile&lt;/em&gt;. But it is a &lt;em&gt;client side
technology&lt;/em&gt;, and so should be in the client profile.
&lt;/p&gt;
&lt;p&gt;
I’ve logged this issue on connect, and recommend you vote for this to be resolved:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=502807"&gt;https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=502807&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=53472720-e2f0-40f2-847b-0ef4736ee6d6" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,53472720-e2f0-40f2-847b-0ef4736ee6d6.aspx</comments>
      <category>Microsoft .NET</category>
      <category>Windows Forms</category>
      <category>WPF</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=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=94a79101-70ce-4d57-a6c0-80f512ad7fa6</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,94a79101-70ce-4d57-a6c0-80f512ad7fa6.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,94a79101-70ce-4d57-a6c0-80f512ad7fa6.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=94a79101-70ce-4d57-a6c0-80f512ad7fa6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Since WPF came out there’s been one quirk, one “optimization” in data binding that
has been a serious pain.
</p>
        <p>
Interestingly enough the same quirk is in Windows Forms, but the WPF team tells me
that the reason it is also in WPF is entirely independent from how and why it is in
Windows Forms.
</p>
        <p>
The “optimization” is that when a user changes a value in the UI, say in a TextBox,
that value is then put into the underlying source object’s property (whatever property
is bound to the Text property of the TextBox). If the source object <em>changes the
value in the setter</em> the change will never appear in the UI. Even if the setter
raises PropertyChanged, WPF ignores it and leaves the original (bad) value in the
UI.
</p>
        <p>
To overcome this, you’ve had to put a ValueConverter on every binding expression in
WPF. In CSLA .NET I created an IdentityConverter, which is a value converter that
does nothing, so you can safely attach a converter to a binding when you really didn’t
want a converter there at all, but you were forced into it to overcome this WPF data
binding quirk.
</p>
        <p>
WPF 4.0 fixes the issue. Karl Shifflett describes the change very nicely in <a href="http://karlshifflett.wordpress.com/2009/05/27/wpf-4-0-data-binding-change-great-feature/">this
blog post</a>.
</p>
        <p>
This should mean that I can remove the (rather silly) IdentityConverter class from
CSLA .NET 4.0, and that makes me happy.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=94a79101-70ce-4d57-a6c0-80f512ad7fa6" />
      </body>
      <title>WPF 4.0 Data Binding Fix</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,94a79101-70ce-4d57-a6c0-80f512ad7fa6.aspx</guid>
      <link>http://www.lhotka.net/weblog/WPF40DataBindingFix.aspx</link>
      <pubDate>Wed, 27 May 2009 15:28:10 GMT</pubDate>
      <description>&lt;p&gt;
Since WPF came out there’s been one quirk, one “optimization” in data binding that
has been a serious pain.
&lt;/p&gt;
&lt;p&gt;
Interestingly enough the same quirk is in Windows Forms, but the WPF team tells me
that the reason it is also in WPF is entirely independent from how and why it is in
Windows Forms.
&lt;/p&gt;
&lt;p&gt;
The “optimization” is that when a user changes a value in the UI, say in a TextBox,
that value is then put into the underlying source object’s property (whatever property
is bound to the Text property of the TextBox). If the source object &lt;em&gt;changes the
value in the setter&lt;/em&gt; the change will never appear in the UI. Even if the setter
raises PropertyChanged, WPF ignores it and leaves the original (bad) value in the
UI.
&lt;/p&gt;
&lt;p&gt;
To overcome this, you’ve had to put a ValueConverter on every binding expression in
WPF. In CSLA .NET I created an IdentityConverter, which is a value converter that
does nothing, so you can safely attach a converter to a binding when you really didn’t
want a converter there at all, but you were forced into it to overcome this WPF data
binding quirk.
&lt;/p&gt;
&lt;p&gt;
WPF 4.0 fixes the issue. Karl Shifflett describes the change very nicely in &lt;a href="http://karlshifflett.wordpress.com/2009/05/27/wpf-4-0-data-binding-change-great-feature/"&gt;this
blog post&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
This should mean that I can remove the (rather silly) IdentityConverter class from
CSLA .NET 4.0, and that makes me happy.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=94a79101-70ce-4d57-a6c0-80f512ad7fa6" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,94a79101-70ce-4d57-a6c0-80f512ad7fa6.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=9025b805-a32f-40e0-bfe8-a044ede7be08</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,9025b805-a32f-40e0-bfe8-a044ede7be08.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,9025b805-a32f-40e0-bfe8-a044ede7be08.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=9025b805-a32f-40e0-bfe8-a044ede7be08</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been working extensively with both WPF and Silverlight over the past many months.
Not too long ago, my workstation started having trouble – specifically Visual Studio
2008 was crashing when trying to open XAML files. Not just crashing either; Visual
Studio was <em>disappearing</em> in the blink of an eye.
</p>
        <p>
This started happening every now and then, and became more frequent until it was happening
multiple times a day.
</p>
        <p>
After working with some Microsoft people to try and trace down the problem (which
we never really did – as it is hard to attach a debugger or other diagnostic tool
to VS after it disappears), they suggested I try this patch:
</p>
        <p>
          <a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&amp;wa=wsignin1.0">https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&amp;wa=wsignin1.0</a>
        </p>
        <p>
(the *.msu are for Vista and Server 2008, and *.exe are for XP and Server 2003, <strike>and
the x86 patch should be used for 64 bit machines too</strike></p>
        <p>
          <span style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <strong>Update: </strong>For
x64 users, you should install the x64 patch, and this will update the 32 bit CLR as
part of the installation</span>)
</p>
        <p>
This patch solved my problem. Just like that.
</p>
        <p>
Apparently this patch solves a wider set of problems related to stability when editing
or working with XAML files in Visual Studio, and is a generally good thing to apply
for developers working with WPF and Silverlight.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=9025b805-a32f-40e0-bfe8-a044ede7be08" />
      </body>
      <title>Working with WPF or Silverlight? You need this patch.</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,9025b805-a32f-40e0-bfe8-a044ede7be08.aspx</guid>
      <link>http://www.lhotka.net/weblog/WorkingWithWPFOrSilverlightYouNeedThisPatch.aspx</link>
      <pubDate>Thu, 12 Mar 2009 00:01:23 GMT</pubDate>
      <description>&lt;p&gt;
I have been working extensively with both WPF and Silverlight over the past many months.
Not too long ago, my workstation started having trouble – specifically Visual Studio
2008 was crashing when trying to open XAML files. Not just crashing either; Visual
Studio was &lt;em&gt;disappearing&lt;/em&gt; in the blink of an eye.
&lt;/p&gt;
&lt;p&gt;
This started happening every now and then, and became more frequent until it was happening
multiple times a day.
&lt;/p&gt;
&lt;p&gt;
After working with some Microsoft people to try and trace down the problem (which
we never really did – as it is hard to attach a debugger or other diagnostic tool
to VS after it disappears), they suggested I try this patch:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&amp;amp;wa=wsignin1.0"&gt;https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&amp;amp;wa=wsignin1.0&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
(the *.msu are for Vista and Server 2008, and *.exe are for XP and Server 2003, &lt;strike&gt;and
the x86 patch should be used for 64 bit machines too&lt;/strike&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;strong&gt;Update: &lt;/strong&gt;For
x64 users, you should install the x64 patch, and this will update the 32 bit CLR as
part of the installation&lt;/span&gt;)
&lt;/p&gt;
&lt;p&gt;
This patch solved my problem. Just like that.
&lt;/p&gt;
&lt;p&gt;
Apparently this patch solves a wider set of problems related to stability when editing
or working with XAML files in Visual Studio, and is a generally good thing to apply
for developers working with WPF and Silverlight.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=9025b805-a32f-40e0-bfe8-a044ede7be08" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,9025b805-a32f-40e0-bfe8-a044ede7be08.aspx</comments>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is one tip that any WPF or Silverlight developer can’t be without. Talk about
instant gratification!
</p>
        <p>
          <a title="http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx" href="http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx">http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx</a>
        </p>
        <p>
I wish I’d known about this months ago.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f" />
      </body>
      <title>Life changing tip for XAML editing in Visual Studio</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f.aspx</guid>
      <link>http://www.lhotka.net/weblog/LifeChangingTipForXAMLEditingInVisualStudio.aspx</link>
      <pubDate>Thu, 29 Jan 2009 04:59:24 GMT</pubDate>
      <description>&lt;p&gt;
This is one tip that any WPF or Silverlight developer can’t be without. Talk about
instant gratification!
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx" href="http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx"&gt;http://weblogs.asp.net/fmarguerie/archive/2009/01/29/life-changer-xaml-tip-for-visual-studio.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I wish I’d known about this months ago.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,96fe3a5e-c1d3-4182-b75d-52fd1ec7bf1f.aspx</comments>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=c76d5eb6-ad0e-48fb-abee-28e81736cdcf</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=c76d5eb6-ad0e-48fb-abee-28e81736cdcf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
PDC 2008 was a lot of fun - a big show, with lots of announcements, lots of sessions
and some thought-provoking content. I thought I'd through out a few observations.
Not really conclusions, as those take time and reflection, so just some observations.
</p>
        <p>
          <strong>Windows Azure</strong>, the operating system for the cloud, is intriguing.
For a first run at this, the technology seems surprisingly complete and contains a
pretty reasonable set of features. I can easily see how web sites, XML services and
both data-centric and compute-centric processing could be built for this platform.
For that matter, it looks like it would be perhaps a week's work to get my web site
ported over to run completely in Azure.
</p>
        <p>
The real question is whether that would even make sense, and <em>that</em> comes down
to the value proposition. One big component of value is price. Like anyone else, I
pay a certain amount to run my web site. Electricity, bandwidth, support time, hardware
costs, software costs, etc. I've never really sorted out an exact cost, but it isn't
real high on a per-month basis. And I could host on any number of .NET-friendly hosting
services that have been around for years, and some of them are pretty inexpensive.
So the question becomes whether Azure will be priced in such a way that it is attractive
to me. If so, I'm excited about Azure!! If not, then I really don't care about Azure.
</p>
        <p>
I suspect most attendees went through a similar thought process. If Microsoft prices
Azure for "the enterprise" then 90% of the developers in the world simply don't care
about Azure. But if Microsoft prices Azure for small to mid-size businesses, and for
the very small players (like me) then 90% of the developers in the world should (I
think) really be looking at this technology
</p>
        <p>
          <strong>Windows 7 </strong>looks good to me. After the Tuesday keynote I was ready
to install it <em>now</em>. As time goes by the urgency has faded a bit - Vista has
stabilized nicely over the past 6-8 months and I really like it now. Windows 7 has
some nice-sounding new features though. Probably the single biggest one is reduced
system resource requirements. If Microsoft can deliver on that part of the promise
I'll be totally thrilled. Though I really <em>do</em> want multi-monitor RDP and the
ability to manage, mount (and even boot from) vhd files directly from the host OS.
</p>
        <p>
In talking to friends of mine that work at Microsoft, my level of confidence in W7
is quite high. A couple of them have been running it for some time now, and while
it is clearly pre-beta, they have found it to be a very satisfying experience. When
I get back from all my travels I do think I'll have to buy a spare HD for my laptop
and give it a try myself.
</p>
        <p>
The <strong>Oslo modeling tools</strong> are also interesting, though they are more
future-looking. Realistically this idea of model-driven development will require a
major shift in how our industry thinks about and approaches <a href="http://magenic.com/Services/CustomSoftwareDevelopment.aspx">custom
software development</a>. Such a massive shift will take many years to occur, regardless
of whether the technology is there to enable it. It is admirable that Microsoft is
taking such a gamble - building a set of tools and technologies for something that
might become acceptable to developers in the murky future. Their gamble will pay off
if we collectively decide that the world of 3GL development really is at an end and
that we need to move to higher levels of abstraction. Of course we could decide to
stick with what has (and hasn't) worked for 30+ years, in which case modeling tools
will go the way of CASE.
</p>
        <p>
But even if some of the really forward-looking modeling ideas never become palatable,
many of the things Microsoft is doing to support modeling are immediately useful.
Enhancements to Windows Workflow are a prime example, as is the M language. I've hard
a hard time getting excited about WF, because it has felt like a graphical way to
do FORTRAN. But some of the enhancements to WF directly address my primary concerns,
and I can see myself getting much more interested in WF in the relatively near future.
And the ability of the M language to define other languages (create DSLs), where I
can create my own output generator to create whatever I need - now <em>that</em> is
really, really cool!
</p>
        <p>
Once I get done with my book and all my fall travel, you can bet I'll be exploring
the use of M to create a specialized language to simplify the creation of CSLA .NET
business classes :)
</p>
        <p>
There were numerous talks about <strong>.NET 4.0</strong> and the future of C# and
VB. 
</p>
        <p>
Probably the single biggest thing on the language front is that Microsoft has finally
decided to sync VB and C# so they have feature parity. Enough of this back-and-forth
with different features, the languages will now just move forward together. A few
years ago I would have argued against this, because competition breeds innovation.
But today I don't think it matters, because the innovation is coming from F#, Ruby,
Python and various other languages and initiatives. Both VB and C# have such massive
pre-existing code-bases (all the code we've written) that they can't move rapidly
or explore radical ideas - while some of these other languages are more free to do
just that.
</p>
        <p>
The framework itself has all sorts of changes and improvements. I spent less time
looking at this than at Azure and Oslo though, so I honestly just don't have a lot
to say on it right now. I look at .NET 4.0 and Visual Studio 2010 as being more tactical
- things I'll spend a lot of time on over the next few months anyway - so I didn't
see so much need to spend my time on it during PDC.
</p>
        <p>
Finally, there were announcements around <strong>Silverlight and WPF</strong>. If
anyone doubts that XAML is the future of the UI on Windows and (to some degree) the
web, now is the time to wake up and smell the coffee. I'm obviously convinced Silverlight
is going to rapidly become the default technology for building business apps, with
WPF and Ajax as fallback positions, and everything at the PDC simply reinforced this
viewpoint.
</p>
        <p>
The new Silverlight and WPF toolkits provide better parity between the two XAML dialects,
and show how aggressively Microsoft is working to achieve true parity.
</p>
        <p>
But more important is the Silverlight intersection with Azure and Live Mesh. The fact
that I can build <em>smart client apps</em> that totally host in Azure or the Mesh
is compelling, and puts Silverlight a notch above WPF in terms of being the desired
start-point for app development. Yes, I really like WPF, but even if it can host in
Azure it probably won't host in Mesh, and in neither case will it be as clean or seamless.
</p>
        <p>
So while I fully appreciate that WPF is good for that small percentage of business
apps that need access to DirectX or rich client-side resources, I still think <em>most</em> business
apps will work just fine with access to the monitor/keyboard/mouse/memory/CPU provided
by Silverlight. 
</p>
        <p>
A couple people asked why I think Silverlight is better than Ajax. To me this is drop-dead
simple. I can write a class in C# or VB that runs on the client in Silverlight. I
can write real smart client applications that run in the browser. And I can run that <em>exact
same code</em> on the server too. So I can give the user a very interactive experience,
and then re-run that same code on the server because I don't trust the client.
</p>
        <p>
To do that in Ajax you'd either have to write your code twice (in C# and in Javascript),
or you'd have to do tons of server calls to simulate the interactivity provided by
Silverlight - and that obviously won't scale nearly the same as the more correct Silverlight
solution.
</p>
        <p>
To me it is a no-brainer - Ajax loses when it comes to building interactive business
apps like order entry screens, customer maintenance screens, etc.
</p>
        <p>
That's not to say Ajax has no home. The web and browser world is really good at displaying
data, and Ajax makes data display more interesting that simple HTML. I strongly suspect
that most "Silverlight" apps will make heavy use of HTML/Ajax for data display, but
I just can't see why anyone would willingly choose to create data entry forms or other
interactive parts of their app outside of Silverlight.
</p>
        <p>
And that wraps up my on-the-flight-home summary of thoughts about PDC. 
</p>
        <p>
Next week I'm speaking at the Patterns and Practices Summit in Redmond, and then I'll
be at Tech Ed EMEA in Barcelona. I'm doing a number of sessions at both events, but
what's cool is that at each event I'm doing a talk specifically about CSLA .NET for
Silverlight. And in December I'll be at VS Live in Dallas, where I'll also give a
talk directly on using CSLA .NET.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c76d5eb6-ad0e-48fb-abee-28e81736cdcf" />
      </body>
      <title>Thoughts on PDC 2008</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</guid>
      <link>http://www.lhotka.net/weblog/ThoughtsOnPDC2008.aspx</link>
      <pubDate>Sat, 01 Nov 2008 01:10:16 GMT</pubDate>
      <description>&lt;p&gt;
PDC 2008 was a lot of fun - a big show, with lots of announcements, lots of sessions
and some thought-provoking content. I thought I'd through out a few observations.
Not really conclusions, as those take time and reflection, so just some observations.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Windows Azure&lt;/strong&gt;, the operating system for the cloud, is intriguing.
For a first run at this, the technology seems surprisingly complete and contains a
pretty reasonable set of features. I can easily see how web sites, XML services and
both data-centric and compute-centric processing could be built for this platform.
For that matter, it looks like it would be perhaps a week's work to get my web site
ported over to run completely in Azure.
&lt;/p&gt;
&lt;p&gt;
The real question is whether that would even make sense, and &lt;em&gt;that&lt;/em&gt; comes down
to the value proposition. One big component of value is price. Like anyone else, I
pay a certain amount to run my web site. Electricity, bandwidth, support time, hardware
costs, software costs, etc. I've never really sorted out an exact cost, but it isn't
real high on a per-month basis. And I could host on any number of .NET-friendly hosting
services that have been around for years, and some of them are pretty inexpensive.
So the question becomes whether Azure will be priced in such a way that it is attractive
to me. If so, I'm excited about Azure!! If not, then I really don't care about Azure.
&lt;/p&gt;
&lt;p&gt;
I suspect most attendees went through a similar thought process. If Microsoft prices
Azure for "the enterprise" then 90% of the developers in the world simply don't care
about Azure. But if Microsoft prices Azure for small to mid-size businesses, and for
the very small players (like me) then 90% of the developers in the world should (I
think) really be looking at this technology
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Windows 7 &lt;/strong&gt;looks good to me. After the Tuesday keynote I was ready
to install it &lt;em&gt;now&lt;/em&gt;. As time goes by the urgency has faded a bit - Vista has
stabilized nicely over the past 6-8 months and I really like it now. Windows 7 has
some nice-sounding new features though. Probably the single biggest one is reduced
system resource requirements. If Microsoft can deliver on that part of the promise
I'll be totally thrilled. Though I really &lt;em&gt;do&lt;/em&gt; want multi-monitor RDP and the
ability to manage, mount (and even boot from) vhd files directly from the host OS.
&lt;/p&gt;
&lt;p&gt;
In talking to friends of mine that work at Microsoft, my level of confidence in W7
is quite high. A couple of them have been running it for some time now, and while
it is clearly pre-beta, they have found it to be a very satisfying experience. When
I get back from all my travels I do think I'll have to buy a spare HD for my laptop
and give it a try myself.
&lt;/p&gt;
&lt;p&gt;
The &lt;strong&gt;Oslo modeling tools&lt;/strong&gt; are also interesting, though they are more
future-looking. Realistically this idea of model-driven development will require a
major shift in how our industry thinks about and approaches &lt;a href="http://magenic.com/Services/CustomSoftwareDevelopment.aspx"&gt;custom
software development&lt;/a&gt;. Such a massive shift will take many years to occur, regardless
of whether the technology is there to enable it. It is admirable that Microsoft is
taking such a gamble - building a set of tools and technologies for something that
might become acceptable to developers in the murky future. Their gamble will pay off
if we collectively decide that the world of 3GL development really is at an end and
that we need to move to higher levels of abstraction. Of course we could decide to
stick with what has (and hasn't) worked for 30+ years, in which case modeling tools
will go the way of CASE.
&lt;/p&gt;
&lt;p&gt;
But even if some of the really forward-looking modeling ideas never become palatable,
many of the things Microsoft is doing to support modeling are immediately useful.
Enhancements to Windows Workflow are a prime example, as is the M language. I've hard
a hard time getting excited about WF, because it has felt like a graphical way to
do FORTRAN. But some of the enhancements to WF directly address my primary concerns,
and I can see myself getting much more interested in WF in the relatively near future.
And the ability of the M language to define other languages (create DSLs), where I
can create my own output generator to create whatever I need - now &lt;em&gt;that&lt;/em&gt; is
really, really cool!
&lt;/p&gt;
&lt;p&gt;
Once I get done with my book and all my fall travel, you can bet I'll be exploring
the use of M to create a specialized language to simplify the creation of CSLA .NET
business classes :)
&lt;/p&gt;
&lt;p&gt;
There were numerous talks about &lt;strong&gt;.NET 4.0&lt;/strong&gt; and the future of C# and
VB. 
&lt;/p&gt;
&lt;p&gt;
Probably the single biggest thing on the language front is that Microsoft has finally
decided to sync VB and C# so they have feature parity. Enough of this back-and-forth
with different features, the languages will now just move forward together. A few
years ago I would have argued against this, because competition breeds innovation.
But today I don't think it matters, because the innovation is coming from F#, Ruby,
Python and various other languages and initiatives. Both VB and C# have such massive
pre-existing code-bases (all the code we've written) that they can't move rapidly
or explore radical ideas - while some of these other languages are more free to do
just that.
&lt;/p&gt;
&lt;p&gt;
The framework itself has all sorts of changes and improvements. I spent less time
looking at this than at Azure and Oslo though, so I honestly just don't have a lot
to say on it right now. I look at .NET 4.0 and Visual Studio 2010 as being more tactical
- things I'll spend a lot of time on over the next few months anyway - so I didn't
see so much need to spend my time on it during PDC.
&lt;/p&gt;
&lt;p&gt;
Finally, there were announcements around &lt;strong&gt;Silverlight and WPF&lt;/strong&gt;. If
anyone doubts that XAML is the future of the UI on Windows and (to some degree) the
web, now is the time to wake up and smell the coffee. I'm obviously convinced Silverlight
is going to rapidly become the default technology for building business apps, with
WPF and Ajax as fallback positions, and everything at the PDC simply reinforced this
viewpoint.
&lt;/p&gt;
&lt;p&gt;
The new Silverlight and WPF toolkits provide better parity between the two XAML dialects,
and show how aggressively Microsoft is working to achieve true parity.
&lt;/p&gt;
&lt;p&gt;
But more important is the Silverlight intersection with Azure and Live Mesh. The fact
that I can build &lt;em&gt;smart client apps&lt;/em&gt; that totally host in Azure or the Mesh
is compelling, and puts Silverlight a notch above WPF in terms of being the desired
start-point for app development. Yes, I really like WPF, but even if it can host in
Azure it probably won't host in Mesh, and in neither case will it be as clean or seamless.
&lt;/p&gt;
&lt;p&gt;
So while I fully appreciate that WPF is good for that small percentage of business
apps that need access to DirectX or rich client-side resources, I still think &lt;em&gt;most&lt;/em&gt; business
apps will work just fine with access to the monitor/keyboard/mouse/memory/CPU provided
by Silverlight. 
&lt;/p&gt;
&lt;p&gt;
A couple people asked why I think Silverlight is better than Ajax. To me this is drop-dead
simple. I can write a class in C# or VB that runs on the client in Silverlight. I
can write real smart client applications that run in the browser. And I can run that &lt;em&gt;exact
same code&lt;/em&gt; on the server too. So I can give the user a very interactive experience,
and then re-run that same code on the server because I don't trust the client.
&lt;/p&gt;
&lt;p&gt;
To do that in Ajax you'd either have to write your code twice (in C# and in Javascript),
or you'd have to do tons of server calls to simulate the interactivity provided by
Silverlight - and that obviously won't scale nearly the same as the more correct Silverlight
solution.
&lt;/p&gt;
&lt;p&gt;
To me it is a no-brainer - Ajax loses when it comes to building interactive business
apps like order entry screens, customer maintenance screens, etc.
&lt;/p&gt;
&lt;p&gt;
That's not to say Ajax has no home. The web and browser world is really good at displaying
data, and Ajax makes data display more interesting that simple HTML. I strongly suspect
that most "Silverlight" apps will make heavy use of HTML/Ajax for data display, but
I just can't see why anyone would willingly choose to create data entry forms or other
interactive parts of their app outside of Silverlight.
&lt;/p&gt;
&lt;p&gt;
And that wraps up my on-the-flight-home summary of thoughts about PDC. 
&lt;/p&gt;
&lt;p&gt;
Next week I'm speaking at the Patterns and Practices Summit in Redmond, and then I'll
be at Tech Ed EMEA in Barcelona. I'm doing a number of sessions at both events, but
what's cool is that at each event I'm doing a talk specifically about CSLA .NET for
Silverlight. And in December I'll be at VS Live in Dallas, where I'll also give a
talk directly on using CSLA .NET.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c76d5eb6-ad0e-48fb-abee-28e81736cdcf" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</comments>
      <category>Microsoft .NET</category>
      <category>Silverlight</category>
      <category>WCF</category>
      <category>Workflow</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=33712ead-def9-433f-b658-d22396f35125</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,33712ead-def9-433f-b658-d22396f35125.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,33712ead-def9-433f-b658-d22396f35125.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=33712ead-def9-433f-b658-d22396f35125</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This <a href="http://www.silverlightshow.net/items/Silverlight-ready-for-business-applications.aspx">blog
post</a> indicates no, based on a number of good arguments.
</p>
        <p>
It is really true that Silverlight 2.0, out of the box, has a lot of holes or gaps
that must be filled in or worked around.
</p>
        <p>
Of course my shameless plug is for <a href="http://www.lhotka.net/cslalight">CSLA
.NET for Silverlight</a>, which fills in most of those gaps. We did encounter the
issues listed, and many others. Ultimately CSLA .NET for Silverlight is the result
of around 9-10 man-months of effort. That's 9-10 man-months of time finding, researching
and solving issues around business application development in Silverlight 2.0.
</p>
        <p>
So while I agree that just picking up Silverlight and running with it will require
some serious effort (as compared to WPF, Windows Forms or Web Forms), I don't think
that's the whole story. The reality is that frameworks and tools will come into existence
(or already have in the case of CSLA .NET) that bring Silverlight's productivity at
least up to the level of WPF.
</p>
        <p>
Then the argument becomes that WPF (and Silverlight) lack solid tooling for building
the UI. When compared to the designers available for Windows Forms and Web Forms that's
absolutely true. <em>However</em>, if you look under the covers, the amount of code
and effort required to actually build an app with WPF/Silverlight <em>is absolutely
less</em> than Windows Forms or Web Forms - at least when using CSLA .NET.
</p>
        <p>
I say this, because the <em>exact same business objects and data access</em> work
in all those environments. So the business and data code is a wash - it is the same
in all cases.
</p>
        <p>
But the UI code for WPF/Silverlight is a <em>tiny fraction</em> of the code required
for Windows Forms or Web Forms. XAML does require a learning curve, but once you get
over that curve it is <em>far more productive</em>, even without good designer tooling.
</p>
        <p>
Yes, I'm totally sold on the Silverlight/WPF/XAML UI future. Yes, there's a learning
curve, and yes there's some initial pain. But once you get past that initial hurdle
it is sooooo nice. You won't find me going back!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=33712ead-def9-433f-b658-d22396f35125" />
      </body>
      <title>Is Silverlight ready for business apps?</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,33712ead-def9-433f-b658-d22396f35125.aspx</guid>
      <link>http://www.lhotka.net/weblog/IsSilverlightReadyForBusinessApps.aspx</link>
      <pubDate>Fri, 24 Oct 2008 04:50:46 GMT</pubDate>
      <description>&lt;p&gt;
This &lt;a href="http://www.silverlightshow.net/items/Silverlight-ready-for-business-applications.aspx"&gt;blog
post&lt;/a&gt; indicates no, based on a number of good arguments.
&lt;/p&gt;
&lt;p&gt;
It is really true that Silverlight 2.0, out of the box, has a lot of holes or gaps
that must be filled in or worked around.
&lt;/p&gt;
&lt;p&gt;
Of course my shameless plug is for &lt;a href="http://www.lhotka.net/cslalight"&gt;CSLA
.NET for Silverlight&lt;/a&gt;, which fills in most of those gaps. We did encounter the
issues listed, and many others. Ultimately CSLA .NET for Silverlight is the result
of around 9-10 man-months of effort. That's 9-10 man-months of time finding, researching
and solving issues around business application development in Silverlight 2.0.
&lt;/p&gt;
&lt;p&gt;
So while I agree that just picking up Silverlight and running with it will require
some serious effort (as compared to WPF, Windows Forms or Web Forms), I don't think
that's the whole story. The reality is that frameworks and tools will come into existence
(or already have in the case of CSLA .NET) that bring Silverlight's productivity at
least up to the level of WPF.
&lt;/p&gt;
&lt;p&gt;
Then the argument becomes that WPF (and Silverlight) lack solid tooling for building
the UI. When compared to the designers available for Windows Forms and Web Forms that's
absolutely true. &lt;em&gt;However&lt;/em&gt;, if you look under the covers, the amount of code
and effort required to actually build an app with WPF/Silverlight &lt;em&gt;is absolutely
less&lt;/em&gt; than Windows Forms or Web Forms - at least when using CSLA .NET.
&lt;/p&gt;
&lt;p&gt;
I say this, because the &lt;em&gt;exact same business objects and data access&lt;/em&gt; work
in all those environments. So the business and data code is a wash - it is the same
in all cases.
&lt;/p&gt;
&lt;p&gt;
But the UI code for WPF/Silverlight is a &lt;em&gt;tiny fraction&lt;/em&gt; of the code required
for Windows Forms or Web Forms. XAML does require a learning curve, but once you get
over that curve it is &lt;em&gt;far more productive&lt;/em&gt;, even without good designer tooling.
&lt;/p&gt;
&lt;p&gt;
Yes, I'm totally sold on the Silverlight/WPF/XAML UI future. Yes, there's a learning
curve, and yes there's some initial pain. But once you get past that initial hurdle
it is sooooo nice. You won't find me going back!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=33712ead-def9-433f-b658-d22396f35125" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,33712ead-def9-433f-b658-d22396f35125.aspx</comments>
      <category>CSLA .NET</category>
      <category>Silverlight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=1ce9b2ba-7caa-4653-8049-94099fa60727</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,1ce9b2ba-7caa-4653-8049-94099fa60727.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,1ce9b2ba-7caa-4653-8049-94099fa60727.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=1ce9b2ba-7caa-4653-8049-94099fa60727</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Someone on the CSLA .NET discussion forum recently asked what new .NET 3.5 features
I used in CSLA .NET 3.5. The poster noted that there are a lot of new features in
.NET 3.5, which is true. They also included some .NET 3.0 features as "new", though
really those features have now been around for 15 months or so and were addressed
in CSLA .NET 3.0. CSLA .NET 3.0 already added support for WCF, WPF and WF, so those
technologies had very little impact on CSLA .NET 3.5.
</p>
        <p>
My philosophy is to use new technologies only if they provide value to me and my work.
In the case of CSLA .NET this is extended slightly, such that I try to make sure CSLA
.NET also <em>supports</em> new technologies that might be of value to people who
use CSLA .NET.
</p>
        <p>
While .NET 3.5 has a number of new technologies at various levels (UI, data, languages),
many of them required no changes to CSLA to support. I like to think this is because
I'm always trying to look into the future as I work on CSLA, anticipating at least
some of what is coming so I can make the transition smoother. For example, this is
why CSLA .NET 2.0 introduced a provider model for the data portal - because I knew
WCF was coming in a couple years and I wanted to be ready.
</p>
        <p>
Since CSLA .NET already supported data binding to WPF, Windows Forms and Web Forms,
there was no real work to do at the UI level for .NET 3.5. I actually <em>removed</em> Csla.Wpf.Validator
because WPF now directly supplies that behavior, but I really didn't <em>add</em> anything
for UI support because it is already there. 
</p>
        <p>
Looking forward beyond 3.5, it is possible I'll need to add support for ASP.NET MVC
because that technology eschews data binding in favor of other techniques to create
the view - but it is too early to know for sure what I'll do in that regard.
</p>
        <p>
Since CSLA .NET has always abstracted the business object concept from the data access
technique you choose, it automatically supported LINQ to SQL (and will automatically
support ADO.NET EF too). No changes required to do that were required, though I did
add Csla.Data.ContextManager to simplify the use of L2S data context objects (as a
companion to the new Csla.Data.ConnectionManager for raw ADO.NET connections). And
I enhanced Csla.Data.DataMapper to have some more powerful mapping options that may
be useful in some L2S or EF scenarios.
</p>
        <p>
LINQ to Objects did require some work. Technically this too was optional, but I felt
it was critical, and so there is now "LINQ to CSLA" functionality provided in 3.5
(thanks to my colleague Aaron Erickson). The primary feature of this is creating a
synchronized view of a BusinessListBase list when you do a non-projection query, which
means you can data bind the results of a non-projection query and allow the user to
add/remove items from the query result <em>and those changes are also reflected in
the original list</em>. As a cool option, LINQ to CSLA also implements indexed queries
against lists, so if you are doing many queries against the same list object you should
look into this as a performance booster!
</p>
        <p>
So all that's left are some of the language enhancements that exist to support LINQ.
And I do use some of them - mostly type inference (which I love). But I didn't go
through the entire body of existing code to use the new language features. The risk
of breaking functionality that has worked for 6-7 years is <em>way</em> too high!
I can't see where anyone would choose to take such a risk with a body of code, but
especially one like CSLA that is used by thousands of people world-wide.
</p>
        <p>
That means I used some of the new language features in new code, and in code I had
to rework anyway. And to be honest, I use those features sparingly and where I thought
they helped. 
</p>
        <p>
I think trying to force new technologies/concepts/patterns into code is a bad idea.
If a given pattern or technology obviously saves code/time/money or has other clear
benefits then I use it, but I try never to get attached to some idea such that I force
it into places where it doesn't fit with my overall goals.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1ce9b2ba-7caa-4653-8049-94099fa60727" />
      </body>
      <title>My philosophy on using new technologies</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,1ce9b2ba-7caa-4653-8049-94099fa60727.aspx</guid>
      <link>http://www.lhotka.net/weblog/MyPhilosophyOnUsingNewTechnologies.aspx</link>
      <pubDate>Sat, 12 Apr 2008 21:11:52 GMT</pubDate>
      <description>&lt;p&gt;
Someone on the CSLA .NET discussion forum recently asked what new .NET 3.5 features
I used in CSLA .NET 3.5. The poster noted that there are a lot of new features in
.NET 3.5, which is true. They also included some .NET 3.0 features as "new", though
really those features have now been around for 15 months or so and were addressed
in CSLA .NET 3.0. CSLA .NET 3.0 already added support for WCF, WPF and WF, so those
technologies had very little impact on CSLA .NET 3.5.
&lt;/p&gt;
&lt;p&gt;
My philosophy is to use new technologies only if they provide value to me and my work.
In the case of CSLA .NET this is extended slightly, such that I try to make sure CSLA
.NET also &lt;em&gt;supports&lt;/em&gt; new technologies that might be of value to people who
use CSLA .NET.
&lt;/p&gt;
&lt;p&gt;
While .NET 3.5 has a number of new technologies at various levels (UI, data, languages),
many of them required no changes to CSLA to support. I like to think this is because
I'm always trying to look into the future as I work on CSLA, anticipating at least
some of what is coming so I can make the transition smoother. For example, this is
why CSLA .NET 2.0 introduced a provider model for the data portal - because I knew
WCF was coming in a couple years and I wanted to be ready.
&lt;/p&gt;
&lt;p&gt;
Since CSLA .NET already supported data binding to WPF, Windows Forms and Web Forms,
there was no real work to do at the UI level for .NET 3.5. I actually &lt;em&gt;removed&lt;/em&gt; Csla.Wpf.Validator
because WPF now directly supplies that behavior, but I really didn't &lt;em&gt;add&lt;/em&gt; anything
for UI support because it is already there. 
&lt;/p&gt;
&lt;p&gt;
Looking forward beyond 3.5, it is possible I'll need to add support for ASP.NET MVC
because that technology eschews data binding in favor of other techniques to create
the view - but it is too early to know for sure what I'll do in that regard.
&lt;/p&gt;
&lt;p&gt;
Since CSLA .NET has always abstracted the business object concept from the data access
technique you choose, it automatically supported LINQ to SQL (and will automatically
support ADO.NET EF too). No changes required to do that were required, though I did
add Csla.Data.ContextManager to simplify the use of L2S data context objects (as a
companion to the new Csla.Data.ConnectionManager for raw ADO.NET connections). And
I enhanced Csla.Data.DataMapper to have some more powerful mapping options that may
be useful in some L2S or EF scenarios.
&lt;/p&gt;
&lt;p&gt;
LINQ to Objects did require some work. Technically this too was optional, but I felt
it was critical, and so there is now "LINQ to CSLA" functionality provided in 3.5
(thanks to my colleague Aaron Erickson). The primary feature of this is creating a
synchronized view of a BusinessListBase list when you do a non-projection query, which
means you can data bind the results of a non-projection query and allow the user to
add/remove items from the query result &lt;em&gt;and those changes are also reflected in
the original list&lt;/em&gt;. As a cool option, LINQ to CSLA also implements indexed queries
against lists, so if you are doing many queries against the same list object you should
look into this as a performance booster!
&lt;/p&gt;
&lt;p&gt;
So all that's left are some of the language enhancements that exist to support LINQ.
And I do use some of them - mostly type inference (which I love). But I didn't go
through the entire body of existing code to use the new language features. The risk
of breaking functionality that has worked for 6-7 years is &lt;em&gt;way&lt;/em&gt; too high!
I can't see where anyone would choose to take such a risk with a body of code, but
especially one like CSLA that is used by thousands of people world-wide.
&lt;/p&gt;
&lt;p&gt;
That means I used some of the new language features in new code, and in code I had
to rework anyway. And to be honest, I use those features sparingly and where I thought
they helped. 
&lt;/p&gt;
&lt;p&gt;
I think trying to force new technologies/concepts/patterns into code is a bad idea.
If a given pattern or technology obviously saves code/time/money or has other clear
benefits then I use it, but I try never to get attached to some idea such that I force
it into places where it doesn't fit with my overall goals.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1ce9b2ba-7caa-4653-8049-94099fa60727" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,1ce9b2ba-7caa-4653-8049-94099fa60727.aspx</comments>
      <category>Architecture</category>
      <category>CSLA .NET</category>
      <category>Microsoft .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=cce56446-b1f5-46e2-ad41-b56804bb2f47</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,cce56446-b1f5-46e2-ad41-b56804bb2f47.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,cce56446-b1f5-46e2-ad41-b56804bb2f47.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=cce56446-b1f5-46e2-ad41-b56804bb2f47</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm just back from the <a href="http://visitmix.com/2008/">MIX 08</a> conference.
This was the first conference I've attended in many years (around 10 I think) where
I wasn't speaking or somehow working. I'd forgotten just how fun and inspiring it
can be to simply attend sessions and network with people in the open areas. No wonder
people come to conference!! :)
</p>
        <p>
Not that it was all fun and games. I did have meetings with some key Microsoft people
and Scott Hanselman interviewed me for an upcoming episode of <a href="http://www.hanselminutes.com/">Hanselminutes</a> (discussing
the various data access and ORM technologies and how they relate to CSLA .NET 3.5).
</p>
        <p>
The Day 1 keynote was everything I'd hoped for. 
</p>
        <p>
Well, nearly. The first part of the keynote was Ray Ozzie trying to convey how Microsoft
and the web got to where it is now. The goal was to show the vision they are pursuing
now and into the future, but I thought the whole segment was rather flat.
</p>
        <p>
But then <a href="http://weblogs.asp.net/scottgu/">Scott Guthrie</a> came on stage
and <em>that</em> was everything you could hope for. Scott is a great guy, and his
dedication and openness seem unparalleled within Microsoft. I remember first meeting
him when ASP.NET was being unveiled. At that time he seemed so young and enthusiastic,
and he was basically just this kick-ass dev who'd created the core of something that
ultimately changed the Microsoft world. Today he seems nearly as young and easily
as enthusiastic, and he's overseeing most of the cool technologies that continue to
change the Microsoft world. Awesome!
</p>
        <p>
So ScottGu gets on stage and orchestrates a keynote that really illustrates the future
of the web. <a href="http://www.silverlight.net">Silverlight</a> (which makes me SOOoooo
happy!), IE8, new data access technologies (like we needed more, but they are still
cool!) and things like ASP.NET MVC and more.
</p>
        <p>
As I expected, they released a whole lot of beta code. You can get a full list with
links from <a href="http://blogs.msdn.com/tims/archive/2008/03/05/download-links-for-mix08-announcements.aspx">Tim
Sneath's blog</a>. He also has links to some <a href="http://blogs.msdn.com/tims/archive/2008/03/05/so-you-ve-installed-silverlight-2-beta-1-what-next.aspx">getting
started materials</a>.
</p>
        <p>
The real reason for keynotes though, is to inspire. And this keynote didn't disappoint.
The demos of Silverlight and related technologies were awesome! There was some funny
and cute banter with the casting director from Circ del Sole as she demonstrated using
a cool disconnected WPF app. There was a fellow RD, Scott Stanfield, showing integration
of SeaDragon into Silveright so we can look (in exquisite detail) at the memorabilia
owned by the Hard Rock Cafe company, some thought-provoking demos of Silverlight on
mobile devices and more.
</p>
        <p>
Now to be honest, I've never been a fan of the web development model. Having done
terminal-based programming for many years before coming to Windows, I find it hard
to get excited about returning to that ancient programming model. Well, a worse one
actually, because at least the mainframe/minicomputer world had decent state management...
</p>
        <p>
AJAX helps, but the browser makes for a pretty lame programming platform. It is more
comparable perhaps to an Apple II or a Commodore 64 than to a modern environment,
and that's before you get into the inconsistencies across browsers and that whole
mess. Yuck!
</p>
        <p>
Which is why Silverlight is so darn cool! Silverlight 2.0 is really a way to do smart
client development with a true web deployment model. Much of the power of .NET and
WPF/XAML, with the transparent deployment and cross-platform capabilities of the browser
world. THIS is impressive stuff. To me Silverlight represents the real future of the
web.
</p>
        <p>
It should come as no surprise then, that I spent my time in Silverlight 2.0 sessions
after the keynote. Sure, I've been working (on and off) with Silverlight 1.1/2.0 for
the past several months, but it was a lot of fun to see presentations by great speakers
like <a href="http://blogs.msdn.com/jstegman/">Joe Stegman</a> (a Microsoft PM) and
various other people. 
</p>
        <p>
One of the best sessions was on game development with Silverlight. I dabble in game
development whenever I have spare time (not nearly as much as I'd like), and so the
talk was interesting from that perspective. But many of the concepts and techniques
they used in their games are things designers and developers will likely use in many
other types of application. Background loading of assemblies and content while the
app is running, and some clever animation techniques using pure XAML-based concepts
(as opposed to some other animation techniques I saw that use custom controls written
in C#/VB - which isn't bad, but it was fun to see the pure-XAML approaches).
</p>
        <p>
Many people have asked about "CSLA Light", my planned version of <a href="http://www.lhotka.net/cslanet">CSLA
.NET</a> for Silverlight. Now that we have a Beta 1 of Silverlight I'll be working
on a public release of CSLA Light, based on CSLA .NET 3.5. Microsoft has put a lot
more functionality into Silverlight 2.0 than they'd originally planned - things like
data binding, reflection and other key concepts are directly supported. This means
that the majority of CSLA can be ported (with some work) into Silverlight. The data
portal is the one big sticking point, and I'm sure that'll be the topic of future
blog posts.
</p>
        <p>
My goal is to support the CSLA .NET 3.5 syntax for property declaration and other
coding constructs such that with little or no change you can take a business class
from full CSLA and have it work in CSLA Light. This goal excludes the DataPortal_XZY
implementations - those will almost always be different, though if you plan ahead
and use a DTO-based data access model even that code may be the same. Of course time
will tell how closely I'll meet this goal - but given my work with pre-beta Silverlight
2.0 code I think it is pretty realistic.
</p>
        <p>
Scott Guthrie indicated that Silverlight 2.0 Beta 1 has a non-commercial go-live license
- right now. And that Beta 2 would be in Q2 (I'm guessing June) and would have a commercial
go-live license, meaning it can be used for real work in any context. 
</p>
        <p>
The future of the web is Silverlight, and Beta 1 is the start of that future. 2008
is going to be a great year!
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=cce56446-b1f5-46e2-ad41-b56804bb2f47" />
      </body>
      <title>Thoughts on MIX 08</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,cce56446-b1f5-46e2-ad41-b56804bb2f47.aspx</guid>
      <link>http://www.lhotka.net/weblog/ThoughtsOnMIX08.aspx</link>
      <pubDate>Sun, 09 Mar 2008 11:18:27 GMT</pubDate>
      <description>&lt;p&gt;
I'm just back from the &lt;a href="http://visitmix.com/2008/"&gt;MIX 08&lt;/a&gt; conference.
This was the first conference I've attended in many years (around 10 I think) where
I wasn't speaking or somehow working. I'd forgotten just how fun and inspiring it
can be to simply attend sessions and network with people in the open areas. No wonder
people come to conference!! :)
&lt;/p&gt;
&lt;p&gt;
Not that it was all fun and games. I did have meetings with some key Microsoft people
and Scott Hanselman interviewed me for an upcoming episode of &lt;a href="http://www.hanselminutes.com/"&gt;Hanselminutes&lt;/a&gt; (discussing
the various data access and ORM technologies and how they relate to CSLA .NET 3.5).
&lt;/p&gt;
&lt;p&gt;
The Day 1 keynote was everything I'd hoped for. 
&lt;/p&gt;
&lt;p&gt;
Well, nearly. The first part of the keynote was Ray Ozzie trying to convey how Microsoft
and the web got to where it is now. The goal was to show the vision they are pursuing
now and into the future, but I thought the whole segment was rather flat.
&lt;/p&gt;
&lt;p&gt;
But then &lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie&lt;/a&gt; came on stage
and &lt;em&gt;that&lt;/em&gt; was everything you could hope for. Scott is a great guy, and his
dedication and openness seem unparalleled within Microsoft. I remember first meeting
him when ASP.NET was being unveiled. At that time he seemed so young and enthusiastic,
and he was basically just this kick-ass dev who'd created the core of something that
ultimately changed the Microsoft world. Today he seems nearly as young and easily
as enthusiastic, and he's overseeing most of the cool technologies that continue to
change the Microsoft world. Awesome!
&lt;/p&gt;
&lt;p&gt;
So ScottGu gets on stage and orchestrates a keynote that really illustrates the future
of the web. &lt;a href="http://www.silverlight.net"&gt;Silverlight&lt;/a&gt; (which makes me SOOoooo
happy!), IE8, new data access technologies (like we needed more, but they are still
cool!) and things like ASP.NET MVC and more.
&lt;/p&gt;
&lt;p&gt;
As I expected, they released a whole lot of beta code. You can get a full list with
links from &lt;a href="http://blogs.msdn.com/tims/archive/2008/03/05/download-links-for-mix08-announcements.aspx"&gt;Tim
Sneath's blog&lt;/a&gt;. He also has links to some &lt;a href="http://blogs.msdn.com/tims/archive/2008/03/05/so-you-ve-installed-silverlight-2-beta-1-what-next.aspx"&gt;getting
started materials&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
The real reason for keynotes though, is to inspire. And this keynote didn't disappoint.
The demos of Silverlight and related technologies were awesome! There was some funny
and cute banter with the casting director from Circ del Sole as she demonstrated using
a cool disconnected WPF app. There was a fellow RD, Scott Stanfield, showing integration
of SeaDragon into Silveright so we can look (in exquisite detail) at the memorabilia
owned by the Hard Rock Cafe company, some thought-provoking demos of Silverlight on
mobile devices and more.
&lt;/p&gt;
&lt;p&gt;
Now to be honest, I've never been a fan of the web development model. Having done
terminal-based programming for many years before coming to Windows, I find it hard
to get excited about returning to that ancient programming model. Well, a worse one
actually, because at least the mainframe/minicomputer world had decent state management...
&lt;/p&gt;
&lt;p&gt;
AJAX helps, but the browser makes for a pretty lame programming platform. It is more
comparable perhaps to an Apple II or a Commodore 64 than to a modern environment,
and that's before you get into the inconsistencies across browsers and that whole
mess. Yuck!
&lt;/p&gt;
&lt;p&gt;
Which is why Silverlight is so darn cool! Silverlight 2.0 is really a way to do smart
client development with a true web deployment model. Much of the power of .NET and
WPF/XAML, with the transparent deployment and cross-platform capabilities of the browser
world. THIS is impressive stuff. To me Silverlight represents the real future of the
web.
&lt;/p&gt;
&lt;p&gt;
It should come as no surprise then, that I spent my time in Silverlight 2.0 sessions
after the keynote. Sure, I've been working (on and off) with Silverlight 1.1/2.0 for
the past several months, but it was a lot of fun to see presentations by great speakers
like &lt;a href="http://blogs.msdn.com/jstegman/"&gt;Joe Stegman&lt;/a&gt; (a Microsoft PM) and
various other people. 
&lt;/p&gt;
&lt;p&gt;
One of the best sessions was on game development with Silverlight. I dabble in game
development whenever I have spare time (not nearly as much as I'd like), and so the
talk was interesting from that perspective. But many of the concepts and techniques
they used in their games are things designers and developers will likely use in many
other types of application. Background loading of assemblies and content while the
app is running, and some clever animation techniques using pure XAML-based concepts
(as opposed to some other animation techniques I saw that use custom controls written
in C#/VB - which isn't bad, but it was fun to see the pure-XAML approaches).
&lt;/p&gt;
&lt;p&gt;
Many people have asked about "CSLA Light", my planned version of &lt;a href="http://www.lhotka.net/cslanet"&gt;CSLA
.NET&lt;/a&gt; for Silverlight. Now that we have a Beta 1 of Silverlight I'll be working
on a public release of CSLA Light, based on CSLA .NET 3.5. Microsoft has put a lot
more functionality into Silverlight 2.0 than they'd originally planned - things like
data binding, reflection and other key concepts are directly supported. This means
that the majority of CSLA can be ported (with some work) into Silverlight. The data
portal is the one big sticking point, and I'm sure that'll be the topic of future
blog posts.
&lt;/p&gt;
&lt;p&gt;
My goal is to support the CSLA .NET 3.5 syntax for property declaration and other
coding constructs such that with little or no change you can take a business class
from full CSLA and have it work in CSLA Light. This goal excludes the DataPortal_XZY
implementations - those will almost always be different, though if you plan ahead
and use a DTO-based data access model even that code may be the same. Of course time
will tell how closely I'll meet this goal - but given my work with pre-beta Silverlight
2.0 code I think it is pretty realistic.
&lt;/p&gt;
&lt;p&gt;
Scott Guthrie indicated that Silverlight 2.0 Beta 1 has a non-commercial go-live license
- right now. And that Beta 2 would be in Q2 (I'm guessing June) and would have a commercial
go-live license, meaning it can be used for real work in any context. 
&lt;/p&gt;
&lt;p&gt;
The future of the web is Silverlight, and Beta 1 is the start of that future. 2008
is going to be a great year!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=cce56446-b1f5-46e2-ad41-b56804bb2f47" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,cce56446-b1f5-46e2-ad41-b56804bb2f47.aspx</comments>
      <category>CSLA .NET</category>
      <category>Microsoft .NET</category>
      <category>Web</category>
      <category>WPF</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=353f34a0-6a97-4039-a441-9a23a2192774</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,353f34a0-6a97-4039-a441-9a23a2192774.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,353f34a0-6a97-4039-a441-9a23a2192774.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=353f34a0-6a97-4039-a441-9a23a2192774</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Another place where I was able to reduce business object code in CSLA .NET 3.5 was
to effectively eliminate the GetIdValue() method.
</p>
        <p>
Prior to version 3.5, GetIdValue() was required, and you had to provide a unique value
identifying your object. This value was used to implement Equals() and GetHashCode(),
and was used as the ToString() value. This was good, because it enabled the concept
of <em>logical equality</em>, where objects were equal to each other based on their
id value.
</p>
        <p>
For better or worse, WPF doesn't support logical equality. They only support absolute
equality - ideally implemented by comparing all properties of the two objects so two
objects are only equal if all their properties are equal. A poor man's replacement
is to use reference equality - which is much faster but is technically less accurate.
The effective default in .NET is reference equality.
</p>
        <p>
CSLA .NET 3.5 no longer overrides Equals() or GetHashCode(), so it now uses the .NET
default behavior. This makes WPF happy. This might break some people's existing code
(though a poll on the forum indicates it is a non-issue for virtually everyone), because
there is no longer any idea of logical equality unless you implement it yourself.
</p>
        <p>
The upside though, is that you no longer need to override GetIdValue(). I left the
method in the framework for backward compatibilty, so if you <em>do</em> override
it your code will continue to compile (though the value is now only used in a ToString()
override).
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=353f34a0-6a97-4039-a441-9a23a2192774" />
      </body>
      <title>CSLA .NET 3.5 code savings: GetIdValue</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,353f34a0-6a97-4039-a441-9a23a2192774.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANET35CodeSavingsGetIdValue.aspx</link>
      <pubDate>Mon, 03 Mar 2008 14:53:36 GMT</pubDate>
      <description>&lt;p&gt;
Another place where I was able to reduce business object code in CSLA .NET 3.5 was
to effectively eliminate the GetIdValue() method.
&lt;/p&gt;
&lt;p&gt;
Prior to version 3.5, GetIdValue() was required, and you had to provide a unique value
identifying your object. This value was used to implement Equals() and GetHashCode(),
and was used as the ToString() value. This was good, because it enabled the concept
of &lt;em&gt;logical equality&lt;/em&gt;, where objects were equal to each other based on their
id value.
&lt;/p&gt;
&lt;p&gt;
For better or worse, WPF doesn't support logical equality. They only support absolute
equality - ideally implemented by comparing all properties of the two objects so two
objects are only equal if all their properties are equal. A poor man's replacement
is to use reference equality - which is much faster but is technically less accurate.
The effective default in .NET is reference equality.
&lt;/p&gt;
&lt;p&gt;
CSLA .NET 3.5 no longer overrides Equals() or GetHashCode(), so it now uses the .NET
default behavior. This makes WPF happy. This might break some people's existing code
(though a poll on the forum indicates it is a non-issue for virtually everyone), because
there is no longer any idea of logical equality unless you implement it yourself.
&lt;/p&gt;
&lt;p&gt;
The upside though, is that you no longer need to override GetIdValue(). I left the
method in the framework for backward compatibilty, so if you &lt;em&gt;do&lt;/em&gt; override
it your code will continue to compile (though the value is now only used in a ToString()
override).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=353f34a0-6a97-4039-a441-9a23a2192774" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,353f34a0-6a97-4039-a441-9a23a2192774.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=0178bec8-e296-4aab-b9ad-94176c128c26</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,0178bec8-e296-4aab-b9ad-94176c128c26.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,0178bec8-e296-4aab-b9ad-94176c128c26.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0178bec8-e296-4aab-b9ad-94176c128c26</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm psyched! I finally figured out how to get the Csla.Wpf.CslaDataProvider control
to support a Delete command that removes child items from a databound list object.
</p>
        <p>
As you might expect, the answer to the problem was staring me in the face the whole
time - I just didn't see it. Isn't that the way things often work? ;)
</p>
        <p>
Since day one, CslaDataProvider has support the Save, Undo and AddNew commands (using
XAML commanding), so it has been possible to create Save, Cancel and Add buttons on
a form purely through XAML - no code-behind required at all.
</p>
        <p>
Now, with this new change it is also possible to implement a Remove button in a DataTemplate
with no code-behind. The button can use the standard Delete command to tell the CslaDataProvider
managing the BusinessListBase object to remove the child object bound to that row
in the DataTemplate. The XAML looks like this:
</p>
        <blockquote>
          <p>
            <font face="Courier New" size="2">&lt;DataTemplate x:Key="lbTemplate"&gt;<br />
  &lt;Grid&gt;<br />
    &lt;StackPanel Orientation="Horizontal"&gt;<br />
      &lt;TextBlock&gt;Id:&lt;/TextBlock&gt;<br />
      &lt;TextBox Text="{Binding Path=Id, Converter={StaticResource
IdentityConverter}, ValidatesOnDataErrors=True}" Width="100" /&gt;<br />
      &lt;TextBlock&gt;Name:&lt;/TextBlock&gt;<br />
      &lt;TextBox Text="{Binding Path=Name, Converter={StaticResource
IdentityConverter}, ValidatesOnDataErrors=True}" Width="250" /&gt;<br /></font>
            <font size="2">
              <font face="Courier New">
                <font color="#800000">     
&lt;Button 
<br />
        Command="ApplicationCommands.Delete" 
<br />
        CommandParameter="{Binding}"<br />
        CommandTarget="{Binding Source={StaticResource
RoleList}, Path=CommandManager, BindsDirectlyToSource=True}"<br />
        HorizontalAlignment="Left"&gt;Remove&lt;/Button&gt;<br /></font>    &lt;/StackPanel&gt;<br />
  &lt;/Grid&gt;<br />
&lt;/DataTemplate&gt;</font>
            </font>
          </p>
        </blockquote>
        <p>
The key was realizing that the CommandParameter could be bound to the entire object
that is represented by this DataTemplate - the individual row object. This revelation
meant that the CslaDataProvider control can in fact remove that item because an equality
comparison is possible. So ApplicationCommands.Delete passes the child object reference
to the data provider, which removes the item from the databound list object and that's
it!
</p>
        <p>
So this means you can now create a typical maintenance screen with no code behind
the XAML. None. You have to write zero lines of VB/C#. Too cool!!
</p>
        <p>
And it means that even on a more complex screen you still don't need to write save/cancel/add
new/remove code. That's a lot of code savings! Often all you need to write is code
dealing with navigation from this screen to some other screen, perhaps some exception
handling code (which I put in a base class) and some authorization code to provide
visual cues to the user about what they can and can't do.
</p>
        <p>
Is this really the final step? I doubt it. I already have some ideas on how to expose
the authorization knowledge encapsulated by the business object such that it
can be directly used within the XAML. I don't know if I'll get that working, but if
I can reduce/elminate the UI authorization code (that provides visual cues to the
user) and get that into XAML then even more forms will become codeless.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=0178bec8-e296-4aab-b9ad-94176c128c26" />
      </body>
      <title>CslaDataProvider: The final step</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,0178bec8-e296-4aab-b9ad-94176c128c26.aspx</guid>
      <link>http://www.lhotka.net/weblog/CslaDataProviderTheFinalStep.aspx</link>
      <pubDate>Thu, 28 Feb 2008 02:41:14 GMT</pubDate>
      <description>&lt;p&gt;
I'm psyched! I finally figured out how to get the Csla.Wpf.CslaDataProvider control
to support a Delete command that removes child items from a databound list object.
&lt;/p&gt;
&lt;p&gt;
As you might expect, the answer to the problem was staring me in the face the whole
time - I just didn't see it. Isn't that the way things often work? ;)
&lt;/p&gt;
&lt;p&gt;
Since day one, CslaDataProvider has support the Save, Undo and AddNew commands (using
XAML commanding), so it has been possible to create Save, Cancel and Add buttons on
a form purely through XAML - no code-behind required at all.
&lt;/p&gt;
&lt;p&gt;
Now, with this new change it is also possible to implement a Remove button in a DataTemplate
with no code-behind. The button can use the standard Delete command to tell the CslaDataProvider
managing the BusinessListBase object to remove the child object bound to that row
in the DataTemplate. The XAML looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" size=2&gt;&amp;lt;DataTemplate x:Key="lbTemplate"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;Grid&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock&amp;gt;Id:&amp;lt;/TextBlock&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBox Text="{Binding Path=Id, Converter={StaticResource
IdentityConverter}, ValidatesOnDataErrors=True}" Width="100" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock&amp;gt;Name:&amp;lt;/TextBlock&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBox Text="{Binding Path=Name, Converter={StaticResource
IdentityConverter}, ValidatesOnDataErrors=True}" Width="250" /&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color=#800000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;Button 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Command="ApplicationCommands.Delete" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CommandParameter="{Binding}"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CommandTarget="{Binding Source={StaticResource
RoleList}, Path=CommandManager, BindsDirectlyToSource=True}"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HorizontalAlignment="Left"&amp;gt;Remove&amp;lt;/Button&amp;gt;&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/Grid&amp;gt;&lt;br&gt;
&amp;lt;/DataTemplate&amp;gt;&lt;/font&gt;&lt;/font&gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The key was realizing that the CommandParameter could be bound to the entire object
that is represented by this DataTemplate - the individual row object. This revelation
meant that the CslaDataProvider control can in fact remove that item because an equality
comparison is possible. So ApplicationCommands.Delete passes the child object reference
to the data provider, which removes the item from the databound list object and that's
it!
&lt;/p&gt;
&lt;p&gt;
So this means you can now create a typical maintenance screen with no code behind
the XAML. None. You have to write zero lines of VB/C#. Too cool!!
&lt;/p&gt;
&lt;p&gt;
And it means that even on a more complex screen you still don't need to write save/cancel/add
new/remove code. That's a lot of code savings! Often all you need to write is code
dealing with navigation from this screen to some other screen, perhaps some exception
handling code (which I put in a base class) and some authorization code to provide
visual cues to the user about what they can and can't do.
&lt;/p&gt;
&lt;p&gt;
Is this really the final step? I doubt it. I already have some ideas on how to expose
the authorization&amp;nbsp;knowledge encapsulated by the business object such that it
can be directly used within the XAML. I don't know if I'll get that working, but if
I can reduce/elminate the UI authorization code (that provides visual cues to the
user) and get that into XAML then even more forms will become codeless.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=0178bec8-e296-4aab-b9ad-94176c128c26" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,0178bec8-e296-4aab-b9ad-94176c128c26.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=886b00ec-4b22-4331-a8fb-706f5963c5ed</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,886b00ec-4b22-4331-a8fb-706f5963c5ed.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,886b00ec-4b22-4331-a8fb-706f5963c5ed.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=886b00ec-4b22-4331-a8fb-706f5963c5ed</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
in a recent email thread someone was wondering why component vendors are being so
slow in coming out with grid controls for WPF/XAML. 
</p>
        <p>
One obvious reason is that grid controls are hard to build, and WPF/XAML is radically
different from Windows Forms or Web Forms. But still, it is fair to wonder why these
highly experienced control vendors haven't overcome that challenge. 
</p>
        <p>
I think the reason is that technology isn't the issue. At least not in the raw "learn
how to use XAML" way. I think the real issue is much bigger! 
</p>
        <p>
Consider the incredible risk a vendor would assume by creating a grid control now. 
</p>
        <p>
Microsoft hasn’t come out with a WPF grid, and so there are no standard interfaces
in .NET to support data binding to a grid. Certainly the current interfaces used by
WPF are not nearly powerful enough to get in-place grid editing like we have in Windows
Forms – and that’s a requirement if WPF is ever going to replace Windows Forms for
business development. 
</p>
        <p>
Windows Forms and Web Forms both have benchmark grids from Microsoft. They set the
standard, and define the core interaction used by data binding. The other vendors
can then build around that core to do cool stuff. In particular, Windows Forms defines
a whole set of powerful interfaces to allow in-place editing so the user can navigate
freely in a grid, edit cells, add rows and delete rows – and press ESC to cancel changes
to whatever row they are on. All features most users would consider critical to the
in-place experience. The majority of those interfaces are <i>not used by WPF today</i>!!
Nor does WPF have replacements for them. And if they do replace those interfaces then
you can’t bind to a DataTable, which shuts out most developers from WPF again – probably
a bad idea. 
</p>
        <p>
The WPF team has already shown that they’ll supersede existing interfaces (INotifyCollectionChanged
was invented even though IBindingList was already there). So it is somewhat hard to
predict where Microsoft might go in this regard. It is quite possible they’ll do the
“worse of all worlds” and support the DataTable (all the existing Windows Forms interfaces) <i>and
invent a whole new model</i><i>as well</i>… (again, see INotifyCollectionChanged
– invented for WPF, but IBindingList is <i>also fully supported by WPF</i>) 
</p>
        <p>
So in WPF the poor component vendors are really stuck. There’s no defined standard
for this kind of data binding, so they need to invent it. They’ll each invent something
different from the other vendors – and NONE of them will likely match whatever Microsoft
eventually does. That means they are all in deep trouble when Microsoft does set the
standard. And so are all consumers of those grids (all of us!). 
</p>
        <p>
This is very much like pre-ODBC database access, except in this case it is a very
safe bet that “ODBC” is coming (in the form of some standard grid definition) and
so investing in building a proprietary solution is a known dead-end. A waste of money
and very likely a way to make many, many angry customers who may hate you forever. 
</p>
        <p>
Nasty business just now… :(
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=886b00ec-4b22-4331-a8fb-706f5963c5ed" />
      </body>
      <title>Why so few WPF/XAML grid controls?</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,886b00ec-4b22-4331-a8fb-706f5963c5ed.aspx</guid>
      <link>http://www.lhotka.net/weblog/WhySoFewWPFXAMLGridControls.aspx</link>
      <pubDate>Tue, 22 Jan 2008 18:17:53 GMT</pubDate>
      <description>&lt;p&gt;
in a recent email thread someone was wondering why component vendors are being so
slow in coming out with grid controls for WPF/XAML. 
&lt;p&gt;
One obvious reason is that grid controls are hard to build, and WPF/XAML is radically
different from Windows Forms or Web Forms. But still, it is fair to wonder why these
highly experienced control vendors haven't overcome that challenge. 
&lt;p&gt;
I think the reason is that technology isn't the issue. At least not in the raw "learn
how to use XAML" way. I think the real issue is much bigger! 
&lt;p&gt;
Consider the incredible risk a vendor would assume by creating a grid control now. 
&lt;p&gt;
Microsoft hasn’t come out with a WPF grid, and so there are no standard interfaces
in .NET to support data binding to a grid. Certainly the current interfaces used by
WPF are not nearly powerful enough to get in-place grid editing like we have in Windows
Forms – and that’s a requirement if WPF is ever going to replace Windows Forms for
business development. 
&lt;p&gt;
Windows Forms and Web Forms both have benchmark grids from Microsoft. They set the
standard, and define the core interaction used by data binding. The other vendors
can then build around that core to do cool stuff. In particular, Windows Forms defines
a whole set of powerful interfaces to allow in-place editing so the user can navigate
freely in a grid, edit cells, add rows and delete rows – and press ESC to cancel changes
to whatever row they are on. All features most users would consider critical to the
in-place experience. The majority of those interfaces are &lt;i&gt;not used by WPF today&lt;/i&gt;!!
Nor does WPF have replacements for them. And if they do replace those interfaces then
you can’t bind to a DataTable, which shuts out most developers from WPF again – probably
a bad idea. 
&lt;p&gt;
The WPF team has already shown that they’ll supersede existing interfaces (INotifyCollectionChanged
was invented even though IBindingList was already there). So it is somewhat hard to
predict where Microsoft might go in this regard. It is quite possible they’ll do the
“worse of all worlds” and support the DataTable (all the existing Windows Forms interfaces) &lt;i&gt;and
invent a whole new model&lt;/i&gt; &lt;i&gt;as well&lt;/i&gt;… (again, see INotifyCollectionChanged
– invented for WPF, but IBindingList is &lt;i&gt;also fully supported by WPF&lt;/i&gt;) 
&lt;p&gt;
So in WPF the poor component vendors are really stuck. There’s no defined standard
for this kind of data binding, so they need to invent it. They’ll each invent something
different from the other vendors – and NONE of them will likely match whatever Microsoft
eventually does. That means they are all in deep trouble when Microsoft does set the
standard. And so are all consumers of those grids (all of us!). 
&lt;p&gt;
This is very much like pre-ODBC database access, except in this case it is a very
safe bet that “ODBC” is coming (in the form of some standard grid definition) and
so investing in building a proprietary solution is a known dead-end. A waste of money
and very likely a way to make many, many angry customers who may hate you forever. 
&lt;p&gt;
Nasty business just now… :(
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=886b00ec-4b22-4331-a8fb-706f5963c5ed" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,886b00ec-4b22-4331-a8fb-706f5963c5ed.aspx</comments>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been working all day on this WPF/WCF application, mostly trying to figure out
how to configure WCF to actually do what I want in terms of security and authentication.
All those angle brackets from the config files have given me a splitting headache...
WCF may be cool, but configuring even relatively simple security scenarios is ridiculously
difficult.
</p>
        <p>
And then distaster struck. As though fighting with WCF and SSL wasn't enough, VS 2008
decided to quit publishing my app for ClickOnce. In order to test this app, I need
to publish for ClickOnce on my dev box, copy the results to a test server and then
run the code on a test client (thankfully we live in an age of virtual machines!!).
</p>
        <p>
So the failure to publish to ClickOnce brought me up short. The issue is that the
WPF project wouldn't build. It would build and run fine in all other ways, but not
when I tried to publish for ClickOnce. It <em>had been publishing</em> just fine,
and then BOOM!
</p>
        <p>
(The only thing I can think of is that I was publishing for online only, then I published
for online/offline, and then I switched back to online only - maybe VS doesn't like
that sort of waffling and wants me to be more decisive?)
</p>
        <p>
The specific problem is that the .g.i.cs files for each XAML source file that should
have been in the obj\Debug directory didn't get there. Google was no help - searching
for "clickonce publish .g.i.cs obj\Debug could not be found" resulted in one hit -
to an MSDN forums post that was unreachable (I kept getting an MSDN forums error page).
</p>
        <p>
          <em>Build|Clean Solution</em> had no effect. Shutting down and reopening VS had no
effect. Rebooting the dev box had no effect.
</p>
        <p>
Finally I thought to manually delete the obj and bin folders in the project directory.
And for good measure I deleted the .user file and .suo file for the project and solution.
Then I reopened the project and it how publishes just fine.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84" />
      </body>
      <title>ClickOnce and WFP publish failure (and solution)</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84.aspx</guid>
      <link>http://www.lhotka.net/weblog/ClickOnceAndWFPPublishFailureAndSolution.aspx</link>
      <pubDate>Wed, 19 Dec 2007 23:10:22 GMT</pubDate>
      <description>&lt;p&gt;
I've been working all day on this WPF/WCF application, mostly trying to figure out
how to configure WCF to actually do what I want in terms of security and authentication.
All those angle brackets from the config files have given me a splitting headache...
WCF may be cool, but configuring even relatively simple security scenarios is ridiculously
difficult.
&lt;/p&gt;
&lt;p&gt;
And then distaster struck. As though fighting with WCF and SSL wasn't enough, VS 2008
decided to quit publishing my app for ClickOnce. In order to test this app, I need
to publish for ClickOnce on my dev box, copy the results to a test server and then
run the code on a test client (thankfully we live in an age of virtual machines!!).
&lt;/p&gt;
&lt;p&gt;
So the failure to publish to ClickOnce brought me up short. The issue is that the
WPF project wouldn't build. It would build and run fine in all other ways, but not
when I tried to publish for ClickOnce. It &lt;em&gt;had been publishing&lt;/em&gt; just fine,
and then BOOM!
&lt;/p&gt;
&lt;p&gt;
(The only thing I can think of is that I was publishing for online only, then I published
for online/offline, and then I switched back to online only - maybe VS doesn't like
that sort of waffling and wants me to be more decisive?)
&lt;/p&gt;
&lt;p&gt;
The specific problem is that the .g.i.cs files for each XAML source file that should
have been in the obj\Debug directory didn't get there. Google was no help - searching
for "clickonce publish .g.i.cs obj\Debug could not be found" resulted in one hit -
to an MSDN forums post that was unreachable (I kept getting an MSDN forums error page).
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Build|Clean Solution&lt;/em&gt; had no effect. Shutting down and reopening VS had no
effect. Rebooting the dev box had no effect.
&lt;/p&gt;
&lt;p&gt;
Finally I thought to manually delete the obj and bin folders in the project directory.
And for good measure I deleted the .user file and .suo file for the project and solution.
Then I reopened the project and it how publishes just fine.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,d9db6f2a-7522-4bb0-acd3-8d5d3e03ba84.aspx</comments>
      <category>Microsoft .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=524845db-67cb-489b-8312-e9de004d7789</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,524845db-67cb-489b-8312-e9de004d7789.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,524845db-67cb-489b-8312-e9de004d7789.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=524845db-67cb-489b-8312-e9de004d7789</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was recently asked whether CSLA incorporates thread synchronization code to marshal
calls or events back onto the UI thread when necessary. The short answer is no, but
the question deserves a bit more discussion to understand why it isn't the business
layer's job to handle such details. 
</p>
        <p>
The responsibility for cross-thread issues resides with the layer that started the
multi-threading. 
</p>
        <p>
So if the business layer internally utilizes multi-threading, then that layer must
abstract the concept from other layers. 
</p>
        <p>
But if the UI layer utilizes multi-threading (which is more common), then it is the
UI layer's job to abstract that concept. 
</p>
        <p>
It is unrealistic to build a reusable business layer around one type of multi-threading
model and expect it to work in other scenarios. Were you to use Windows Forms components
for thread synchronization, you'd be out of luck in the ASP.NET world, for example. 
</p>
        <p>
So CSLA does nothing in this regard, at the business object level anyway. Nor does
a DataSet, or the entity objects from ADO.NET EF, etc. It isn't the business/entity
layer's problem. 
</p>
        <p>
CSLA does do some multi-threading, specifically in the Csla.Wpf.CslaDataProvider control,
because it supports the IsAsynchronous property. But even there, WPF data binding
does the abstraction, so there's no thread issues in either the business or UI layers.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=524845db-67cb-489b-8312-e9de004d7789" />
      </body>
      <title>Who is responsible for thread synchronization</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,524845db-67cb-489b-8312-e9de004d7789.aspx</guid>
      <link>http://www.lhotka.net/weblog/WhoIsResponsibleForThreadSynchronization.aspx</link>
      <pubDate>Tue, 13 Nov 2007 17:09:54 GMT</pubDate>
      <description>&lt;p&gt;
I was recently asked whether CSLA incorporates thread synchronization code to marshal
calls or events back onto the UI thread when necessary. The short answer is no, but
the question deserves a bit more discussion to understand why it isn't the business
layer's job to handle such details. 
&lt;p&gt;
The responsibility for cross-thread issues resides with the layer that started the
multi-threading. 
&lt;p&gt;
So if the business layer internally utilizes multi-threading, then that layer must
abstract the concept from other layers. 
&lt;p&gt;
But if the UI layer utilizes multi-threading (which is more common), then it is the
UI layer's job to abstract that concept. 
&lt;p&gt;
It is unrealistic to build a reusable business layer around one type of multi-threading
model and expect it to work in other scenarios. Were you to use Windows Forms components
for thread synchronization, you'd be out of luck in the ASP.NET world, for example. 
&lt;p&gt;
So CSLA does nothing in this regard, at the business object level anyway. Nor does
a DataSet, or the entity objects from ADO.NET EF, etc. It isn't the business/entity
layer's problem. 
&lt;p&gt;
CSLA does do some multi-threading, specifically in the Csla.Wpf.CslaDataProvider control,
because it supports the IsAsynchronous property. But even there, WPF data binding
does the abstraction, so there's no thread issues in either the business or UI layers.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=524845db-67cb-489b-8312-e9de004d7789" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,524845db-67cb-489b-8312-e9de004d7789.aspx</comments>
      <category>Architecture</category>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=1eea8bbc-d325-4376-aab0-5580dc5c7784</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,1eea8bbc-d325-4376-aab0-5580dc5c7784.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,1eea8bbc-d325-4376-aab0-5580dc5c7784.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=1eea8bbc-d325-4376-aab0-5580dc5c7784</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I haven't tried this yet, but it looks like a very nice tool for WPF developers:
</p>
        <p>
          <a href="http://www.codeproject.com/useritems/WoodstockForWPF.asp">Woodstock for WPF
- The Code Project - Windows Presentation Foundation</a>
        </p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1eea8bbc-d325-4376-aab0-5580dc5c7784" />
      </body>
      <title>WPF debugging visualizer</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,1eea8bbc-d325-4376-aab0-5580dc5c7784.aspx</guid>
      <link>http://www.lhotka.net/weblog/WPFDebuggingVisualizer.aspx</link>
      <pubDate>Tue, 13 Nov 2007 16:48:41 GMT</pubDate>
      <description>&lt;p&gt;
I haven't tried this yet, but it looks like a very nice tool for WPF developers:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.codeproject.com/useritems/WoodstockForWPF.asp"&gt;Woodstock for WPF
- The Code Project - Windows Presentation Foundation&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=1eea8bbc-d325-4376-aab0-5580dc5c7784" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,1eea8bbc-d325-4376-aab0-5580dc5c7784.aspx</comments>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=ab37dbeb-58a3-4aef-bf84-448a233cf0e9</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,ab37dbeb-58a3-4aef-bf84-448a233cf0e9.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,ab37dbeb-58a3-4aef-bf84-448a233cf0e9.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ab37dbeb-58a3-4aef-bf84-448a233cf0e9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Earlier this week I co-presented a session at ReMIX in Boston, with Anthony Handley,
a fellow <a href="http://www.magenic.com">Magenicon</a>. Anthony is a User Experience
Specialist, and the two of us have been working on a WPF/Silverlight project (that
also happens to use CSLA .NET of course :) ) and in this presentation we discussed
our experiences using WPF from the perspectives of a developer and a designer.
</p>
        <p>
Here are the links to the video of the session.
</p>
        <h3>Real World Experiences Building Applications Using WPF and Silverlight
</h3>
        <p>
Part 1<br /><a href="http://channel9.msdn.com/Showpost.aspx?postid=346810">http://channel9.msdn.com/Showpost.aspx?postid=346810</a><br />
Part 2<br /><a href="http://channel9.msdn.com/Showpost.aspx?postid=346812">http://channel9.msdn.com/Showpost.aspx?postid=346812</a><br />
Part 3<br /><a href="http://channel9.msdn.com/Showpost.aspx?postid=346815">http://channel9.msdn.com/Showpost.aspx?postid=346815</a><br />
Part 4<br /><a href="http://channel9.msdn.com/Showpost.aspx?postid=346818">http://channel9.msdn.com/Showpost.aspx?postid=346818</a></p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ab37dbeb-58a3-4aef-bf84-448a233cf0e9" />
      </body>
      <title>ReMIX presentation video is online</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,ab37dbeb-58a3-4aef-bf84-448a233cf0e9.aspx</guid>
      <link>http://www.lhotka.net/weblog/ReMIXPresentationVideoIsOnline.aspx</link>
      <pubDate>Wed, 10 Oct 2007 21:10:17 GMT</pubDate>
      <description>&lt;p&gt;
Earlier this week I co-presented a session at ReMIX in Boston, with Anthony Handley,
a fellow &lt;a href="http://www.magenic.com"&gt;Magenicon&lt;/a&gt;. Anthony is a User Experience
Specialist, and the two of us have been working on a WPF/Silverlight project (that
also happens to use CSLA .NET of course :) ) and in this presentation we discussed
our experiences using WPF from the perspectives of a developer and a designer.
&lt;/p&gt;
&lt;p&gt;
Here are the links to the video of the session.
&lt;/p&gt;
&lt;h3&gt;Real World Experiences Building Applications Using WPF and Silverlight
&lt;/h3&gt;
&lt;p&gt;
Part 1&lt;br&gt;
&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=346810"&gt;http://channel9.msdn.com/Showpost.aspx?postid=346810&lt;/a&gt;
&lt;br&gt;
Part 2&lt;br&gt;
&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=346812"&gt;http://channel9.msdn.com/Showpost.aspx?postid=346812&lt;/a&gt;
&lt;br&gt;
Part 3&lt;br&gt;
&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=346815"&gt;http://channel9.msdn.com/Showpost.aspx?postid=346815&lt;/a&gt;
&lt;br&gt;
Part 4&lt;br&gt;
&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=346818"&gt;http://channel9.msdn.com/Showpost.aspx?postid=346818&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ab37dbeb-58a3-4aef-bf84-448a233cf0e9" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,ab37dbeb-58a3-4aef-bf84-448a233cf0e9.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=79bf5dfe-851a-427a-ba10-6f975591ed3e</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,79bf5dfe-851a-427a-ba10-6f975591ed3e.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,79bf5dfe-851a-427a-ba10-6f975591ed3e.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=79bf5dfe-851a-427a-ba10-6f975591ed3e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In CSLA .NET 3.0 I implemented Csla.Wpf.Validator. This control provides functionality
similar to the Windows Forms ErrorProvider control, only in WPF. Of course the ErrorProvider
relies on the standard IDataErrorInfo interface, which CSLA supports on behalf of
your business objects, and so my Validator control used that same interface.
</p>
        <p>
While I was researching and designing the Validator control, I was in contact with
the WPF product team. As a result, I had (shall we say) a "strong suspicion"
that my control was a temporary stop-gap until Microsoft provided a more integrated
solution. And that's fine - we needed something that worked, and Validator was
the ticket.
</p>
        <p>
This blog post provides some good, detailed, insight into the <em>real</em> solution
in .NET 3.5: 
</p>
        <p>
          <a href="http://blogs.msdn.com/wpfsdk/archive/2007/10/02/data-validation-in-3-5.aspx">Windows
Presentation Foundation SDK : Data Validation in 3.5</a>
        </p>
        <p>
A couple people have emailed me, asking what I think about this. My answer: I'm happy
as can be!
</p>
        <p>
As I say, I knew Validator was temporary. WPF is a version 1.0 technology, and it
is <em>very</em> clear that Microsoft will be evolving it rapidly over the next few
years. And it is equally clear that WPF must evolve to catch up to, and hopefully
exceed, Windows Forms. That means more robust data binding support, including an ErrorProvider
equivalent.
</p>
        <p>
So to me, this just means that CSLA .NET 3.5 can drop the Validator control, because
there's now a directly supported solution in .NET itself. While this will require
changing XAML when moving from .NET 3.0 to 3.5, it is a worthwhile change to make.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=79bf5dfe-851a-427a-ba10-6f975591ed3e" />
      </body>
      <title>CSLA .NET 3.5 - no more WPF Validator control</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,79bf5dfe-851a-427a-ba10-6f975591ed3e.aspx</guid>
      <link>http://www.lhotka.net/weblog/CSLANET35NoMoreWPFValidatorControl.aspx</link>
      <pubDate>Wed, 10 Oct 2007 15:31:01 GMT</pubDate>
      <description>&lt;p&gt;
In CSLA .NET 3.0 I implemented&amp;nbsp;Csla.Wpf.Validator. This control provides&amp;nbsp;functionality
similar to the Windows Forms ErrorProvider control, only in WPF. Of course the ErrorProvider
relies on the standard IDataErrorInfo interface, which CSLA supports on behalf of
your business objects, and so my Validator control used that same interface.
&lt;/p&gt;
&lt;p&gt;
While I was researching and designing the Validator control, I was in contact with
the WPF product team. As a result, I had&amp;nbsp;(shall we say) a "strong suspicion"
that my control was a temporary stop-gap until Microsoft provided a more integrated
solution. And that's fine - we needed something that worked, and&amp;nbsp;Validator&amp;nbsp;was
the ticket.
&lt;/p&gt;
&lt;p&gt;
This blog post provides some good, detailed, insight into the &lt;em&gt;real&lt;/em&gt; solution
in .NET 3.5:&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.msdn.com/wpfsdk/archive/2007/10/02/data-validation-in-3-5.aspx"&gt;Windows
Presentation Foundation SDK : Data Validation in 3.5&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
A couple people have emailed me, asking what I think about this. My answer: I'm happy
as can be!
&lt;/p&gt;
&lt;p&gt;
As I say, I knew Validator was temporary. WPF is a version 1.0 technology, and it
is &lt;em&gt;very&lt;/em&gt; clear that Microsoft will be evolving it rapidly over the next few
years. And it is equally clear that WPF must evolve to catch up to, and hopefully
exceed, Windows Forms. That means more robust data binding support, including an ErrorProvider
equivalent.
&lt;/p&gt;
&lt;p&gt;
So to me, this just means that CSLA .NET 3.5 can drop the Validator control, because
there's now a directly supported solution in .NET itself. While this will require
changing XAML when moving from .NET 3.0 to 3.5, it is a worthwhile change to make.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=79bf5dfe-851a-427a-ba10-6f975591ed3e" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,79bf5dfe-851a-427a-ba10-6f975591ed3e.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=bcd4e249-8203-40e2-bced-2978423fd38b</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=bcd4e249-8203-40e2-bced-2978423fd38b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div style="FLOAT: right; MARGIN: 5px 15px 5px 5px">
          <a href="http://store.lhotka.net">
            <img src="http://www.lhotka.net/images/csla30cscover-165.jpg" border="0" />
          </a>
        </div>
        <p>
CSLA .NET version 3.0 adds support for Microsoft .NET 3.0 features. This ~120
page ebook covers how to use these new capabilities: 
</p>
        <p>
        </p>
        <ul>
          <li>
Windows Presentation Foundation (WPF) 
<ul><li>
Creating WPF forms using business objects 
</li><li>
Using the new controls in the Csla.Wpf namespace 
<ul><li>
CslaDataProvider 
</li><li>
Validator 
</li><li>
Authorizer 
</li><li>
ObjectStatus 
</li><li>
IdentityConverter</li></ul></li><li>
Maximizing XAML and minimizing C#/VB code</li></ul></li>
          <li>
Windows Communication Foundation (WCF) 
<ul><li>
Using the new WCF data portal channel to seamlessly upgrade from Remoting, Web services
or Enterprise Services 
</li><li>
Building WCF services using business objects 
</li><li>
Applying WCF security to encrypt data on the wire 
</li><li>
Sending username/password credentials to a WCF service 
<ul><li>
Including use of the new Csla.Security.PrincipalCache class</li></ul></li><li>
Using the DataContract attribute instead of the Serializable attribute</li></ul></li>
          <li>
Windows Workflow Foundation (WF) 
<ul><li>
Creating activities using business objects 
</li><li>
Invoking a workflow from a business object 
</li><li>
Using the WorkflowManager class in the Csla.Workflow namespace</li></ul></li>
        </ul>
        <p>
Version 3.0 is an <em>additive update</em>, meaning that you only need to use the
.NET 3.0 features if you are using .NET 3.0. CSLA .NET 3.0 <em>is useful <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=ac20fe4c-6afc-4176-bcb4-d74b5a370356">for
people using .NET 2.0</a>!!</em> These features include:
</p>
        <ul>
          <li>
Enhancements to the validation subsystem 
<ul><li>
Friendly names for properties 
</li><li>
Better null handling in the RegExMatch rule method 
</li><li>
New StringMinLength rule method 
</li><li>
Help for code generation through the DecoratedRuleArgs class</li></ul></li>
          <li>
Data binding issues 
<ul><li>
Fixed numerous bugs in BusinessListBase to improve data binding behavior 
</li><li>
Throw exception when edit levels get out of sync, making debugging easier 
</li><li>
N-level undo changed to provide parity with Windows Forms data binding requirements</li></ul></li>
          <li>
AutoCloneOnUpdate 
<ul><li>
Automatically clone objects when Save() is called, but only when data portal is local</li></ul></li>
          <li>
Enhancements to the authorization subsystem 
<ul><li>
CanExecuteMethod() allows authorization for arbitrary methods</li></ul></li>
        </ul>
        <p>
CSLA .NET 3.0 includes numerous bug fixes and some feature enhancements that benefit
everyone. If you are using version 2.0 or 2.1, you should consider upgrading to 3.0
to gain these benefits, even if you aren't using .NET 3.0.
</p>
        <p>
See the change logs for <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=0c94aa82-b975-455b-a0c5-f4f7196a2408">version
3.0</a>, <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=4534c39c-c5d8-4553-88af-bdc1c8149cbc">version
3.0.1</a> and <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=7360998d-d842-49f6-b1f0-a21b517798e3">version
3.0.2</a> for a more detailed list of changes.
</p>
        <p>
          <em>Using CSLA .NET 3.0</em> is completely focused on how to use the new features
in version 3.0. The book does not detail the internal changes to CSLA .NET itself,
so all ~120 pages help you use the enhancements added since version 2.1.
</p>
        <p>
          <font size="5">Get the book at </font>
          <a href="http://store.lhotka.net/">
            <font size="5">store.lhotka.net</font>
          </a>
          <font size="5">. 
<br />
(C# available now, VB available in early October)</font>
        </p>
        <p>
Download the 3.0.2 code from the <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA
.NET download page</a>.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=bcd4e249-8203-40e2-bced-2978423fd38b" />
      </body>
      <title>Using CSLA .NET 3.0 ebook available (and CSLA .NET version 3.0.2)</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</guid>
      <link>http://www.lhotka.net/weblog/UsingCSLANET30EbookAvailableAndCSLANETVersion302.aspx</link>
      <pubDate>Fri, 28 Sep 2007 21:21:26 GMT</pubDate>
      <description>&lt;div style="FLOAT: right; MARGIN: 5px 15px 5px 5px"&gt;&lt;a href="http://store.lhotka.net"&gt;&lt;img src="http://www.lhotka.net/images/csla30cscover-165.jpg" border=0&gt;&lt;/a&gt; 
&lt;/div&gt;
&lt;p&gt;
CSLA .NET version&amp;nbsp;3.0 adds support for Microsoft .NET 3.0 features. This ~120
page ebook covers how to use these new capabilities: 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Windows Presentation Foundation (WPF) 
&lt;ul&gt;
&lt;li&gt;
Creating&amp;nbsp;WPF forms using business objects 
&lt;li&gt;
Using the new controls in the Csla.Wpf namespace 
&lt;ul&gt;
&lt;li&gt;
CslaDataProvider 
&lt;li&gt;
Validator 
&lt;li&gt;
Authorizer 
&lt;li&gt;
ObjectStatus 
&lt;li&gt;
IdentityConverter&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Maximizing XAML and minimizing C#/VB code&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Windows Communication Foundation (WCF) 
&lt;ul&gt;
&lt;li&gt;
Using the new WCF data portal channel to seamlessly upgrade from Remoting, Web services
or Enterprise Services 
&lt;li&gt;
Building WCF services using business objects 
&lt;li&gt;
Applying WCF security to encrypt data on the wire 
&lt;li&gt;
Sending username/password credentials to a WCF service 
&lt;ul&gt;
&lt;li&gt;
Including use of the new Csla.Security.PrincipalCache class&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Using the DataContract attribute instead of the Serializable attribute&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Windows Workflow Foundation (WF) 
&lt;ul&gt;
&lt;li&gt;
Creating activities using business objects 
&lt;li&gt;
Invoking a workflow from a business object 
&lt;li&gt;
Using the WorkflowManager class in the Csla.Workflow namespace&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Version 3.0 is an &lt;em&gt;additive update&lt;/em&gt;, meaning that you only need to use the
.NET 3.0 features if you are using .NET 3.0. CSLA .NET 3.0 &lt;em&gt;is useful &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=ac20fe4c-6afc-4176-bcb4-d74b5a370356"&gt;for
people using .NET 2.0&lt;/a&gt;!!&lt;/em&gt; These features include:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Enhancements to the validation subsystem 
&lt;ul&gt;
&lt;li&gt;
Friendly names for properties 
&lt;li&gt;
Better null handling in the RegExMatch rule method 
&lt;li&gt;
New StringMinLength rule method 
&lt;li&gt;
Help for code generation through the DecoratedRuleArgs class&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Data binding issues 
&lt;ul&gt;
&lt;li&gt;
Fixed numerous bugs in BusinessListBase to improve data binding behavior 
&lt;li&gt;
Throw exception when edit levels get out of sync, making debugging easier 
&lt;li&gt;
N-level undo changed to provide parity with Windows Forms data binding requirements&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
AutoCloneOnUpdate 
&lt;ul&gt;
&lt;li&gt;
Automatically clone objects when Save() is called, but only when data portal is local&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Enhancements to the authorization subsystem 
&lt;ul&gt;
&lt;li&gt;
CanExecuteMethod() allows authorization for arbitrary methods&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
CSLA .NET 3.0 includes numerous bug fixes and some feature enhancements that benefit
everyone. If you are using version 2.0 or 2.1, you should consider upgrading to 3.0
to gain these benefits, even if you aren't using .NET 3.0.
&lt;/p&gt;
&lt;p&gt;
See the change logs for &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=0c94aa82-b975-455b-a0c5-f4f7196a2408"&gt;version
3.0&lt;/a&gt;, &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=4534c39c-c5d8-4553-88af-bdc1c8149cbc"&gt;version
3.0.1&lt;/a&gt; and &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=7360998d-d842-49f6-b1f0-a21b517798e3"&gt;version
3.0.2&lt;/a&gt; for a more detailed list of changes.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Using CSLA .NET 3.0&lt;/em&gt; is completely focused on how to use the new features
in version 3.0. The book does not detail the internal changes to CSLA .NET itself,
so all ~120 pages help you use the enhancements added since version 2.1.
&lt;/p&gt;
&lt;p&gt;
&lt;font size=5&gt;Get the book at &lt;/font&gt;&lt;a href="http://store.lhotka.net/"&gt;&lt;font size=5&gt;store.lhotka.net&lt;/font&gt;&lt;/a&gt;&lt;font size=5&gt;. 
&lt;br&gt;
(C# available now, VB available in early October)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Download the 3.0.2 code from the &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA
.NET download page&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=bcd4e249-8203-40e2-bced-2978423fd38b" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</comments>
      <category>Books</category>
      <category>CSLA .NET</category>
      <category>WCF</category>
      <category>Workflow</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=06f305de-ec32-4e20-b042-171b58f305ae</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,06f305de-ec32-4e20-b042-171b58f305ae.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,06f305de-ec32-4e20-b042-171b58f305ae.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=06f305de-ec32-4e20-b042-171b58f305ae</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It is a reasonably well-known fact that WPF misuses the Equals() method in the data
binding implementation.
</p>
        <p>
If you set a DataContext to an object, then set it to <em>another object</em> that
is logically equal to the first, but which has different data, WFP gladly ignores
the new object's data:
</p>
        <blockquote>
          <p>
form.DataContext = A;<br />
B = A.Clone();<br />
B.Value = "new value";<br />
form.DataContext = B;
</p>
        </blockquote>
        <p>
Assuming A and B retain logical equality even though Value has changed, this code
results in the UI <em>not showing the new value</em>. Apparently the reasoning is
that if the objects are equal, then there's no need to update any data through data
binding.
</p>
        <p>
Of course this totally confuses <em>ReferenceEquals()</em> with <em>Equals()</em>,
and the result is that objects used by WFP can no longer have logical equality. They
can only have reference equality.
</p>
        <p>
(or, arguably, WPF forces 100% property-level equality across objects, so equality
can extend to two different instances as long as they have absolutely no different
property values - which seems entirely useless)
</p>
        <p>
In .NET 3.0 I had a solution, at least in CslaDataProvider. The solution was to temporarily
set the DataContext to null, then to the new object. The result was that the faulty
(imo anyway) equality comparison was defeated.
</p>
        <p>
Unfortunately, it appears that .NET 3.5 may have "fixed a bug" that prevents this
from working. The result is that it appears there is NO WAY TO REFRESH DATA when fields
of an object change, but the object's logical identity remains the same.
</p>
        <p>
I'm not yet sure of a final solution. The current situation is very bad, because you
can either use WPF <em>or</em> you can have logical equality between objects - but
not both.
</p>
        <p>
It might be the case that people who need logical equality will have to implement
their own parallel Equals() concept - ignoring the standard one built into .NET. That's
a really poor solution, but if Microsoft isn't going to use their own framework responsibly
then we're kind of stuck. Of course operators become an issue then, since operator
overloading is related to Equals() as well. I suppose you could break that relationship,
but then you'd get really odd stuff like this:
</p>
        <blockquote>
          <p>
x = y is true
</p>
          <p>
x.Equals(y) is false
</p>
        </blockquote>
        <p>
But if WPF forces Equals() to be <em>ReferenceEquals()</em> instead of actual equality,
then we come back to being stuck.
</p>
        <p>
I love WPF - it is really cool. But this particular issue is a real problem. Apparently
one without a real solution.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=06f305de-ec32-4e20-b042-171b58f305ae" />
      </body>
      <title>Data refresh in WPF</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,06f305de-ec32-4e20-b042-171b58f305ae.aspx</guid>
      <link>http://www.lhotka.net/weblog/DataRefreshInWPF.aspx</link>
      <pubDate>Fri, 28 Sep 2007 15:02:38 GMT</pubDate>
      <description>&lt;p&gt;
It is a reasonably well-known fact that WPF misuses the Equals() method in the data
binding implementation.
&lt;/p&gt;
&lt;p&gt;
If you set a DataContext to an object, then set it to &lt;em&gt;another object&lt;/em&gt; that
is logically equal to the first, but which has different data, WFP gladly ignores
the new object's data:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
form.DataContext = A;&lt;br&gt;
B = A.Clone();&lt;br&gt;
B.Value = "new value";&lt;br&gt;
form.DataContext = B;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Assuming A and B retain logical equality even though Value has changed, this code
results in the UI &lt;em&gt;not showing the new value&lt;/em&gt;. Apparently the reasoning is
that if the objects are equal, then there's no need to update any data through data
binding.
&lt;/p&gt;
&lt;p&gt;
Of course this totally confuses &lt;em&gt;ReferenceEquals()&lt;/em&gt; with &lt;em&gt;Equals()&lt;/em&gt;,
and the result is that objects used by WFP can no longer have logical equality. They
can only have reference equality.
&lt;/p&gt;
&lt;p&gt;
(or, arguably, WPF forces 100% property-level equality across objects, so equality
can extend to two different instances as long as they have absolutely no different
property values - which seems entirely useless)
&lt;/p&gt;
&lt;p&gt;
In .NET 3.0 I had a solution, at least in CslaDataProvider. The solution was to temporarily
set the DataContext to null, then to the new object. The result was that the faulty
(imo anyway) equality comparison was defeated.
&lt;/p&gt;
&lt;p&gt;
Unfortunately, it appears that .NET 3.5 may have "fixed a bug" that prevents this
from working. The result is that it appears there is NO WAY TO REFRESH DATA when fields
of an object change, but the object's logical identity remains the same.
&lt;/p&gt;
&lt;p&gt;
I'm not yet sure of a final solution. The current situation is very bad, because you
can either use WPF &lt;em&gt;or&lt;/em&gt; you can have logical equality between objects - but
not both.
&lt;/p&gt;
&lt;p&gt;
It might be the case that people who need logical equality will have to implement
their own parallel Equals() concept - ignoring the standard one built into .NET. That's
a really poor solution, but if Microsoft isn't going to use their own framework responsibly
then we're kind of stuck. Of course operators become an issue then, since operator
overloading is related to Equals() as well. I suppose you could break that relationship,
but then you'd get really odd stuff like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
x = y is true
&lt;/p&gt;
&lt;p&gt;
x.Equals(y) is false
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
But if WPF forces Equals() to be &lt;em&gt;ReferenceEquals()&lt;/em&gt; instead of actual equality,
then we come back to being stuck.
&lt;/p&gt;
&lt;p&gt;
I love WPF - it is really cool. But this particular issue is a real problem. Apparently
one without a real solution.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=06f305de-ec32-4e20-b042-171b58f305ae" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,06f305de-ec32-4e20-b042-171b58f305ae.aspx</comments>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=ca4b9ae6-1db7-4f96-bcba-9723191bf702</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,ca4b9ae6-1db7-4f96-bcba-9723191bf702.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,ca4b9ae6-1db7-4f96-bcba-9723191bf702.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ca4b9ae6-1db7-4f96-bcba-9723191bf702</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just got back from <a href="http://www.vslive.com">VS Live NY</a> - which was a
great show. It sold out, and the people attending were very engaged and fun to be
with. I love crowds like that!
</p>
        <p>
In my all-day workshop on building distributed apps using objects I showed how to
use WPF <em>commanding</em> to automatically enable/disable Save and Cancel buttons
on a form by connecting them to a CslaDataProvider control. That's a really cool feature
of WPF that I am leveraging with some of the new <a href="http://www.lhotka.net/cslanet">CSLA
.NET</a> 3.0 features.
</p>
        <p>
An attendee asked if it was possible to <em>hide</em> the Save button, not just disable
it. I hadn't thought about that, and came up with some answer involving code.
</p>
        <p>
Josh Smith, who was also in the audience, has given this even further thought and
sent me an email with a better, pure XAML, solution. Thank you Josh!! Here's the relevant
bit of the email:
</p>
        <blockquote>
          <p>
During the presentation a fellow asked you how, in WPF, to hide a Button when it is
disabled.  The Button was disabled because its associated command could not execute,
and he wanted to hide the Button instead of letting it sit in the UI disabled. 
</p>
          <p>
The solution you gave him involved some code, which threw a red flag in my mind. 
IMO, this is the kind of thing you should use XAML to express, so that there are less
"moving parts" in your app.  Here's one way to implement that functionality with
no code at all: 
</p>
          <p>
&lt;Button Command="Open" Content="_Open"&gt;<br />
  &lt;Button.Style&gt;<br />
    &lt;Style TargetType="Button"&gt;<br />
      &lt;Style.Triggers&gt;<br />
        &lt;Trigger Property="IsEnabled" Value="False"&gt; 
<br />
          &lt;Setter Property="Visibility"
Value="Collapsed" /&gt;<br />
        &lt;/Trigger&gt;<br />
      &lt;/Style.Triggers&gt;<br />
    &lt;/Style&gt;<br />
  &lt;/Button.Style&gt;<br />
&lt;/Button&gt;
</p>
          <p>
Depending on your layout, you might want to set Visibility to Hidden instead.
</p>
        </blockquote>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ca4b9ae6-1db7-4f96-bcba-9723191bf702" />
      </body>
      <title>Hiding a disabled Save button in WPF</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,ca4b9ae6-1db7-4f96-bcba-9723191bf702.aspx</guid>
      <link>http://www.lhotka.net/weblog/HidingADisabledSaveButtonInWPF.aspx</link>
      <pubDate>Fri, 21 Sep 2007 13:01:20 GMT</pubDate>
      <description>&lt;p&gt;
I just got back from &lt;a href="http://www.vslive.com"&gt;VS Live NY&lt;/a&gt; - which was a
great show. It sold out, and the people attending were very engaged and fun to be
with. I love crowds like that!
&lt;/p&gt;
&lt;p&gt;
In my all-day workshop on building distributed apps using objects I showed how to
use WPF &lt;em&gt;commanding&lt;/em&gt; to automatically enable/disable Save and Cancel buttons
on a form by connecting them to a CslaDataProvider control. That's a really cool feature
of WPF that I am leveraging with some of the new &lt;a href="http://www.lhotka.net/cslanet"&gt;CSLA
.NET&lt;/a&gt; 3.0 features.
&lt;/p&gt;
&lt;p&gt;
An attendee asked if it was possible to &lt;em&gt;hide&lt;/em&gt; the Save button, not just disable
it. I hadn't thought about that, and came up with some answer involving code.
&lt;/p&gt;
&lt;p&gt;
Josh Smith, who was also in the audience, has given this even further thought and
sent me an email with a better, pure XAML, solution. Thank you Josh!! Here's the relevant
bit of the email:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
During the presentation a fellow asked you how, in WPF, to hide a Button when it is
disabled.&amp;nbsp; The Button was disabled because its associated command could not execute,
and he wanted to hide the Button instead of letting it sit in the UI disabled. 
&lt;/p&gt;
&lt;p&gt;
The solution you gave him involved some code, which threw a red flag in my mind.&amp;nbsp;
IMO, this is the kind of thing you should use XAML to express, so that there are less
"moving parts" in your app.&amp;nbsp; Here's one way to implement that functionality with
no code at all: 
&lt;/p&gt;
&lt;p&gt;
&amp;lt;Button Command="Open" Content="_Open"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;Button.Style&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Style TargetType="Button"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Style.Triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Trigger Property="IsEnabled" Value="False"&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setter Property="Visibility"
Value="Collapsed" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Trigger&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Style.Triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Style&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/Button.Style&amp;gt;&lt;br&gt;
&amp;lt;/Button&amp;gt;
&lt;/p&gt;
&lt;p&gt;
Depending on your layout, you might want to set Visibility to Hidden instead.
&lt;/p&gt;
&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=ca4b9ae6-1db7-4f96-bcba-9723191bf702" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,ca4b9ae6-1db7-4f96-bcba-9723191bf702.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=5d0f03d0-e4a6-45bb-a65b-21e670601258</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,5d0f03d0-e4a6-45bb-a65b-21e670601258.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,5d0f03d0-e4a6-45bb-a65b-21e670601258.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=5d0f03d0-e4a6-45bb-a65b-21e670601258</wfw:commentRss>
      <title>Codeless WPF data edit forms with CslaDataProvider</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,5d0f03d0-e4a6-45bb-a65b-21e670601258.aspx</guid>
      <link>http://www.lhotka.net/weblog/CodelessWPFDataEditFormsWithCslaDataProvider.aspx</link>
      <pubDate>Wed, 20 Jun 2007 16:14:03 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;A CSLA .NET user, Aaron Nottestad, has been
helping test 3.0 and ran into some issues when using the new WPF CslaDataProvider
with editable objects. Thanks Aaron!&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;As a result, I had to do some work with CslaDataProvider,
so it can manage the object’s entire lifetime from create/fetch through to save/cancel.
If it can’t manage the lifetime, especially the save, then it can’t get the new object
that comes back as a result of save. And if it doesn’t get that new object, then neither
does data binding, so the UI controls end up editing an old instance of the object.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;So the CslaDataProvider now has Save() and
Cancel() methods that you can call to trigger saving or canceling of the business
object. Also, as the object is created/fetched CslaDataProvider automatically calls
BeginEdit() on the object.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;This behavior is all optional, and is controlled
by the ManageObjectLifetime property of the CslaDataProvider control. So if you want
this behavior, you have to set that property to True. If you leave it at False (the
default), then you must manage everything through code – though honestly you &lt;i style="mso-bidi-font-style: normal"&gt;can’t&lt;/i&gt; manage
editable objects through code while using CslaDataProvider. So maybe I should make
the default be True? Hmm.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Anyway, this was easy enough to do and worked
great. The resulting forms had exactly 4 lines of code – 2 to call Save() and 2 to
call Cancel(). It occurred to me that there &lt;i style="mso-bidi-font-style: normal"&gt;must&lt;/i&gt; be
a way to avoid writing those 4 lines of boring code, and Aaron put me onto the RoutedCommand
concept in XAML.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;A RoutedCommand allows a control like a button
or menu item to invoke a method on another control – purely through XAML. There are
many examples out there about how this works to create standard Copy/Paste menu items
that run against the current TextBox control, and that sort of thing. But none that
I found which routed a command to a data provider control.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The reason turns out to be that the &lt;i style="mso-bidi-font-style: normal"&gt;target&lt;/i&gt; of
a command must be a UIElement, and data providers don’t inherit from that base class.
Oops…&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;I thought I was stuck, because I really &lt;i style="mso-bidi-font-style: normal"&gt;do&lt;/i&gt; want
to route the command to CslaDataProvider in this case. However, I figured out a solution.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;CslaDataProvider now has a read-only CommandManager
property. This property exposes a “command manager” object which does inherit from
UIElement and which does handle the Save and Undo routed commands. When it is created
by CslaDataProvider, it is given a reference to the CslaDataProvider control, so it
simply delegates all Save commands to the CslaDataProvider.Save() method and all Undo
commands to CslaDataProvider.Cancel().&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;With that done, you can route a command from
a button or menu item (or any other valid command source) to this CommandManager object,
which effectively means you’ve routed the command to the CslaDataProvider control.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The CslaDataProvider gets declared like this:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;csla:CslaDataProvider x:Key="ChildList"&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ObjectType="{x:Type this:ChildList}"&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
FactoryMethod="GetList"&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
IsAsynchronous="False"&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ManageObjectLifetime="True"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/csla:CslaDataProvider&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Then the button controls get declared like
this:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;Button 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Command="ApplicationCommands.Save" 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
CommandTarget="{Binding Source={StaticResource ChildList}, 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Path=CommandManager,
BindsDirectlyToSource=True}"&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
HorizontalAlignment="Left" IsDefault="True"&amp;gt;Save&amp;lt;/Button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;Button 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Command="ApplicationCommands.Undo" 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
CommandTarget="{Binding Source={StaticResource ChildList}, 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Path=CommandManager,
BindsDirectlyToSource=True}"&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
HorizontalAlignment="Left" IsCancel="True"&amp;gt;Cancel&amp;lt;/Button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The result is &lt;i style="mso-bidi-font-style: normal"&gt;very&lt;/i&gt; cool:
a form that can edit an object without the need to write any C# or VB code at all.
Coupled with the CSLA .NET ValidationPanel to display validation results, you can
create a highly interactive data edit form purely with XAML – and of course a CSLA
.NET style business object doing all the work behind the scenes.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;These new capabilities will appear in CSLA
.NET 3.0 Beta 2 - hopefully later this week.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=5d0f03d0-e4a6-45bb-a65b-21e670601258" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,5d0f03d0-e4a6-45bb-a65b-21e670601258.aspx</comments>
      <category>CSLA .NET</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=3103c2bf-6f03-4d62-b933-cf95bc45edfd</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,3103c2bf-6f03-4d62-b933-cf95bc45edfd.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,3103c2bf-6f03-4d62-b933-cf95bc45edfd.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=3103c2bf-6f03-4d62-b933-cf95bc45edfd</wfw:commentRss>
      <title>A couple observations about WPF programming</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,3103c2bf-6f03-4d62-b933-cf95bc45edfd.aspx</guid>
      <link>http://www.lhotka.net/weblog/ACoupleObservationsAboutWPFProgramming.aspx</link>
      <pubDate>Wed, 20 Jun 2007 15:51:35 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;I’ve been spending some quality time with
WPF and Visual Studio 2008 Beta 1 (Orcas) over the past few months. A couple observations
I’ve made:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;Observation
ichi:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Putting code in a Page/Window constructor
is bad. Yes, I know it is the “C# way”, but it is bad. The “VB way” of putting code
in the Loaded event handler is better.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Why?&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Because any exceptions thrown in the constructor
prevent the page/window from loading at all, and you have to catch those exceptions
in the code that is creating the page/window. In many navigation scenarios you can’t
catch them, so the user gets an ugly WPF exception dialog.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;However, if you do all your init work in the
Loaded event handler, the page/window instance already exists. Navigation has already
happened, so the “calling code” is no longer responsible for your page/window going
haywire. Instead, you can actually handle the exception and show a nice dialog, explaining
to the user what happened, and you can (if desired) navigate somewhere else or whatever.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;Observation
ni:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Handing control events with += or AddHandler
is superior to using WithEvents/Handles. Yes, I am a strong advocate of WithEvents/Handles,
and it is one of the major missing features in C#, but for WPF it turns out to be
a negative.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Why?&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Because the Handles clause links the &lt;i style="mso-bidi-font-style: normal"&gt;name
of the control&lt;/i&gt; to the code behind. The AddHandler or += approach, while less attractive
in many ways, &lt;i style="mso-bidi-font-style: normal"&gt;only couples the event name to
the code behind&lt;/i&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;In other words, when using Handles you get
code like:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;Private
Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) _&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Handles Button1.Click&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;While the AddHandler approach results in this
code:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;Private
Sub SaveData(ByVal sender As Object, ByVal e As EventArgs)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The value of the second approach is that &lt;i style="mso-bidi-font-style: normal"&gt;any
control&lt;/i&gt; can route an event to SaveData(). It doesn’t have to be a button, much
less Button1. It actually doesn’t even have to be a Click event. It could be almost
any event.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The result is that the Presentation (XAML)
is less coupled to the UI (VB/C# code) this way than when using Handles.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Unfortunately the Handles approach is more
explicit and thus more readable (which is why C# should really get the Handles feature),
so we’re left trading readability in order to gain loose coupling…&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=3103c2bf-6f03-4d62-b933-cf95bc45edfd" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,3103c2bf-6f03-4d62-b933-cf95bc45edfd.aspx</comments>
      <category>WPF</category>
    </item>
  </channel>
</rss>