<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CAB: Solving The Active View Problem</title>
	<atom:link href="http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/</link>
	<description>Adventures in .NET &#38; Agile Development...</description>
	<lastBuildDate>Mon, 13 Apr 2009 10:13:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: John Zhang</title>
		<link>http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/comment-page-1/#comment-25193</link>
		<dc:creator>John Zhang</dc:creator>
		<pubDate>Mon, 28 Jan 2008 15:56:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/#comment-25193</guid>
		<description>Hi, Chris,

Looks like we have a problem that can be resolved using your approach.

However, we do not understand why following code works 99% of the times, but DID failed once or two.

We have a DeckWorkspace, it will ALWAYS display one of two views.  Then we use following code to determine which view is active (displayed):

private ITemplateView CurrentTemplateView
        {
            get
            {
                if (object.ReferenceEquals(
                    this.LayoutWorkspace.ActiveSmartPart,
                    this._normalViewPresenter.View))
                    return this._normalViewPresenter.View;
                else if (object.ReferenceEquals(
                    this.LayoutWorkspace.ActiveSmartPart,
                    this._designViewPresenter.View))
                    return this._designViewPresenter.View;
                else
                    return null;
            }
        } 

As I said, one of these two views will always displayed in the LayoutWorkspace(A DeckWorkspace), so it should never return null. But for a once or twice, it did. I believe there is an issue in the Workspace.ActiveSmartpart. Could you please clear our mind what is wrong? 

Please help. We will highly appreciate it. Thanks a lot.

John</description>
		<content:encoded><![CDATA[<p>Hi, Chris,</p>
<p>Looks like we have a problem that can be resolved using your approach.</p>
<p>However, we do not understand why following code works 99% of the times, but DID failed once or two.</p>
<p>We have a DeckWorkspace, it will ALWAYS display one of two views.  Then we use following code to determine which view is active (displayed):</p>
<p>private ITemplateView CurrentTemplateView<br />
        {<br />
            get<br />
            {<br />
                if (object.ReferenceEquals(<br />
                    this.LayoutWorkspace.ActiveSmartPart,<br />
                    this._normalViewPresenter.View))<br />
                    return this._normalViewPresenter.View;<br />
                else if (object.ReferenceEquals(<br />
                    this.LayoutWorkspace.ActiveSmartPart,<br />
                    this._designViewPresenter.View))<br />
                    return this._designViewPresenter.View;<br />
                else<br />
                    return null;<br />
            }<br />
        } </p>
<p>As I said, one of these two views will always displayed in the LayoutWorkspace(A DeckWorkspace), so it should never return null. But for a once or twice, it did. I believe there is an issue in the Workspace.ActiveSmartpart. Could you please clear our mind what is wrong? </p>
<p>Please help. We will highly appreciate it. Thanks a lot.</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prasad</title>
		<link>http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/comment-page-1/#comment-24342</link>
		<dc:creator>Prasad</dc:creator>
		<pubDate>Wed, 16 Jan 2008 19:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/#comment-24342</guid>
		<description>Ahmad,
Can you explain by example what you want to say.</description>
		<content:encoded><![CDATA[<p>Ahmad,<br />
Can you explain by example what you want to say.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ahmad El Kerdi</title>
		<link>http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/comment-page-1/#comment-20153</link>
		<dc:creator>Ahmad El Kerdi</dc:creator>
		<pubDate>Sat, 24 Nov 2007 18:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/#comment-20153</guid>
		<description>Hi, I think that I have a simple solution: why you simply does not check if the WorkItem.Status property is Active in the workitem that contains the command handler. I know that in CAB, a workitem is activated automaticly when one of it&#039;s view is activated (has the focus) !!</description>
		<content:encoded><![CDATA[<p>Hi, I think that I have a simple solution: why you simply does not check if the WorkItem.Status property is Active in the workitem that contains the command handler. I know that in CAB, a workitem is activated automaticly when one of it&#8217;s view is activated (has the focus) !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan</title>
		<link>http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/comment-page-1/#comment-12079</link>
		<dc:creator>Nathan</dc:creator>
		<pubDate>Tue, 03 Jul 2007 15:39:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/#comment-12079</guid>
		<description>Wow, thanks for the reply.

I&#039;ll use your argument, but it has not worked in the past :(

Anxiously awaiting your post about the full UIService!</description>
		<content:encoded><![CDATA[<p>Wow, thanks for the reply.</p>
<p>I&#8217;ll use your argument, but it has not worked in the past <img src='http://www.chrisholmesonline.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Anxiously awaiting your post about the full UIService!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/comment-page-1/#comment-11894</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Fri, 29 Jun 2007 22:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/#comment-11894</guid>
		<description>Nathan, 

Modifying CAB was indeed one of the first solutions I looked at after we came up with the idea for the Guid&#039;s to uniquely identify the views. My thought was: lets not have to sprinkle code everywhere to maintain the active view, let&#039;s just modify the Workspaces and have them do it automatically. 

Unfortunately, a few problems arise from the way I chose to go about it, and it was due to my desire to simply augment the Show() method. The biggest problem we ran into is that Maintenance is still required by the developer; the programmer has to know the order of views being displayed when you&#039;re dealing with nested Workspaces (as we have happen with great regularity in our app). It&#039;s not uncommon for us to have a DeckWorkspace view that has a nested DeckWorkspace view on it, and a TabWorkspaces view on that. In order to make sure that the UserControl on a TabWorkspace view is the &quot;active&quot; view when Show() was called, the Deckworkspaces have to be displayed in order from top-down, until the UserControl on the TabWorkspace is the last view activated. Otherwise, suppose the UserControl on the TabWorkspace gets Shown first; then the DeckWorkspace view becomes the &quot;active&quot; view, which isn&#039;t what we really wanted. 

So, there&#039;s some ordering issues that had to happen, and personally I dislike having to manage the &quot;order&quot; of my code in an event-driven environment. I would much rather explicitly call a service and tell it &quot;this view is the active view under these conditions&quot; and not have to worry about all of the other workspace and views and whether they&#039;re being shown in any specific order or not (because to the end user it all looks instantaneous anyway). 

I had not thought, however, about providing a separate method instead of Show() that would be called something like ShowActiveView(). It would have the same signature as the overrides of Show() I imagine, only it would perform the additional task of setting the ActiveView Guid on the UIService (or some other feature more closely integrated with CAB) prior to calling Show() internally.

I like the idea. 

As to the Pros/Cons of modifying CAB: I&#039;ve modified the CAB ever so slightly before for certain things. However, as with all 3rd party applications/frameworks/etc., when you modify something the biggest con is that when the vendor releases a new version, you have to make sure your changes don&#039;t get lost. 

Now, with the announcement of Acropolis the P&amp;P team is not going to be doing much more to CAB, so it&#039;s probably safe to modify it. 

The other thing I&#039;d consider when making the pitch to your project lead: Frameworks like CAB rarely do everything you want exactly the way you want them to be done. The power in owning a framework like CAB, which makes its source and unit tests fully available, is that you *can* modify it to suit your needs.</description>
		<content:encoded><![CDATA[<p>Nathan, </p>
<p>Modifying CAB was indeed one of the first solutions I looked at after we came up with the idea for the Guid&#8217;s to uniquely identify the views. My thought was: lets not have to sprinkle code everywhere to maintain the active view, let&#8217;s just modify the Workspaces and have them do it automatically. </p>
<p>Unfortunately, a few problems arise from the way I chose to go about it, and it was due to my desire to simply augment the Show() method. The biggest problem we ran into is that Maintenance is still required by the developer; the programmer has to know the order of views being displayed when you&#8217;re dealing with nested Workspaces (as we have happen with great regularity in our app). It&#8217;s not uncommon for us to have a DeckWorkspace view that has a nested DeckWorkspace view on it, and a TabWorkspaces view on that. In order to make sure that the UserControl on a TabWorkspace view is the &#8220;active&#8221; view when Show() was called, the Deckworkspaces have to be displayed in order from top-down, until the UserControl on the TabWorkspace is the last view activated. Otherwise, suppose the UserControl on the TabWorkspace gets Shown first; then the DeckWorkspace view becomes the &#8220;active&#8221; view, which isn&#8217;t what we really wanted. </p>
<p>So, there&#8217;s some ordering issues that had to happen, and personally I dislike having to manage the &#8220;order&#8221; of my code in an event-driven environment. I would much rather explicitly call a service and tell it &#8220;this view is the active view under these conditions&#8221; and not have to worry about all of the other workspace and views and whether they&#8217;re being shown in any specific order or not (because to the end user it all looks instantaneous anyway). </p>
<p>I had not thought, however, about providing a separate method instead of Show() that would be called something like ShowActiveView(). It would have the same signature as the overrides of Show() I imagine, only it would perform the additional task of setting the ActiveView Guid on the UIService (or some other feature more closely integrated with CAB) prior to calling Show() internally.</p>
<p>I like the idea. </p>
<p>As to the Pros/Cons of modifying CAB: I&#8217;ve modified the CAB ever so slightly before for certain things. However, as with all 3rd party applications/frameworks/etc., when you modify something the biggest con is that when the vendor releases a new version, you have to make sure your changes don&#8217;t get lost. </p>
<p>Now, with the announcement of Acropolis the P&#038;P team is not going to be doing much more to CAB, so it&#8217;s probably safe to modify it. </p>
<p>The other thing I&#8217;d consider when making the pitch to your project lead: Frameworks like CAB rarely do everything you want exactly the way you want them to be done. The power in owning a framework like CAB, which makes its source and unit tests fully available, is that you *can* modify it to suit your needs.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
