<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Derik Whittaker : Silverlight</title><link>http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx</link><description>Tags: Silverlight</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Missing Silverlight Resources and ASP.Net security</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2012/01/25/missing-silverlight-resources-and-asp-net-security.aspx</link><pubDate>Wed, 25 Jan 2012 08:58:13 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:69361</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=69361</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=69361</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2012/01/25/missing-silverlight-resources-and-asp-net-security.aspx#comments</comments><description>&lt;p&gt;Have you ever had an error crop up when debugging an application which has made you simply want to pull each hair out of your head one by one with a pair of tweezers because that would be less painful than debugging the error? Today I had just this happen to me.&lt;/p&gt;  &lt;p&gt;Today when I hit F5 to launch our Silverlight application I received the following exception : &lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_111C75D1.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_7E677C19.png" width="364" height="242" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The body of this error message is &lt;/p&gt;  &lt;p&gt;Line: 56    &lt;br /&gt;Error: Unhandled Error in Silverlight Application     &lt;br /&gt;Code: 2108&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Category: InitializeError&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Message: Failed to download the splash screen&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Of course since I have the debugger I was going to attach to it, but sadly that was NO HELP.&amp;#160; When reading error you notice it says that it failed to download the splash screen. This is really odd because when looking in the source it is there…&amp;#160; In an effort to ‘remove the problem’ I removed the line of code from our ASPX page which setup the splash screen as a resource, the line below. &lt;/p&gt;  &lt;p&gt;&amp;lt;param name=&amp;#39;splashscreensource&amp;#39; value=&amp;#39;SplashScreen.xaml&amp;#39; /&amp;gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Thinking that this would solve my issue, at least for now, I hit F5 again.&amp;#160; Things were different this time, but sadly not for the better.&amp;#160; Now in place of getting the error message I simply got the default ‘blue dots’ from silverlight indicating that the xap was trying to load.&amp;#160; This was really odd.&amp;#160; I did what any developer would do, I hit F5 3-4 more times thinking that the problem would just magically go away, hey it does happen, but as you can guess it did not go away.&lt;/p&gt;  &lt;p&gt;Because I had been making a bit of changes in the code and it was possible that I could have accidently really FUBARED my code base I shelved my code, blew away my ENTIRE branch and did a fresh pull.&amp;#160; Yea, that did not either.&lt;/p&gt;  &lt;p&gt;So my on branch was dead, but my co-worker who is in the same branch was able to launch and run the app just fine.&amp;#160; In another effort to see if it was my branch code or my machine I decided to pull down the trunk (the parent of this particular branch) to see if I had the issue there… Yea no, that code worked just fine.&lt;/p&gt;  &lt;p&gt;Because I knew it was not my machine it had to be code.&amp;#160; I decided to start diffing the files I thought were causing the issues such as our default.aspx page, our login page along with a few other files.&amp;#160; As you may have guessed NONE of these files were different.&lt;/p&gt;  &lt;p&gt;Because I had been beating my head against this for greater than an hour I decided that I should move on to something else and come back to this later (I guess I was still holding out for the code fairy to magically fix my stuff while I was away).&lt;/p&gt;  &lt;p&gt;Well later came and I had to go back to my branch to fix a production issue and this issue was still there.&amp;#160; This time however things were a bit different, no the code fairy did not do her magic, my co-worker said ‘hey I got that a few minutes ago’.&amp;#160; I was both elated and pissed at the same time.&amp;#160; I was elated because maybe NOW I could solve my issue.&amp;#160; I was pissed because this was the same co-worker I had talked to about this issue a few hours back and NOW they knew how to solve the issue.&lt;/p&gt;  &lt;p&gt;So what was the issue?&amp;#160; My co-worker was playing around with some security settings in our web.config file and had accidently committed is changes.&amp;#160; It was these changes that was causing my issue.&amp;#160; What did he change?&amp;#160; He did 2 things&lt;/p&gt;  &lt;p&gt;1) He setup a deny ALL authorization rule    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_28677A42.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;float:left;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" align="left" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_7603A6C2.png" width="218" height="71" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;2) He setup other rules to only allow a few pages to be open as such    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_759773CD.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_0E27111E.png" width="228" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The 2nd change was not a huge issue, it was the 1st one that was killing me.&amp;#160; Because he had turned off anon access to the site my xap could not load and because my xap could not load the splash screen could not be presented to the user and for what ever reason Silverlight decided that in place of providing a meaningful message it would simply say it could not find my splash screen resource.&lt;/p&gt;  &lt;p&gt;Since I knew the issue I was able to change my rule from deny to allow (in #1) and re-run the application…. finally I could fix bugs I created &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/wlEmoticon_2D00_smile_5F00_7452DAEE.png" /&gt;&lt;/p&gt;  &lt;p&gt;The moral of the story here is that if you get an error saying you cannot access a resource in your xap file double check that IIS has access to the xap because if it does not you may get this issue.&lt;/p&gt;  &lt;p&gt;The other moral of the story is that it should be 100% legal to cane a co-worker who commits a change that breaks you and does not even realize it. Ok caning may be harsh, at least they should buy you a beer.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=69361" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>How to Show a deleted List Item with a Strike Through in XAML</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2012/01/08/how-to-show-a-deleted-list-item-with-a-strike-through-in-xaml.aspx</link><pubDate>Sun, 08 Jan 2012 13:12:44 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:69142</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=69142</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=69142</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2012/01/08/how-to-show-a-deleted-list-item-with-a-strike-through-in-xaml.aspx#comments</comments><description>&lt;p&gt;When building applications it is very common to have a set of screens which are basically list/edit screens.&amp;#160; And when having these list/edit screens it is also common to allow users to delete a row.&amp;#160; In this post I am going to show how you can add a neat little UI wrinkle to your deleting action which will be visually appealing but will also allow users to undo their changes with ease.&lt;/p&gt;  &lt;p&gt;If you take a look at the screen shot below you will notice that I have a data grid with 2 line items.&amp;#160; You should also notice that at the far right of each row is a ‘Red X’ which can be used to delete that selected row.&amp;#160; Commonly when you have this type of delete action the row will be removed from the UI in real time.&amp;#160; Having the row removed in real time is ok but it does give the user an easy way to undo their actions prior to committing their changes.&amp;#160; What I would like to do is change this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_011817A3.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_39568EBB.png" width="704" height="68" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In the screen shot below you can see how we have accomplished the ability to mark a row as being deleted yet still give the user the ability to undo a given deletion.&amp;#160; What we have done is 2 things.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;In place of actually removing the row from the grid we implemented the strike through to show the user that row will be removed when the save their changes. &lt;/li&gt;    &lt;li&gt;We removed the delete icon and replaced it with the add icon &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_2DC0D17C.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_4D03784F.png" width="704" height="68" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Since we know what we want to accomplish how do we actually do it.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Setting up your model to have Deleted bool property        &lt;br /&gt;&lt;/strong&gt;In order for this whole thing to work you will need to have some sort of bool property on your underlying model which stored the Deleted state of a given row.       &lt;br /&gt;      &lt;br /&gt;      &lt;pre class="c#" name="code"&gt;	private bool _deleted;
        public bool Deleted
        {
            get
            {
                return _deleted;
            }
            set
            {
                _deleted = value;

                OnPropertyChanged(() =&amp;gt; Deleted);
            }
        }&lt;br /&gt;&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Setting up your XAML to have the strike through &lt;/strong&gt;

    &lt;br /&gt;In my XAML we are using the stock DataGrid for Silverlight and we are templating each column in the grid.&amp;#160; For the columns which we want to implement the strike though we need to add some xaml which will only be visible WHEN Deleted flag of the given row is true.&amp;#160; Here is snapshot of our XAML 

    &lt;br /&gt;

    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_73655B9A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_44337003.png" width="704" height="89" /&gt;&lt;/a&gt; 

    &lt;br /&gt;

    &lt;br /&gt;Things to pay attention to in the above XAML are 

    &lt;br /&gt;1) We have both a TextBlock and a Rectangle element in our cell, however the Rectangle’s visibility is being set based on the Deleted flag.&amp;#160; To set this visibility we are using a BooleanToVisiblity converter (will put that code at the end of this post) 

    &lt;br /&gt;2) In the above case the margin on the Rectangle is Margin=”4,0,0,0” and this is because it is far left column in our grid and we don’t want the line to butt up against the edge.&amp;#160; In the middle columns we don’t want a margin in order to appear to be a complete line.&amp;#160; However in our far right column we want to setup the margin as Margin=”0,0,4,0” in order to not butt up against the right hand edge. 

    &lt;br /&gt;

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Setting up your XAML to swap action buttons based on the deleted state 
      &lt;br /&gt;&lt;/strong&gt;To enable the swapping of our buttons based on the Deleted flag we basically will do the same as above w/ the strike through lines but in place of the visibility being swapped on a Rectangle we will do it on a Button element. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;BoolenToVisibilityConverter Code&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;	public class BooleanToVisibilityConverter : IValueConverter
	{
        public Visibility TrueValue { get; set; }
        public Visibility FalseValue { get; set; }

        public BooleanToVisibilityConverter()
        {
            TrueValue = Visibility.Visible;
            FalseValue = Visibility.Collapsed;
        }

		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
            if (value == null)
            {
                return Visibility.Collapsed;
            }

			return ((bool) value) ? TrueValue : FalseValue;
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException();
		}
	}&lt;/pre&gt;

&lt;p&gt;As you can see you can implement a slick UI which shows the user an item has been deleted with very little effort.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=69142" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Building Async WCF Services in Silverlight with Channelfactory</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/12/17/building-async-wcf-services-in-silverlight-with-channelfactory.aspx</link><pubDate>Sat, 17 Dec 2011 18:23:04 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68849</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68849</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68849</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/12/17/building-async-wcf-services-in-silverlight-with-channelfactory.aspx#comments</comments><description>&lt;p&gt;If you have created any silverlight applications which need to communicate to a WCF Endpoint you know that you must communicate with WCF via Async actions.&amp;#160; As you may know there are multiple ways to get your Silverlight application to communicate with a WCF service.&amp;#160; One way is to simply create a Service Reference, aka proxy.&amp;#160; The other is to use the ChannelFactory and a shared interface. There are many good references on the net on why one is better than the other but personally I prefer to use the ChannelFactory approach as it allows for cleaner separation of concerns and it allows me to share the same interfaces/models on both side of the wire.&amp;#160; Of course this really only works in a closed development scenario, one where you control both sides of the wire.&lt;/p&gt;  &lt;p&gt;The issue with using the Channelfactory pattern is that by default it will create synchronous endpoints for use and this is not allowed in Silverlight.&amp;#160; However this problem is easily solved for you and we will take a look at how to solve this.&lt;/p&gt;  &lt;p&gt;When you typically setup a WCF &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.aspx"&gt;OperationContract&lt;/a&gt; you typically do something like the following:&lt;/p&gt;  &lt;pre&gt;[OperationContract]&lt;br /&gt;List&amp;lt;Make&amp;gt; GetMakes();&lt;/pre&gt;

&lt;p&gt;However as you may have guessed this will create a synchronous method/endpoint when you use the ChanelFactory.&amp;#160; In order to use this in WCF you need to make a slight change to your setup.&amp;#160; You will need to instruct the Contract that you are following the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.asyncpattern.aspx"&gt;AsyncPattern&lt;/a&gt; .&amp;#160; The code below will show you how using the AsyncPattern changes your setup.&lt;/p&gt;

&lt;pre&gt;[OperationContract(AsyncPattern = true)]
IAsyncResult BeginGetMakes(AsyncCallback callback, object state);
IList&amp;lt;Make&amp;gt; EndGetMakes(IAsyncResult result);&lt;/pre&gt;

&lt;p&gt;As you can see from above, using the AsyncPattern = true pattern does mean we need to create 2 methods not just 1.&amp;#160; We should take a closer look at these to better understand what is going one.&lt;/p&gt;

&lt;p&gt;In the first method we are creating the ‘begin’ call which will return us back a &lt;a href="http://msdn.microsoft.com/en-us/library/system.iasyncresult.aspx"&gt;IAsyncResult&lt;/a&gt; which will later be provided to the End method. 

  &lt;br /&gt;In the second method we are making a call and passing in the IAsyncResult instance provided to us via the begin call.&amp;#160; It is this second method which will return us back our actual data.&lt;/p&gt;

&lt;p&gt;Now that we know how to&amp;#160; create our OperationContract we should take a look at how to create our implementation of these contracts.&amp;#160; The code below will illustrate how to do this&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;public IAsyncResult BeginGetMakes( AsyncCallback callback, object state )
{
    var db = new AutomobilesEntities();

    var makes = db.Makes.Select( m =&amp;gt; new Make {Name = m.Name} ).ToList();

    return new CompletedAsyncResult&amp;gt;(makes);
}

public IList EndGetMakes( IAsyncResult result )
{
    var completedAsyncResult = result as CompletedAsyncResult&amp;gt;;

    return completedAsyncResult != null ? completedAsyncResult.Data : new List();
}&lt;/pre&gt;

&lt;p&gt;Taking a closer look above you should notice that the Begin method will actually do the ‘heavy’ lifting in terms of performing any real logic.&amp;#160;&amp;#160; This method also returns back a AsyncResult class (see below for that class) which will be passed into the ending call The End call.&amp;#160; The End call will accept the provided AsyncResult instance and pull out the data payload inside of it.&amp;#160; It will then pass this payload back as the actual results you were expecting.&lt;/p&gt;

&lt;p&gt;Now that we know how to create an Async endpoint how to we spin up an endpoint via the ChannelFactory and make our WCF call work.&amp;#160; Take a look at the code below for that example.&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;var binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
                              {
                                  MaxBufferSize = 2147483647,
                                  MaxReceivedMessageSize = 2147483647
                              };
            
var endpointAddress = new EndpointAddress(fullEndpointAddress);
var channelFactory = new ChannelFactory(binding, endpointAddress);

var channel = channelFactory.CreateChannel();

AsyncCallback callback = result =&amp;gt;
                                {
                                    var endGetMakes = channel.EndGetMakes(result);

                                    Debug.WriteLine( &amp;quot;I Have Makes&amp;quot; );
                                };

channel.BeginGetMakes(callback, channel);&lt;/pre&gt;

&lt;p&gt;The magic in the code above which makes this all work is to create the pointer to the AsyncCallback instance and to provide this in your Begin call.&lt;/p&gt;

&lt;p&gt;This is the class I used for encapsulating our IAsyncResult&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;public class CompletedAsyncResult : IAsyncResult
{
    T data;

    public CompletedAsyncResult(T data)
    { this.data = data; }

    public T Data
    { get { return data; } }

    #region IAsyncResult Members

    public object AsyncState
    { get { return (object)data; } }

    public WaitHandle AsyncWaitHandle
    { get { throw new Exception(&amp;quot;The method or operation is not implemented.&amp;quot;); } }

    public bool CompletedSynchronously
    { get { return true; } }

    public bool IsCompleted
    { get { return true; } }
    #endregion
}&lt;/pre&gt;

&lt;p&gt;Using the Async Pattern in WCF is a bit more work but it will allow you to do 2 things. 1) Use the Channelfactory in WCF and 2) Create async service calls to allow your application to continue working while you wait for your call to come back.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68849" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WCF/default.aspx">WCF</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Runtime Exception for PageIndex of a DataPager</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/11/29/runtime-exception-for-pageindex-of-a-datapage.aspx</link><pubDate>Tue, 29 Nov 2011 15:25:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68439</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68439</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68439</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/11/29/runtime-exception-for-pageindex-of-a-datapage.aspx#comments</comments><description>&lt;p&gt;Today I was building a UI in Silverlight which needed a Data Grid and a Data Pager.&amp;#160; When I setup my pager I had it bound to the various properties that I cared about (Source, PageIndex, PageSize, etc) via my ViewModel.&amp;#160; However when I ran the page for the first time I received the error below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_3ACA1083.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2F345344.png" width="364" height="178" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;At first I was a bit stumped because why in the world would I want to set my Page Index to –1 (as an FYI my Source property is NULL when first bound because of the way we lazy fetch our data.&amp;#160; In order to get around this I did what the error told me and set my Page Index to default to –1. This worked… kinda.&amp;#160; See it worked the first time I loaded the screen when there was NO data loaded in memory.&amp;#160; Every subsequent loading of the page threw another exception telling me that my default Page Index had to be &amp;gt;= 0.&lt;/p&gt;  &lt;p&gt;As I sat there scratching my head it dawned on me that the issue was due to the way that the XAML engine reads/parses the elements (left to right, top to bottom).&amp;#160; I reset my default Page Index to 0 and moved my Source property to the left of my PageIndex property and this worked.&amp;#160; Take a look below at my XAML to see the difference.&lt;/p&gt;  &lt;p&gt;Original XAML&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_32D26E21.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_196A6AE7.png" width="644" height="63" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Correct XAML&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_0DD4ADA8.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_5F7B27FA.png" width="644" height="76" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The moral of the story is that you need to pay attention to the order (left to right/top to bottom) of your XAML properties in some places.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68439" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Using MVVM with the AutoCompleteTextBox in Silverlight 4</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/11/18/using-mvvm-with-the-autocompletetextbox-in-silverlight-4.aspx</link><pubDate>Fri, 18 Nov 2011 22:25:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68404</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68404</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68404</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/11/18/using-mvvm-with-the-autocompletetextbox-in-silverlight-4.aspx#comments</comments><description>&lt;p&gt;The AutoCompleteTextBox is a great tool in Silverlight to allow you to provide relevant information to your users as they are typing as seen below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_4B1A6A5F.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_4AAE376A.png" height="165" width="364" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But there are a few issues with this control&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Pretty much every sample on the net uses the code behind to do the heavy lifting and not binding &lt;/li&gt;
&lt;li&gt;It will not update the VM text box in real time, which is needed if you want to do on the fly filtering &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this post I will walk you though how to setup your AutoCompleteText&amp;nbsp; box and we will learn how to do 3 things&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use MVVM to populate and use the control &lt;/li&gt;
&lt;li&gt;Use a custom Behavior to allow the property backing the control to be updated in real time &lt;/li&gt;
&lt;li&gt;Use a command to trigger background searches on the fly &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;b&gt;Using MVVM to populate your control:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;In order to populate your AutoCompleteTextBox you will need to bind something to the ItemSource property of the control as such:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;ItemsSource=&amp;quot;{Binding KeywordSearchSource}&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;I am sure you are wondering what the KeywordSearchSource is?&amp;nbsp; Well it is simple a property which returns a IEnumerable&amp;lt;string&amp;gt;&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;       public IEnumerable KeywordSearchSource
        {
            get
            {
                return SomeListOfValues.Select( x =&amp;gt; x.TextValue );
            }
        }&lt;/pre&gt;
&lt;p&gt;The next thing you will want to do is setup a property in your view to handle the current value inside the control.&amp;nbsp; This is needed because we are binding and not using the code behind.&amp;nbsp; You can do this as below:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Text=&amp;quot;{Binding KeywordSearchText, Mode=TwoWay}&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The trick to above is to remember to mark this as being TwoWay or you will not get the results you are expecting&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;        private string _keywordSearchText;
        public string KeywordSearchText
        {
            get { return _keywordSearchText; }
            set 
            {
                _keywordSearchText = value; 

                NotifyOfPropertyChange(() =&amp;gt; KeywordSearchText); 
            }
        }&lt;/pre&gt;
&lt;p&gt;That does it for the MVVM portion of the setup.&amp;nbsp; However, you may already know that when binding to a text box the actual binding does not trigger until AFTER the user leaves the control, in many cases this is good but not in our case.&amp;nbsp; In our case I want to start the filter process as the user types (which is fine as I have all the filter data local, this is NOT fine if I have to do any type of remote call to filter the data as this will cause a bad user experience).&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Triggering the binding in real time:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;As I stated above the binding of a text box (or autocomplete text box) does not fire until you leave the control and this is not the desired action for us.&amp;nbsp; In order to get around this we are going to create a custom behavior to allow the text box binding to push the value into our property in real time.&lt;/p&gt;
&lt;p&gt;Our custom behavior is going to be called the ImmediateUpdateBehavior and the code can be found below.&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;    public class ImmediateUpdateBehavior : Behavior
    {
        protected override void OnAttached()
        {
            AssociatedObject.TextChanged += OnTextChanged;
        }

        void OnTextChanged(object sender, RoutedEventArgs e)
        {
            AssociatedObject.GetBindingExpression(AutoCompleteBox.TextProperty).UpdateSource();
        }

        protected override void OnDetaching()
        {
            AssociatedObject.TextChanged -= OnTextChanged;
        }
    }&lt;/pre&gt;
&lt;p&gt;In the behavior above you can see that all we are pretty much doing is listing for the TextChanged event and forcing the binding to fire.&amp;nbsp; This is a nice way to do it when developing with MVVM.&lt;/p&gt;
&lt;p&gt;Once we have our behavior created we need to attach it to our AutoCompleteTextBox and that can be found below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_2307BB40.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_7BCD720A.png" height="73" width="324" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Triggering the filtering to fire as we type:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;I am going to chose to do this via a Command.&amp;nbsp; I guess you could have the changing value of the property do the same thing but I typically am against doing this as I feel it is hiding the implementation details of the filtering.&amp;nbsp; I also feel that this can cause unwanted side effects in your code if you are not careful.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;In order to use the command I am going to use the EventTrigger behavior in silverlight to call my command.&amp;nbsp; You can see this XAML below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_09338511.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_28E25ED9.png" height="98" width="644" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the XAML above you see I am calling the KeywordSearchFilterCommand.&amp;nbsp; This command will end up calling the code below&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;        private void KeywordSearchFilter()
        {
	    // Key here is i am simply notifying to rebuind these values and allowing the underlying methods to filter the data
            NotifyOfPropertyChange(() =&amp;gt; SomeListOfValues);
            NotifyOfPropertyChange(() =&amp;gt; PagedSomeListOfValues);
        }&lt;/pre&gt;
&lt;p&gt;As you can see from the above I am not doing anything special in the filter method I am simply notifying of property change and letting the various properties doing their own filtering.&amp;nbsp; The code below is the filtering for my PagedSomeListOfValues property (we are doing client side paging here)&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;        public ObservableCollection PagedSomeListOfValues
        {
            get
            {
                var skipCount = PageIndex &amp;gt; 0 ? PageIndex * PageSize : 0;
                var takeCount = PageSize;
                var tempItems= SomeListOfValues.Skip(skipCount).Take(takeCount).ToList();

                var observableLinks = new ObservableCollection();
                observableLinks.SetContents(tempItems);

                return observableLinks;
            }
        }&lt;/pre&gt;
&lt;p&gt;Once you have your 2 properties (list and search field) bound to the AutoCompleteTextBox you are almost there, but not quite.&amp;nbsp; In order to make this fully work you will want to also you the custom behavior and the filter command.&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68404" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight Code 2104 – Could not download the silverlight app error</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/10/10/silverlight-code-2104-could-not-download-the-silverlight-app-error.aspx</link><pubDate>Mon, 10 Oct 2011 13:26:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68274</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68274</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68274</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/10/10/silverlight-code-2104-could-not-download-the-silverlight-app-error.aspx#comments</comments><description>&lt;p&gt;Today after pulling latest from our TFS server, and doing a few auto merges (turns out that the AutoMerge is at fault here again)(some day I will learn NOT to trust TFS to do anything, but doubt it) I tried to fire up our Silverlight Browser app and I was presented with this lovely error.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/clip_5F00_image002_5F00_74067789.jpg"&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="clip_image002" alt="clip_image002" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/clip_5F00_image002_5F00_thumb_5F00_531304E2.jpg" border="0" height="296" width="446" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I was a bit stumped by this and did some google searches and everything wanted me to check my IIS settings.&amp;nbsp; I was pretty sure this could not be the cause because this was all local dev and we have not made any changes.&amp;nbsp; After digging around in my change log I noticed that during a merge our .xap file was renamed (this was with intent).&amp;nbsp; However, the server project did not pick up this rename change (technically there were 2 .xap entries in my proj file which did not help either).&amp;nbsp; So when server was trying to serve up the newly named .xap file it was not found, hence the error &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/wlEmoticon_2D00_smile_5F00_244D4C40.png" /&gt;&lt;/p&gt;
&lt;p&gt;There are 2 possible solutions to this problem (assuming it is non-IIS)&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Make sure that the .xap file being served up by your server components is in fact the CORRECT .xap file your client wants.&amp;nbsp; I actually had to open the .proj file directly for the server to make the changes as the IDE will only show one .xap file I wanted.&lt;/li&gt;
&lt;li&gt;Make sure that your Default.aspx (or what ever page servers ur silverlight .xap file) has the correct file name in the source folder&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68274" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Getting around the Caching in the Silverlight Image Control</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/09/23/getting-around-the-caching-in-the-silverlight-image-control.aspx</link><pubDate>Fri, 23 Sep 2011 17:24:42 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68197</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68197</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68197</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/09/23/getting-around-the-caching-in-the-silverlight-image-control.aspx#comments</comments><description>&lt;p&gt;Today I ran into a very odd issue when trying to reload the Silverlight Image Control with a new image which happened to have the EXACT same URL as the previously loaded image.&lt;/p&gt;  &lt;p&gt;See in our application we provide a way to upload an image and also allow the user to not simply create a new image but rather swap out an existing image with a new one but leave the URL the exact same.&amp;#160; During my development I really did not pay attention to or care that when I swapped out the image instance and raised the property changed event that the actual image was changing from the old to the new.&lt;/p&gt;  &lt;p&gt;When I noticed that this was not working as expected I assumed that I could kill the instance of the object which was being bound to the &amp;lt;Image /&amp;gt; control in Silverlight and reset it w/ the new instance and that would trigger the reloading of the image via its url, however as you may have guessed this did not work.&amp;#160; I had setup the binding to the control as follows:&lt;/p&gt;  &lt;p&gt;Source=&amp;quot;{Binding CurrentImage.SourceUrl}&lt;/p&gt;  &lt;p&gt;I liked the binding code above (loading via URL rather than binary data) because I could easily hook into the loaded/failed events of the control in order to indicate to the user that there was something wrong with the image they are using.&lt;/p&gt;  &lt;p&gt;It turns out (based on observations and Fiddler traces) that the Silverlight Image control will cache the current image and will NOT refresh/reload the image if the URL does not change.&amp;#160; I guess the assumption is that if the same URL is provided multiple times don’t to waste cycles reloading it to only show the same image which is in memory. &lt;/p&gt;  &lt;p&gt;This behavior works great in most cases…well until you don’t want it to work like this.&amp;#160; I thought of a few ways to get around this issue, such as binding to a BitmapImage or binding to a byte[] array.&amp;#160; However I really wanted to reduce the amount of rework or modifications I needed to make to the existing VM.&amp;#160; &lt;/p&gt;  &lt;p&gt;The solution we found that solved the issue was to bind to a image source url in the VM directly (did not want to dirty the existing SourceUrl Property as others user it and this work around is PURELY as UI issue, not a domain one) to a Url property in the VM and append an arbitrary query string value to the end of the URL.&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;       public string CurrentImageSourceUrl
        {
            get
            {
                if (CurrentImage != null)
                {
                    return string.Format(&amp;quot;{0}?id={1}&amp;quot;, CurrentImage.SourceUrl, Guid.NewGuid().ToString());
                }

                return string.Empty;
            }
        }&lt;/pre&gt;

&lt;p&gt;When I added the querystring value as above I was able to leave my existing VM logic alone and have the Image control reload the image correctly because it assumed that since my URL has changed that the images are different. I know this is a bit of a hack but hey it worked &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/wlEmoticon_2D00_smile_5F00_7B2663D7.png" /&gt; .&amp;#160; If anyone knows of a better way to solve this please let me know.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68197" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Unit Testing Silverlight from MSTest–Forcing VS to use the right Silverlight Assemblies</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/08/26/unit-testing-silverlight-from-mstest.aspx</link><pubDate>Fri, 26 Aug 2011 13:13:14 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68139</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68139</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68139</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/08/26/unit-testing-silverlight-from-mstest.aspx#comments</comments><description>&lt;p&gt;Ok, silverlight and unit testing just plan sucks, I firmly believe that the devs for silverlight did NOT care about testability, but that is off topic.&amp;#160; When doing any type of unit testing (and not with the built in silverlight testing framework which actually runs the app, talking code level testing) you will quickly run into an issue of version mis-match.&lt;/p&gt;  &lt;p&gt;The issue with the version mis-match is that VS wants to push the 4.0 version of your assemblies, even when you add direct reference to the 2.0.5 version (silverlight version).&amp;#160; When this happens your tests will fail with an error telling you that your assemblies are not the right version.&amp;#160; And if you are like me you will try over and over to ‘force’ vs to reference the right version and it will fail.&amp;#160; The good news is that there IS a way around this, but it is a bit of a hack&lt;/p&gt;  &lt;p&gt;How to get around this issue (at least one way)&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Move copies of your desired Silverlight .dlls into a local library folder. I have the following in my folder      &lt;ol&gt;       &lt;li&gt;System.ComponentModel.DataAnnotations.dll &lt;/li&gt;        &lt;li&gt;System.Net.dll &lt;/li&gt;        &lt;li&gt;System.Runtime.Serialization.dll &lt;/li&gt;        &lt;li&gt;System.ServiceModel.dll &lt;/li&gt;        &lt;li&gt;System.ServiceModel.DomainServices.Client.dll &lt;/li&gt;        &lt;li&gt;System.Windows.dll &lt;/li&gt;        &lt;li&gt;System.Xml.dll &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Open up your unit tests .proj file in notepad or any text editor &lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;Find the &amp;lt;Reference&amp;gt; entry to the correct silverlight dll you want and create a hint path which points to your LOCAL dll        &lt;br /&gt;See this example:         &lt;br /&gt;&amp;lt;Reference Include=&amp;quot;System.ServiceModel&amp;quot;&amp;gt;         &lt;br /&gt;&amp;#160; &amp;lt;HintPath&amp;gt;..\..\..\Libraries\Silverlight Test dlls\2.0.5 DLLs\System.ServiceModel.dll&amp;lt;/HintPath&amp;gt;         &lt;br /&gt;&amp;lt;/Reference&amp;gt;         &lt;br /&gt;&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Save the .proj file&lt;/li&gt;    &lt;li&gt;Open it back up in VS (or reload)&lt;/li&gt;    &lt;li&gt;Verify the correct version is not being used by viewing the properties of the dll in VS&lt;/li&gt;    &lt;li&gt;Get back to testing&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;As you can see this is fixable, but it is also a bit of a hack/work around.&amp;#160; However this little bit of pain is worth the gains of adding tests to your code.&amp;#160; Now if only silverlight as a framework was more testable &lt;img style="border-bottom-style:none;border-right-style:none;border-top-style:none;border-left-style:none;" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/wlEmoticon_2D00_sadsmile_5F00_0D457A4A.png" /&gt;&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68139" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Hey, why is my ViewModelLocator not being called when creating a view?</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/08/04/hey-why-is-my-viewmodellocator-not-being-called-when-creating-a-view.aspx</link><pubDate>Thu, 04 Aug 2011 16:44:31 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68075</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68075</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68075</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/08/04/hey-why-is-my-viewmodellocator-not-being-called-when-creating-a-view.aspx#comments</comments><description>&lt;p&gt;Ok, this is going to seem really stupid, cause it was, but I thought I would share my pain incase someone has the same issue.&lt;/p&gt;  &lt;p&gt;A while back I blogged about how to create a &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2011/07/02/view-model-location-using-ninject-in-a-mvvm-silverlight-application.aspx"&gt;Convention Based View Model Location using Ninject in a MVVM/Silverlight Application&lt;/a&gt; in this post I talk about how to create a VMLocator, but to be honest my issue would also be visible if you rolled your own so you do not need to review my prior post if you do not want.&lt;/p&gt;  &lt;p&gt;My issue was that I created a child window in my Silverlight application and setup my binding for the VMLocator as normal&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;DataContext=&amp;quot;{Binding Source={StaticResource VMLocator}, Converter={StaticResource VMIndexerConverter}}&amp;quot;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, when I created the instance of the View the VMLocator was not being invoked and I was perplexed.&amp;#160; After talking it over w/ a co-worker it dawned on me that in my overloaded constructor in my View I did NOT setup the call to InitializeComponent(); correctly, OK i plan forgot to add it. Once I added the call to InitializeComponent(); everything just worked and the world was a happy place.&lt;/p&gt;

&lt;p&gt;The moral of the story is this, if you are trying to use the VMLocator pattern via setting the DataContext in XAML you MUST make sure you have a call to InitializeComponent(); in your constructor or you will not get the results you expected.&lt;/p&gt;

&lt;p&gt;Till next time, 
  &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68075" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Working with Live Tiles in WP7 Mango–Creating, Updating and Deleting them</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/16/working-with-live-tiles-in-wp7-mango-creating-updating-and-deleting-them.aspx</link><pubDate>Sat, 16 Jul 2011 19:24:15 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:67997</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=67997</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=67997</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/16/working-with-live-tiles-in-wp7-mango-creating-updating-and-deleting-them.aspx#comments</comments><description>&lt;p&gt;***** UPDATE *****   &lt;br /&gt;If you would like to see a video on this topic check out &lt;a href="http://dimecasts.net/Casts/CastDetails/195"&gt;Episode 195 @ Dimecasts.Net&lt;/a&gt;    &lt;br /&gt;*******************&lt;/p&gt;  &lt;p&gt;When Windows Phone 7 was first announced one of its distinguishing features of the OS compared to the iPhone or the Android was its Live Tile concept.&amp;#160; These live tiles allowed for the content on the tile to be updated and changed remotely to signify a change in the backend application, the weather applications where the info on the tile changes to reflect the current weather at your location is the typical example.&amp;#160; This was a cool feature and all but with Mango they have stepped that up a notch.&lt;/p&gt;  &lt;p&gt;In this post we will take a look at how we can create not only Application Tile content but also take a look at how to Create, Edit and Delete secondary tiles.&amp;#160; A secondary tile is a tile which can provide a deep link directly into a given screen in your application.&amp;#160; This will allow someone to skip directly to a page w/ important data with ease.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Creating the Application Tile via code&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;public void CreateApplicationTile()
{
    var appTile = ShellTile.ActiveTiles.First();

    if (appTile != null)
    {
        var standardTile = new StandardTileData
        {
            Title = &amp;quot;Live Tile Demo&amp;quot;,
            BackgroundImage = new Uri(&amp;quot;Images/SecondaryTileFrontIcon.jpg&amp;quot;, UriKind.Relative),
            Count = 13,	// any number can go here, leaving this null shows NO number
            BackTitle = &amp;quot;Back Title&amp;quot;,
            //BackBackgroundImage = new Uri(&amp;quot;Images/ApplicationTileIcon.jpg&amp;quot;, UriKind.Relative),
            BackContent = &amp;quot;Live Tile Demo Back Title&amp;quot;
        };

        appTile.Update(standardTile);
    }            
}&lt;/pre&gt;

&lt;p&gt;When creating, updating or deleting any tiles you will work from the ShellTile class which can be found in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.shell%28v=vs.92%29.aspx"&gt;Microsoft.Phone.Shell&lt;/a&gt; namespace.&amp;#160; This class has various static methods on it which will allow you to work with the tiles you want to create.&lt;/p&gt;

&lt;p&gt;Also, when creating the tiles you do NOT need to fill out items such as Count (leaving null will show no value) or any of the Back tile properties (BackTitle, BackBackgroundImage and BackContent).&amp;#160; really the only items you should populate is the Title and the BackgroundImage&lt;/p&gt;

&lt;p&gt;Finally, in the Beta build of WP7 Mango creating this application tile via code does NOT actually pin your application to the start screen, it simply sets up the metadata so that when it is pinned it will be populated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the Secondary Tile via code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So what is a Secondary tile?&amp;#160; A secondary tile is a tile which can be created programmatically and is similar to an Application tile but with one big difference.&amp;#160;&amp;#160; An Application tile will simply launch the application where a Secondary tile allows for you to launch the application and navigate directly to a given page in your application.&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public void CreateSecondaryTile()
{
    var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x =&amp;gt; x.NavigationUri.ToString().Contains(&amp;quot;DetailId=123&amp;quot;));

    if (foundTile == null)
    {
        var secondaryTile = new StandardTileData
                                {
                                    BackgroundImage = new Uri(&amp;quot;Images/SecondaryTileFrontIcon.jpg&amp;quot;, UriKind.Relative),
                                    Title = &amp;quot;Secondary Tile&amp;quot;,
                                    Count = null,
                                    BackTitle = &amp;quot;Back of Tile&amp;quot;,
                                    BackContent = &amp;quot;You can put some data here......&amp;quot;,
                                    //BackBackgroundImage = new Uri(&amp;quot;Images/SecondaryTileFrontIcon.jpg&amp;quot;, UriKind.Relative)
                                };
                
        ShellTile.Create(new Uri(&amp;quot;/Views/DetailsPage.xaml?DetailId=123&amp;quot;, UriKind.Relative), secondaryTile);
    }            
}&lt;/pre&gt;

&lt;p&gt;After running the code above you should notice one thing very quickly and that is that you will be navigated away from your application and back to the start menu.&amp;#160; This is currently by design (although I think it is a really bad idea) and will cause your application to tombstone.&amp;#160; Your users can get back into your application by either clicking on the tile or hitting the back&amp;#160; button.&amp;#160; &lt;/p&gt;

&lt;p&gt;One key item here is that when you call the .Create method on the Shelltile object make sure you put a valid Uri.&amp;#160; This URI along with the provided query string will allow WP7 Mango to navigate directly to this page w/ the provided query string data.&amp;#160; Now when the user navigates to this page you WILL be required to parse out the content of the query string in order to repopulate the screen.&lt;/p&gt;

&lt;p&gt;Also, your tiles should look something like below: 
  &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_5864D8FA.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_22EC16D5.png" width="131" height="134" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_17565996.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3705335E.png" width="132" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updating an existing Tile via code&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public void EditExistingTile()
{
    var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x =&amp;gt; x.NavigationUri.ToString().Contains(&amp;quot;DetailId=123&amp;quot;));

    if (foundTile != null)
    {
        // what sucks here is we cannot get access to the information on the existing tile...
        var liveTile = new StandardTileData
        {
            Title = &amp;quot;New Tile Text&amp;quot;
        };

        foundTile.Update(liveTile);
    }
}&lt;/pre&gt;

&lt;p&gt;The code above will search for (via the ShellTile object) a given tile and overlay any file tile with a new StandardTileData object.&amp;#160; What I totally hate here is that I have not seen any way to get ahold of the metadata on the found tile (Title, image, count, etc) which means you must repopulate it from scratch when you want to make a change.&amp;#160; This is not a huge issue but just sucks.&lt;/p&gt;

&lt;p&gt;This will NOT cause the user to navigate away from the app it will simply update any found secondary tile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting an existing Tile via code&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public void DeleteExistingTile()
{
    var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x =&amp;gt; x.NavigationUri.ToString().Contains(&amp;quot;DetailId=123&amp;quot;));

    // If the Tile was found, then delete it.
    if (foundTile != null)
    {
        foundTile.Delete();
    }
}&lt;/pre&gt;

&lt;p&gt;If we can find an existing tile we can simply call the ‘Delete’ method on it.&amp;#160; This will NOT cause the user to navigate away from the app it will simply remove any secondary tile.&lt;/p&gt;

&lt;p&gt;As you can see working with the Live Tiles in WP7 mango is cake which is great because this is an awesomely powerful new feature.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=67997" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WP7+Mango/default.aspx">WP7 Mango</category></item><item><title>Using Ninject (with CommonServiceLocator) with Caliburn.Micro on WP7</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/08/using-ninject-with-commonservicelocator-with-caliburn-micro-on-wp7.aspx</link><pubDate>Fri, 08 Jul 2011 09:35:54 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:67954</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=67954</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=67954</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/08/using-ninject-with-commonservicelocator-with-caliburn-micro-on-wp7.aspx#comments</comments><description>&lt;p&gt;As I am in the process of rebuilding my Dimecasts.net WP7 application from the ground up to work with WP7 Mango one of the things I wanted to do was fully use the &lt;a href="http://caliburnmicro.codeplex.com/"&gt;Caliburn.Micro&lt;/a&gt; framework.&amp;nbsp; Caliburn.Micro has its own built in &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;IoC&lt;/a&gt; container called the &lt;a href="http://caliburnmicro.codeplex.com/SourceControl/changeset/view/47de308d08ed#src%2fCaliburn.Micro.WP7.Extensions%2fPhoneContainer.cs"&gt;PhoneContainer&lt;/a&gt; which provides basic &lt;a href="http://en.wikipedia.org/wiki/Dependency_Injection"&gt;Dependency Injection&lt;/a&gt; and this container works great but I have a bit of history using Ninject with my Wp7 applications so I wanted to replace the usage of the PhoneContainer with my &lt;a href="http://ninject.org/"&gt;Ninject&lt;/a&gt;, or more precisely the &lt;a href="http://commonservicelocator.codeplex.com/"&gt;CommonServiceLocator&lt;/a&gt; implementation of Ninject.&amp;nbsp; I knew this had to be doable because there are examples of using &lt;a href="http://mef.codeplex.com/"&gt;MEF&lt;/a&gt; with Caliburn.Micro&lt;/p&gt; &lt;p&gt;Turns out I was right using Ninject w/ the CommonServiceLocator inside of Caliburn.Micro is doable and is very easy to boot.&amp;nbsp; Of course before I set out to build my own implementation of this I decided to google for it and this &lt;a href="http://caliburnmicro.codeplex.com/discussions/230861"&gt;post&lt;/a&gt; was about the closest I could find to working code, but this code was NOT complete, at least for the current CM implementation.&amp;nbsp; Even though the post I found was not complete working code it was a great headstart in what needed to be done.&lt;/p&gt; &lt;p&gt;Here is how I got Caliburn.Micro to use Ninject as its IoC container.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 1: Register the setup bootstrapper that you want to use&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;You will need to open up your App.xaml file and put in the code below.&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;    &amp;lt;!--Application Resources--&amp;gt;
    &amp;lt;Application.Resources&amp;gt;
    	&amp;lt;local:NinjectBootstrapper x:Key=&amp;quot;bootstrapper&amp;quot; /&amp;gt;
    &amp;lt;/Application.Resources&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Create the a NinjectBootstrapper which inherits off of &lt;/strong&gt;&lt;a href="http://caliburnmicro.codeplex.com/SourceControl/changeset/view/47de308d08ed#src%2fCaliburn.Micro.WP7%2fPhoneBootstrapper.cs"&gt;&lt;strong&gt;PhoneBootstrapper&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Caliburn.Micor uses its bootstrapper to do some basic setup and configuration work.&amp;nbsp; It is here that we want to extend this and add support for Ninject and the CommonServiceLocator.&amp;nbsp; Go ahead and create a class as you see below.&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;public class NinjectBootstrapper : PhoneBootstrapper
{
    private NinjectContainer _ninjectContainer;

    protected override void Configure()
    {
        _ninjectContainer = new NinjectContainer(RootFrame);

        _ninjectContainer.RegisterDefaultBindings( typeof ( DashboardViewModel ), typeof ( IEventAggregator ) );
        _ninjectContainer.RegisterPhoneServices();

        var ninjectServiceLocator = new NinjectServiceLocator(_ninjectContainer.Kernel);

        ServiceLocator.SetLocatorProvider(() =&amp;gt; ninjectServiceLocator);     
    }

    protected override object GetInstance(Type service, string key)
    {
        if (service != null)
        {
            return ServiceLocator.Current.GetInstance( service, key );
        }

        throw new ArgumentNullException(&amp;quot;service&amp;quot;);
    }

    protected override IEnumerable&amp;lt;object&amp;gt; GetAllInstances(Type service)
    {
        return ServiceLocator.Current.GetAllInstances( service );
    }

    protected override void BuildUp(object instance)
    {
        _ninjectContainer.Kernel.Inject(instance);
    }
}
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 3: Implement the Ninject Setup logic&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As you can see from step 2 I have created a class which actually performs all the direct Ninject setup and I called it the NinjectContainer.&amp;nbsp; Below is the code for this container.&amp;nbsp; You should also note 2 more things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;This container implements &lt;a href="http://Caliburn%20Micro:%20WPF,%20Silverlight%20and%20WP7%20made%20easy."&gt;IPhoneContainer&lt;/a&gt; from Caliburn.Micro 
&lt;li&gt;In the RegisterPhoneServices method this is a very manual rebinding of Caliburn.Micro and it is likely that I missed something.&amp;nbsp; This code was a direct port from the default implementation of the Caliburn IoC container setup. &lt;/li&gt;&lt;/ol&gt;&lt;pre class="c-sharp" name="code"&gt;public class NinjectContainer : IPhoneContainer
{
    private readonly IKernel _kernel;
    private readonly Frame _rootFrame;

    public NinjectContainer( Frame rootFrame )
    {
        _kernel = new StandardKernel();
        _rootFrame = rootFrame;
    }

    public event Action&amp;lt;object&amp;gt; Activated;

    public IKernel Kernel
    {
        get { return _kernel; }
    }

    public void RegisterWithPhoneService( Type service, string phoneStateKey, Type implementation )
    {}

    public void RegisterWithAppSettings( Type service, string appSettingsKey, Type implementation )
    {}

    public void RegisterPhoneServices(bool treatViewAsLoaded = false)
    {
        var phoneService = new PhoneApplicationServiceAdapter(_rootFrame);
        var navigationService = new FrameAdapter(_rootFrame, treatViewAsLoaded);
            
        Kernel.Rebind&amp;lt;IPhoneContainer&amp;gt;().ToMethod(x =&amp;gt; this);
        Kernel.Rebind&amp;lt;INavigationService&amp;gt;().ToMethod(x =&amp;gt; navigationService);
        Kernel.Rebind&amp;lt;IPhoneService&amp;gt;().ToMethod(x =&amp;gt; phoneService);
        Kernel.Rebind&amp;lt;IEventAggregatorv().To&amp;lt;EventAggregator&amp;gt;().InSingletonScope();
        Kernel.Rebind&amp;lt;IWindowManager&amp;gt;().To&amp;lt;WindowManager&amp;gt;().InSingletonScope();
        Kernel.Rebind&amp;lt;IVibrateController&amp;gt;().To&amp;lt;SystemVibrateController&amp;gt;().InSingletonScope();
        Kernel.Rebind&amp;lt;ISoundEffectPlayer&amp;gt;().To&amp;lt;XnaSoundEffectPlayer&amp;gt;().InSingletonScope();
        Kernel.Rebind&amp;lt;StorageCoordinator&amp;gt;().To&amp;lt;StorageCoordinator&amp;gt;().InSingletonScope();
        Kernel.Rebind&amp;lt;TaskController&amp;gt;().To&amp;lt;TaskController&amp;gt;().InSingletonScope();
            

        var coordinator = Kernel.Get&amp;lt;StorageCoordinator&amp;gt;();
        coordinator.Start();

        var taskController = Kernel.Get&amp;lt;TaskController&amp;gt;();
        taskController.Start();
    }

    public void RegisterDefaultBindings( params Type[] typesToScanAssembliesFor )
    {
        // scan services
        Kernel.Scan(x =&amp;gt;
        {
            foreach ( var type in typesToScanAssembliesFor )
            {
                x.FromAssemblyContaining( type );
            }
                
            x.Where(type =&amp;gt; type.Name.EndsWith(&amp;quot;Service&amp;quot;));

            x.BindWithDefaultConventions();

            x.InSingletonScope();
        });

        // scan the rest
        Kernel.Scan(x =&amp;gt;
        {
            foreach (var type in typesToScanAssembliesFor)
            {
                x.FromAssemblyContaining(type);
            }

            x.Where(type =&amp;gt; !type.Name.EndsWith(&amp;quot;Service&amp;quot;));

            x.BindWithDefaultConventions();
        });
    }
}
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 4: Hit F5 and see the fruits of your effort&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now if we did everything right your application should not be able to be run and Caliburn.Micro and Ninject (and CSL) as its IoC container.&lt;/p&gt;
&lt;p&gt;As you can see you can swap out the built in IoC container w/ Ninject inside of Caliburn.Micro with almost no effort.&amp;nbsp; I hope this helps and others enjoy.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;/object&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=67954" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WP7/default.aspx">WP7</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WindowsPhone/default.aspx">WindowsPhone</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Caliburn+Micro/default.aspx">Caliburn Micro</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WP7+Mango/default.aspx">WP7 Mango</category></item><item><title>XamlParseException from WP7 Mango and Caliburn.Micro</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/03/xamlparseexception-from-wp7-mango-and-caliburn-micro.aspx</link><pubDate>Sun, 03 Jul 2011 22:41:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:67941</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=67941</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=67941</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/03/xamlparseexception-from-wp7-mango-and-caliburn-micro.aspx#comments</comments><description>&lt;p&gt;*** UPDATE: Turns out the is expected as Caliburn will create its own instance of the PhoneApplicationService for you.&amp;#160; Also when using Caliburn.Micro make sure that your App.xaml.cs is empty as Caliburn.Micro has better facilities for handling all these actions. ***&lt;/p&gt;  &lt;p&gt;Today when I was kicking off a new Wp7 Mango project where I was going to use &lt;a href="http://caliburnmicro.codeplex.com/"&gt;Caliburn.Micro&lt;/a&gt; soup to nuts I quickly ran into the following exception.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_051F5B05.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2B813E50.png" width="456" height="271" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now before I explain what is needed to resolve this error (I hope) let me quickly explain what I had done so far in my project which lead up to this.&amp;#160; I did the following:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Created a new WP7 Mango Application (not pivot, not panorama) &lt;/li&gt;    &lt;li&gt;Downloaded the latest nightly build of Calibrun.Micro &lt;/li&gt;    &lt;li&gt;Opened one of the Caliburn.Micro sample applications and copied it’s WP7AppBootstraper &lt;/li&gt;    &lt;li&gt;Hit F5 &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;When I ran the application, which had NOTHING in it other than the default setup contents I received the error above.&amp;#160; Since I had not setup the ability to walk though the Caliburn.Micro source (something I have since done) I quickly took another quick scan of the sample WP7 Navigation sample that is part of the Caliburn.Micro source tree to see what I had done differently.&amp;#160; &lt;/p&gt;  &lt;p&gt;After about 2 minutes of looking I noticed that my App.xaml was a bit different.&amp;#160; I had the following in my App.xaml    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_38E75156.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_387B1E61.png" width="663" height="135" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Just for giggles I commented out the line which setup the PhoneApplicationService (as you see below):    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_0A2198B4.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_09B565BF.png" width="701" height="127" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After commenting out the line above I again hit F5.&amp;#160; This time my error went away and the application loaded as expected.&amp;#160; Now I am not sure of 2 things.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Is this a Mango only issue w/ Caliburn.Micro (assuming it is an issue at ALL w/ CM) &lt;/li&gt;    &lt;li&gt;Is this something that should ALWAYS be removed when building a Caliburn.Micro application? &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;No matter the reason or the cause it did appear to solve my issue.&amp;#160; So if you are having the same issue try removing the code above from your app.xaml and see if that helps.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=67941" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WP7/default.aspx">WP7</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Caliburn+Micro/default.aspx">Caliburn Micro</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WP7+Mango/default.aspx">WP7 Mango</category></item><item><title>Convention Based View Model Location using Ninject in a MVVM/Silverlight Application</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/02/view-model-location-using-ninject-in-a-mvvm-silverlight-application.aspx</link><pubDate>Sat, 02 Jul 2011 11:23:53 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:67852</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=67852</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=67852</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/07/02/view-model-location-using-ninject-in-a-mvvm-silverlight-application.aspx#comments</comments><description>***** UPDATE *****   &lt;br /&gt;If you would like to see a video on this topic check out &lt;a href="http://dimecasts.net/Casts/CastDetails/194"&gt;Episode 194 @ Dimecasts.Net&lt;/a&gt;   &lt;br /&gt;*******************  &lt;p&gt;When building out a Silverlight application (or WPF application for that matter) the &lt;a href="http://en.wikipedia.org/wiki/Model_View_ViewModel"&gt;MVVM&lt;/a&gt; pattern is the pattern of choice for most projects I am aware of.&amp;#160; When using MVVM there is a sub pattern which is commonly used which is known as ViewModelLocator.&amp;#160; The ViewModelLocator concept basically tries to handle the repetitive task of coupling the View with its ViewModel but doing so in a way which removes any manual coding and it just ‘happens’.&lt;/p&gt;  &lt;p&gt;Now if you have done any research on the ViewModel Location I am sure you have run across countless other blog posts out there which explain how to implement in this code, and many of them are great.&amp;#160; In fact here are a few which helped me down the path of creating the code I am going to talk about in this post&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://johnpapa.net/simple-viewmodel-locator-for-mvvm-the-patients-have-left-the-asylum"&gt;Simple ViewModel Locator&lt;/a&gt; for MVVM by John Papa (this is the post which really kick started this pattern) &lt;/li&gt;    &lt;li&gt;Wiring up &lt;a href="http://blog.roboblob.com/tag/viewmodellocator/"&gt;ViewModel Locator&lt;/a&gt; w/ Silverlight &lt;/li&gt;    &lt;li&gt;MVVM and &lt;a href="http://geekswithblogs.net/bdiaz/archive/2010/03/31/kiss-and-tell---mvvm-and-the-viewmodellocator.aspx"&gt;ViewModel Location&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Another MVVM and &lt;a href="http://geekswithblogs.net/bdiaz/archive/2010/03/31/kiss-and-tell---mvvm-and-the-viewmodellocator.aspx"&gt;ViewModel Location&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://caliburnmicro.codeplex.com/"&gt;Caliburn.Micro&lt;/a&gt; has an implementation &lt;/li&gt;    &lt;li&gt;&lt;a href="http://mvvmlight.codeplex.com/"&gt;MVVMLight&lt;/a&gt; has an implementation &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All of the above posts basically show how to implement this pattern in your application and from what I can tell all of them work and will do the job. However, none of those (minus the Caliburn.Micro) implementations fulfills the one requirement I want which is to totally remove the need to ‘wire’ the ViewModel up to your View if even via XAML.&amp;#160; I want to remove this wiring from the XAML because in my mind this still leaves me hard wiring the relationship rather than using convention based wiring.&amp;#160; One scenario in which the hard wiring could turn around and bite you is in the times where you rename the view and the view model.&amp;#160; If you fail to update your wiring code in XAML you will receive runtime errors.&lt;/p&gt;  &lt;p&gt;Here are a few examples:    &lt;br /&gt;John Papa’s Implementation&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;DataContext=&amp;quot;{Binding Source={StaticResource VMLocator}, Converter={StaticResource VMIndexerConverter}, ConverterParameter=MainPageViewModel}&amp;quot;&lt;/pre&gt;

&lt;p&gt;ViewModelLocator’s Implementation&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;    &amp;lt;UserControl.Resources&amp;gt;
        &amp;lt;ViewModels:EditUsersViewModelLocator x:Key=&amp;quot;viewModelLocator&amp;quot;  /&amp;gt;
    &amp;lt;/UserControl.Resources&amp;gt;
    &amp;lt;UserControl.DataContext&amp;gt;
        &amp;lt;Binding Source=&amp;quot;{StaticResource viewModelLocator}&amp;quot; Path=&amp;quot;ViewModel&amp;quot; /&amp;gt;
    &amp;lt;/UserControl.DataContext&amp;gt;&lt;/pre&gt;

&lt;p&gt;I wanted my implementation of toe ViewModelLocator pattern to NOT need to know anything about the actual View or the ViewModel either in the XAML or in the code behind.&amp;#160; What I wanted as the following:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;DataContext=&amp;quot;{Binding Source={StaticResource VMLocator}, Converter={StaticResource VMIndexerConverter}}&amp;quot;&lt;/pre&gt;

&lt;p&gt;Now you may be looking at my XAML above and comparing it to the XAML from John Papa’s post and be thinking what is really different?&amp;#160; The difference is in this segment of code &lt;em&gt;ConverterParameter=MainPageViewModel &lt;/em&gt;In his example he ‘hard wires’ the ViewModel which is being used up to the page and I did not want to do that.&amp;#160; I wanted to use a standard naming convention (right, &lt;a href="http://en.wikipedia.org/wiki/Convention_over_configuration"&gt;convention over configuration&lt;/a&gt;) and allow my locator to determine the ViewModel based on the current View.&lt;/p&gt;

&lt;p&gt;So how did I implement my ViewModelLocator pattern, well lets take a look.&lt;/p&gt;

&lt;p&gt;Code for ViewModelLocator&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public class ViewModelLocator
{   
    private static readonly IDictionary&amp;lt;type, type&amp;gt; s_viewModelCache = new Dictionary&amp;lt;type, type&amp;gt;();
        
    public Type GetViewModelTypeForView( Type viewType )
    {
        var viewModelName = ResolveViewModelName(viewType.Name).ToLower();

        // We are try to cache the types in order to remove the assembly scan hit, this is optional of course and 
	// you may not want or need this
	// One thing to point out here is that this code ASSUMES that your view and viewmodel classes are in the 
	//  same assembly.  if this is not true for your project this code will not work as expected.  We made this
	//  assumption because it is true in our project
        var foundViewModelType = GetExistingTypeFromCache(viewType) ?? (from type in viewType.Assembly.GetExportedTypes()
                                                                        where viewModelName.Equals(type.Name.ToLower())
                                                                        select type).FirstOrDefault();
    
        // this will throw a custom exception type, you can use your own if you want
        if (foundViewModelType == null) { throw new ViewModelTypeNotResolvedException(viewModelName, viewType); }

        // Add the found view and viewModel to the cache
        AddToCache(viewType, foundViewModelType);

        return foundViewModelType;
    }

    private void AddToCache(Type viewType, Type foundViewModelType)
    {
        if (!s_viewModelCache.ContainsKey(viewType))
        {
            s_viewModelCache.Add(viewType, foundViewModelType);
        }
    }

    private Type GetExistingTypeFromCache( Type viewType )
    {
        if (s_viewModelCache.ContainsKey(viewType))
        {
            return s_viewModelCache[viewType];
        }

        return null;
    }

    private string ResolveViewModelName(string viewTypeName)
    {
        var asLowerViewTypeName = viewTypeName.ToLower();

	// ***** Below is OUR product&amp;#39;s current naming conventions, replace with your own if you want *****
        // check to see if the view ends w/ &amp;quot;View&amp;quot;
        if (asLowerViewTypeName.EndsWith(&amp;quot;view&amp;quot;))
        {
            return asLowerViewTypeName.Replace(&amp;quot;view&amp;quot;, &amp;quot;ViewModel&amp;quot;);
        }

        if (asLowerViewTypeName.EndsWith(&amp;quot;usercontrol&amp;quot;))
        {
            return asLowerViewTypeName.Replace(&amp;quot;usercontrol&amp;quot;, &amp;quot;ViewModel&amp;quot;);
        }

        if (asLowerViewTypeName.EndsWith(&amp;quot;childwindow&amp;quot;))
        {
            return asLowerViewTypeName.Replace(&amp;quot;childwindow&amp;quot;, &amp;quot;ViewModel&amp;quot;);
        }

        return string.Concat(viewTypeName, &amp;quot;ViewModel&amp;quot;);
    }

    public static IDictionary&amp;lt;type, type&amp;gt; ViewModelCache { get { return s_viewModelCache; } }
}&lt;/pre&gt;

&lt;p&gt;Code for IndexConverter&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public class IndexerConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    {
        Contract.Requires&amp;lt;ArgumentNullException&amp;gt;(value != null);

        var locator = value as ViewModelLocator;

        Contract.Assume(locator != null,
                        string.Format(
                            &amp;quot;The provided converter value was expected to be of type {0} but was provided as type {1} which is not acceptable for this converter&amp;quot;,
                            typeof(ViewModelLocator).Name,
                            value.GetType().Name));

        var viewType = GetViewType();

        var viewModelType = locator.GetViewModelTypeForView(viewType);

	// We are using the ServiceLocator pattern which is wrapping Ninject
        var viewModelInstance = ServiceLocator.Current.GetInstance(viewModelType);

        return viewModelInstance;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
        
    // This does incur a perf hit by looking at the stack trace, but in 
    //  my opinion this hit is worth it compared to having to manually wire items up
    private Type GetViewType()
    {
        var stack = new StackTrace();

        return stack.GetFrames()
            .Select(f =&amp;gt; f.GetMethod())
            .Where(m =&amp;gt; m.Name == &amp;quot;InitializeComponent&amp;quot;)
            .Select(m =&amp;gt; m.DeclaringType)
            .FirstOrDefault();
    }

}&lt;/pre&gt;

&lt;p&gt;Code needed in your App.Xaml&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;&amp;lt;MVVMLib:ViewModelLocator x:Key=&amp;quot;VMLocator&amp;quot; /&amp;gt;
&amp;lt;MVVMLib:IndexerConverter x:Key=&amp;quot;VMIndexerConverter&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;Code for the custom Exception ViewModelTypeNotResolvedException&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public class ViewModelTypeNotResolvedException : Exception
{
    public string ViewModelName { get; set; }
    public Type ViewName { get; set; }

    // Commented this out because i do not want to be able to create this without the VMName or the VName
    //public ViewModelTypeNotResolvedException() {}

    /// 
    /// Will build an instance of the exception and push in a default message based on the viewModelname and view properties.
    /// *** This is the lazy way to create the message ***
    /// 
    /// &lt;param name="viewModelName" /&gt;The name of the viewModel which was not able to be created or found&lt;/param&gt;
    /// &lt;param name="view" /&gt;The type for the view we were trying to bind the VM to&lt;/param&gt;
    public ViewModelTypeNotResolvedException(string viewModelName, Type view)
        : base(string.Format(&amp;quot;When trying to resolve the view model {0} it was not found in the same assembly as the view {1}&amp;quot;, viewModelName, view.Name))
    {
        ViewModelName = viewModelName;
        ViewName = view;            
    }

    /// 
    /// Will build an instance of the exception
    /// 
    /// &lt;param name="viewModelName" /&gt;The name of the viewModel which was not able to be created or found&lt;/param&gt;
    /// &lt;param name="view" /&gt;The type for the view we were trying to bind the VM to&lt;/param&gt;
    /// &lt;param name="message" /&gt;&lt;/param&gt;
    public ViewModelTypeNotResolvedException(string viewModelName, Type view, string message) : base(message)
    {
        ViewModelName = viewModelName;
        ViewName = view;
    }

    /// 
    /// Will build an instance of the exception
    /// 
    /// &lt;param name="viewModelName" /&gt;The name of the viewModel which was not able to be created or found&lt;/param&gt;
    /// &lt;param name="view" /&gt;The type for the view we were trying to bind the VM to&lt;/param&gt;
    /// &lt;param name="message" /&gt;&lt;/param&gt;
    /// &lt;param name="innerException" /&gt;&lt;/param&gt;
    public ViewModelTypeNotResolvedException(string viewModelName, Type view, string message, Exception innerException)
        : base(message, innerException)
    {
        ViewModelName = viewModelName;
        ViewName = view;
    }
}&lt;/pre&gt;

&lt;p&gt;As you can see the code needed for this is not that complicated or difficult to implement.&amp;#160; &lt;/p&gt;

&lt;p&gt;One thing to understand with this post, I am NOT saying that the other implementations are bad or they do not work. In fact I am saying the exact opposite, they all are great and they all work and I used all their implementations as baseline for my implementation.&amp;#160; What I am saying as the other examples did not meet my EXACT needs. &lt;/p&gt;

&lt;p&gt;Please take a look at the code and let me know where I went wrong or what your thoughts are.&amp;#160; &lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=67852" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Best+Practice/default.aspx">Best Practice</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Ninject/default.aspx">Ninject</category></item><item><title>Help RIA Services is NOT returning my entire object graph</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/06/23/help-ria-services-is-not-returning-my-entire-object-graph.aspx</link><pubDate>Thu, 23 Jun 2011 16:36:55 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:67772</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=67772</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=67772</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/06/23/help-ria-services-is-not-returning-my-entire-object-graph.aspx#comments</comments><description>&lt;p&gt;***** NOTE: I (we) may be doing this 100% wrong so if I am please let me know a better way *****&lt;/p&gt;  &lt;p&gt;Ok, this is a complete NEWBIE post by me, but hey I am just learning &lt;a href="http://www.silverlight.net/getstarted/riaservices/"&gt;WCF RIA Services&lt;/a&gt;. If you are like me and you are learning you may run into the scenario I have a few times where data is present during inspection on the server side but NOT on the client side.&amp;#160; &lt;/p&gt;  &lt;p&gt;If you run into this scenario there are 2 things you should check;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;You have explicitly included our child objects in your EF query &lt;/li&gt;    &lt;li&gt;You have provided the correct ‘Include’ property on your child entity via the MetadataTypeAttribute &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;How to ensure your EF queries have included your child objects?&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;// The key to the EF logic below is the .Include statement
public IQueryable GetLinkCollection(int clientID)
{
	var result = ObjectContext.kLinkCollections
                .Include(&amp;quot;LinkCollectionType&amp;quot;)
                .Include(&amp;quot;QuickLinks.ClientLink&amp;quot;)
                .Where(m =&amp;gt; m.ClientID == clientID);

	return result;
}&lt;/pre&gt;

&lt;p&gt;How to ensure your RIA services have your child objects exposed?&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;// The trick to this code below is the [Include] attribute on your child objects
[MetadataTypeAttribute(typeof(LinkCollection.LinkCollectionMetadata))]
public partial class LinkCollection
{
	internal sealed class LinkCollectionMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private LinkCollectionMetadata()
            {
                
            }

            [Include]
            public EntityCollection&amp;lt;QuickLink&amp;gt; QuickLinks { get; set; }

            [Include]
            public ClientQuickLinkCollectionType LinkCollectionType { get; set; }

        }
}&lt;/pre&gt;

&lt;p&gt;Like I said above it is possible that I am doing something completely wrong, but ensuring the above 2 items are setup correctly has solved my problem. I should also note that the class tree which is being returned back from the RIA call was created AFTER the initial setup wizard was run and we cannot find anyway to re-run the wizard without blowing away the original code and having it recreated.&lt;/p&gt;

&lt;p&gt;Hope this helps the next newbie &lt;img style="border-bottom-style:none;border-right-style:none;border-top-style:none;border-left-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/wlEmoticon_2D00_smile_5F00_799A1859.png" /&gt;&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=67772" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/RIA+Services/default.aspx">RIA Services</category></item><item><title>Using Binding to create Panels/Pivots in your WP7 Application</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/04/19/using-binding-to-create-panels-pivots-in-your-wp7-application.aspx</link><pubDate>Tue, 19 Apr 2011 10:19:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:66962</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=66962</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=66962</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/04/19/using-binding-to-create-panels-pivots-in-your-wp7-application.aspx#comments</comments><description>&lt;p&gt;If you are building a Windows Phone 7 application it is very likely that you are going to incorporate either the Panoramic or Pivot layouts in your app.&amp;nbsp; In most cases when you are building these your panels/pivots are fairly static.&amp;nbsp; However, what do you do when the number of panels/pivots needs to changed based on environmental setting (ie data or user preferences)?&lt;/p&gt;
&lt;p&gt;One solution is to use the code behind and manually create your panels/pivots.&amp;nbsp; However, I personally feel this method is clunky and fugly.&amp;nbsp; I would rather stay as close to the MvvM pattern as possible as well as harness the power of Binding to build my UI on the fly based on values inside my view model.&amp;nbsp; In this post we are going to take a look at how simple it is to bind your View Model to your UI and have your panels/pivots built for you.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Create the View Model&amp;rsquo;s to Bind to the UI&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Main View Model &amp;ndash; This is the one bound directly to the UI&lt;/i&gt;&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;    public class DashboardViewModel : ViewModelBase
    {
        // This is an internal class and does not change the implementation...
        private readonly IDashboardService _dashboardService;

        public DashboardViewModel( IDashboardService dashboardService )
        {
            _dashboardService = dashboardService;
        }


        public string Title 
        {
            get { return _dashboardService.DashboardTitle; } 
            set 
            { 
                _dashboardService.DashboardTitle = value;
                RaisePropertyChangedEventImmediately( &amp;quot;Title&amp;quot; );
            }
        }

        public ObservableCollection PanelCollection
        {
            get { return _dashboardService.PanelItems; }
            set
            {
                _dashboardService.PanelItems = value;
                RaisePropertyChangedEventImmediately( &amp;quot;PanelCollection&amp;quot; );
            }
        }
    }&lt;/pre&gt;
&lt;p&gt;In the class above there are 2 properties we need to know about.&amp;nbsp; &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Title &amp;ndash; This is the property in the VM which will create the actual title for the entire Panorama control &lt;/li&gt;
&lt;li&gt;PanelCollection &amp;ndash; This is the property in the VM which contains the list of items which will be used to generate each panel/pivot in the UI &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;i&gt;Panel View Model &amp;ndash; These are the ones which will build each panel/pivot&lt;/i&gt;&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;    public interface IDashboardPanelItemViewModel
    {
        DashboardPanelType DashboardPanelType { get; set; }

        string DashboardTitle { get; set; }

        ObservableCollection&amp;lt;IDashboardPanelListItemViewModel&amp;gt;: PanelListItems { get; set; }
    }&lt;/pre&gt;
&lt;p&gt;In the class (actually it is an interface) above there are 3 properties we need to worry about&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;DashboardPanelType &amp;ndash; This really does not change how the panels are bound to the UI but rather is used to determine how the actual panel data is displayed (future post on this) &lt;/li&gt;
&lt;li&gt;DashboardTitle &amp;ndash; This is the property which will create the text title for the panel/pivot &lt;/li&gt;
&lt;li&gt;PanelListItems &amp;ndash; This is the property which will contain the individual data points which will be displayed on the created panel/pivot&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;b&gt;Create the xaml to hookup the binding&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;When binding the Main View Model (the first class above) to the UI we need to do 2 things&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Need to bind our main View Model to the Panorama (or PIvot)
    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_3890E917.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2C8EF8E3.png" border="0" height="26" width="644" /&gt;&lt;/a&gt;
    &lt;/li&gt;
&lt;li&gt;Need to bind the individual list item from the element in PanelCollection to the panel
    &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_7E357335.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_04E87CB9.png" border="0" height="64" width="644" /&gt;&lt;/a&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When looking at the 2 snippets above you want to pay attention to the ItemsSource Property in both.&lt;/p&gt;
&lt;p&gt;The End Result (bit fugly, but this is for demo only)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_1D781A09.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3607B759.png" border="0" height="459" width="254" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you can using Binding to create your panels/pivots based on the data in your view model is super simple and requires NO code behind code to accomplish.&amp;nbsp; Please be aware though that you should NOT generate too many panels/pivots as that is a massive UI design smell.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=66962" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WP7/default.aspx">WP7</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WindowsPhone/default.aspx">WindowsPhone</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>