<?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: Modal dialogs with MVVM and Silverlight 4</title>
	<atom:link href="http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/</link>
	<description>and ideas for its refactoring...</description>
	<lastBuildDate>Thu, 26 Jan 2012 18:27:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
	<item>
		<title>By: Hüseyin KÜÇÜK</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-15335</link>
		<dc:creator>Hüseyin KÜÇÜK</dc:creator>
		<pubDate>Thu, 19 Jan 2012 20:01:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-15335</guid>
		<description>great job, thanks</description>
		<content:encoded><![CDATA[<p>great job, thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: m00</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-9408</link>
		<dc:creator>m00</dc:creator>
		<pubDate>Mon, 15 Aug 2011 11:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-9408</guid>
		<description>Simon and Jordan: I found a funny hacky way of removing the event handlers in the view and have them in the ViewModel, here you go ;)

public ICommand CloseCommand
{
    get 
    { 
        return new DelegateCommand(
            sender =&gt; Application.Current.Windows.OfType().First().Close());
    }
}

Enjoy</description>
		<content:encoded><![CDATA[<p>Simon and Jordan: I found a funny hacky way of removing the event handlers in the view and have them in the ViewModel, here you go <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>public ICommand CloseCommand<br />
{<br />
    get<br />
    {<br />
        return new DelegateCommand(<br />
            sender =&gt; Application.Current.Windows.OfType().First().Close());<br />
    }<br />
}</p>
<p>Enjoy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Montoya</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-8110</link>
		<dc:creator>John Montoya</dc:creator>
		<pubDate>Wed, 29 Jun 2011 15:42:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-8110</guid>
		<description>Hi,

I love your Modal dialog sample.  I would love to see a WPF version of this code.  Can you create one for us?

Regards,

John</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I love your Modal dialog sample.  I would love to see a WPF version of this code.  Can you create one for us?</p>
<p>Regards,</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Axente Adrian</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-7940</link>
		<dc:creator>Axente Adrian</dc:creator>
		<pubDate>Mon, 20 Jun 2011 01:38:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-7940</guid>
		<description>I think wiring up interface from the view model is so WRONG.
Please read dicussion from 
http://compositewpf.codeplex.com/discussions/69088</description>
		<content:encoded><![CDATA[<p>I think wiring up interface from the view model is so WRONG.<br />
Please read dicussion from<br />
<a href="http://compositewpf.codeplex.com/discussions/69088" rel="nofollow">http://compositewpf.codeplex.com/discussions/69088</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ubuntu</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-7240</link>
		<dc:creator>Ubuntu</dc:creator>
		<pubDate>Tue, 10 May 2011 17:43:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-7240</guid>
		<description>Hello Frosty,
Where can I find the fix to the MEF solution for the close event issue.

Best.</description>
		<content:encoded><![CDATA[<p>Hello Frosty,<br />
Where can I find the fix to the MEF solution for the close event issue.</p>
<p>Best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhawal Parkar</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-7239</link>
		<dc:creator>Dhawal Parkar</dc:creator>
		<pubDate>Tue, 10 May 2011 14:36:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-7239</guid>
		<description>How do you validate the values ? With the red box surrounding the ones which are invalid. Something like which is mentioned here :
http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validatesondataerrors.aspx</description>
		<content:encoded><![CDATA[<p>How do you validate the values ? With the red box surrounding the ones which are invalid. Something like which is mentioned here :<br />
<a href="http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validatesondataerrors.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validatesondataerrors.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ubuntu</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-7226</link>
		<dc:creator>Ubuntu</dc:creator>
		<pubDate>Sun, 08 May 2011 22:21:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-7226</guid>
		<description>Hello frosty,
Can  you tell me how to fix the close event, as I have it fired as much as the window open (using MEF).

Kind regards</description>
		<content:encoded><![CDATA[<p>Hello frosty,<br />
Can  you tell me how to fix the close event, as I have it fired as much as the window open (using MEF).</p>
<p>Kind regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roboblob</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-6287</link>
		<dc:creator>roboblob</dc:creator>
		<pubDate>Wed, 09 Mar 2011 16:53:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-6287</guid>
		<description>Hi Jordan,
one way of solving this would be to have ViewModel of the Dialog to have reference to its View via the interface IModalWindow (just add to the ViewModel interface View property of type IModalWindow).
You could then assign the value of that View property in ModalDialogService when you bind View and ViewModel:

view.DataContext = viewModel;
viewModel.View = view;

After that, in your ViewModel when you need to close the Dialog just call view.Close(); 
Close method is already part of the IModalWindow interface that ChildWindow implicitly implements so no need to implement it explicitly in each dialog.

Let me know if this helps and thanks for your feedback!</description>
		<content:encoded><![CDATA[<p>Hi Jordan,<br />
one way of solving this would be to have ViewModel of the Dialog to have reference to its View via the interface IModalWindow (just add to the ViewModel interface View property of type IModalWindow).<br />
You could then assign the value of that View property in ModalDialogService when you bind View and ViewModel:</p>
<p>view.DataContext = viewModel;<br />
viewModel.View = view;</p>
<p>After that, in your ViewModel when you need to close the Dialog just call view.Close();<br />
Close method is already part of the IModalWindow interface that ChildWindow implicitly implements so no need to implement it explicitly in each dialog.</p>
<p>Let me know if this helps and thanks for your feedback!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordan</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-6283</link>
		<dc:creator>Jordan</dc:creator>
		<pubDate>Wed, 09 Mar 2011 16:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-6283</guid>
		<description>Hi Rob, excellent example - really helped me out.  I&#039;m in a similar position with Simon (above).  I&#039;m not a purist or anything and believe that code-behind is ok if it gets the job done.  However I&#039;m trying to find a way to close a modal window from the modal window&#039;s view model.  

The case example for this is the modal window has a datagrid of search results, when the user double-clicks a result I fire a message on the event aggregator for some other section of code to pick up and then need to close the dialog.</description>
		<content:encoded><![CDATA[<p>Hi Rob, excellent example &#8211; really helped me out.  I&#8217;m in a similar position with Simon (above).  I&#8217;m not a purist or anything and believe that code-behind is ok if it gets the job done.  However I&#8217;m trying to find a way to close a modal window from the modal window&#8217;s view model.  </p>
<p>The case example for this is the modal window has a datagrid of search results, when the user double-clicks a result I fire a message on the event aggregator for some other section of code to pick up and then need to close the dialog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://blog.roboblob.com/2010/01/19/modal-dialogs-with-mvvm-and-silverlight-4/comment-page-1/#comment-5763</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Wed, 23 Feb 2011 19:54:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.roboblob.com/?p=109#comment-5763</guid>
		<description>Thanks for the reply Rob and I fully understand your approach and so far it is the nicest I&#039;ve used IMO. Other approaches of decoupling modal windows I&#039;ve resorted to in the past are far more heavyweight e.g. using the mediator pattern and passing ShowDialog messages or using Prism&#039;s event aggregator.

For the simple task of showing a modal dialog this is the simplest and cleanest, whilst still remaining testable.

I was wondering from a purist sense, if it is possible to completely remove all code-behind from the View including the OK and Cancel button click event handlers. Even with the Close ICommand, the view must be told to close. The VM has no reference to the view apart from indirectly through bindings.
In order to close the view, one needs to set the DialogResult property to something.
So I guess to achieve this one would need to somehow create a binding from a property in the VM to the view&#039;s DialogResult property. Unfortunately DialogResult is not a dependency property so I don&#039;t think it&#039;s actually possible.</description>
		<content:encoded><![CDATA[<p>Thanks for the reply Rob and I fully understand your approach and so far it is the nicest I&#8217;ve used IMO. Other approaches of decoupling modal windows I&#8217;ve resorted to in the past are far more heavyweight e.g. using the mediator pattern and passing ShowDialog messages or using Prism&#8217;s event aggregator.</p>
<p>For the simple task of showing a modal dialog this is the simplest and cleanest, whilst still remaining testable.</p>
<p>I was wondering from a purist sense, if it is possible to completely remove all code-behind from the View including the OK and Cancel button click event handlers. Even with the Close ICommand, the view must be told to close. The VM has no reference to the view apart from indirectly through bindings.<br />
In order to close the view, one needs to set the DialogResult property to something.<br />
So I guess to achieve this one would need to somehow create a binding from a property in the VM to the view&#8217;s DialogResult property. Unfortunately DialogResult is not a dependency property so I don&#8217;t think it&#8217;s actually possible.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

