Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Part 15: Implementing Type Converters

16 minutes, 32 seconds


Right click “Save as…”

In order to make our declarative controls and data binding work smoothly, we look at implicit XAML type converters, type converters added to our project template, then implement our own custom type converter and explain its purpose.


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Navprabhat SinghNavprabhat Singh

    please provide us a code which you are written in a flip view so that we can understand the given function properly.

  • IanIan

    Thanks for this great series, is there a reason that StringBuilder.ApendLine(item) wasn't used? Best wishes

  • @Navprabhat Singh: Hi, not sure what you're asking for here.  You'll need to be more specific / clearer as to what it is you are trying to accomplish.

    @Ian: If you could point me to the exact time in the video I could offer a better answer.  Off the top of my head / not looking at the video (1) I was following the instructions of the Hands On Labs Smiley and (2) why the author of the Lab chose not to use StringBuilder?  Speculation, but perhaps the amount of appending didn't warrant it, or they were just keeping everything obvious and simple.  You can feel free to use whatever method you prefer.  Good luck!

  • IanIan

    Thanks for the reply Bob.
    It was only a very minor point, eg at 4:50, they could replace the two lines with one.
    I'm very new to programming so wasn't sure if I was missing something obvious

  • I think what Navprabhat Singh is saying is that in your download code (http://media.ch9.ms/content/WinStoreAppDev_CS.zip) there is no Common\ListConverter.cs at all and the code in ItemDetailPage.xaml doesn't have <FlipView.Template> (see 8:11 in the video).  I typed in the ListConverter.cs manually as I could see all the code on the video but not so for the ItemDetailPage.xaml file.

    In your download there are folders of the application for chapters 3-5, 9 and 24.  There is no CS_15 folder for the lesson in question ("Part 15: Implementing Type Converters").  I looked in the CS_24 folder hoping to find it there but ItemDetailPage.xaml has no reference to <FlipView.Template> and ListConverter.cs isn't there either.

    I'm sure it's in the Lab download, I just didn't get around do downloading it (it seems large and was hoping to avoid getting it).

    Anyway, thanks Bob for your great work.

  • I downloaded the Labs (http://aka.ms/windows8campinabox) and got the code I needed, so I'm good to go.



  • @JohnMarsing: Ah, thanks for the explanation and I apologize for the oversight!

  • Vance Lee MeurerVanceLee​Meurer as of 1999

    I'm stuck.  ItemDetailPage.xaml line 85, the part you  deleted to see what would happen is BLUE LINED and I can't get it to go away.  I'll try a reboot and if that does not work I'll be giving you tons of detail on what I've tried so far.  Thanks for the class.

  • @VanceLeeMeurer: Any updates?  Despite the Intellisense / blue line, does the code still compile?  I'll try to help if I can.

  • Vance Lee MeurerVanceLee​Meurer as of 1999

    I'm not sure what it was but only this far along, I deleted the solution and started over.  It worked the second time. The one thing I'd say is I can't click on COPY CODE on the web page.  I have to highlight the data, right click and get it.  Maybe I picked up an invisible internet character somehow?  I'm back on track and eager to get through this.

  • akiaki

    if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
    i m getting this error how to solve this , the app opens bt when we click on any recipe it opens app.g.i.cs and high lights this line plzz help.

  • akiaki

    Text="{Binding Ingredients, Converter={StaticResource ListConverter}}" and i m getting blue line here line no. 84

  • akiaki

    in item detail page line no. is 85 sorry abut that

  • if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break(); 
    i m getting this error how to solve this , the app opens bt when we click on any recipe it opens app.g.i.cs and high lights this line plzz help.

  • @aki: @codingquery: I'm assuming you are the same person ... according to this:


    It means you've hit a bug in the code you typed in.  Since you didn't land on C# code, I'm going to guess it's a problem with your XAML code.  I'm guessing this is related to your other issue with the blue squiggly line under line 85 in your XAML.  Since it's dealing with the Type Converter AND this is not a compilation error -- but rather a runtime error, I'm guessing you didn't implement it correctly and when you call it from XAML it breaks.  Perhaps you're missing a accessibility modifier like Public?  If I were you I would CLOSELY comb through my code.  Worst case ... compare ( or even copy the code) from the Windows 8 Lab in a Box / Contoso Cookbook Hands on Lab and paste it into your project ... both the List Converter AND the XAML that calls it to see if it fixes the problem.

    I've never hit the error you describe, so outside of helping you debug it, I don't exactly why you're getting it.

  • akiaki

    i have much of the problem only one error is their i hope u can tell how to solve that also blue line exists over this

    d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}">

    d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}">

    and the error shown is
    Error 1 The name "SampleDataSource" does not exist in the namespace "using:mycookbook". C:\Users\aakriti\Documents\Visual Studio 2012\Projects\mycookbook\mycookbook\ItemDetailPage.xaml 26 13 mycookbook

  • akiaki

    sorry i have solved much of the problem

  • @aki: Good to hear ... were you missing a XAML namespace declaration associated with the d: prefix?

  • BilalBilal

    I would like to know if i want to add images with each Ingredients what i need to do or how it can be done using type converter. Supposing that we have imagedata in our data"Recipes.txt"

  • Thanks Bob, all looks good except for in the simulation for 1024 X 768 resolution, where you get about 3 characters on line, you will have the need for the scroll bar on those, but it is not so readable, would be better if we could shrink the left margin or something to give the direction text more room..

    Here's an odd error..  I ran the simulator code ok, ran again I got an error, ran again it code ok, ran again got the error of two runs back.. I thought I saw someone insert a photo, but don't see it..

    well the code page is ItemsDetailPage.xaml.cs

    line # 51  this.DefaultViewModel["Group"] = item.Group;

    Error is NullReference was unhandled by user code

    Weird, I did not get this error until this video, and we weren't playing with the Group in this lesson, also weird it is not every time.

    More info, every time I ran the simulator I closed it, by not only hitting the red square in VS to end the session, but also opposite clicking the simulator in the taskbar and hitting close.. So it was working and not working for run, close, run, close, run, close, run, close..  Now when I leave the simulator running and just end by clicking the little red square in VS, it will work every time...

  • J SattiJ Satti

    Hi Bob:

    Would you please provide link or text where I can get FlipView (that lengthy code you copied and pasted). I downloaded stuff at http://aka.ms/windows8campinabox) but could not find the code. And too old to type though love to follow your teaching here and at LearnVisualStudio.net.

    Thanks in advance.

  • J SattiJ Satti

    Bob I got it. Thanks and appreciate your teaching skills.

  • Opening comments

  • Mike Taultymtaulty Mike Taulty

    At around 2mins in to the video I think there's a bit of a mixup between type converters and value converters. The 2 converters in the project are value converters (IValueConverter) rather than type converters - apologies if I've got that mixed up.



  • @mtaulty: I probably misspoke.  My apologies.  I'm a big fan of yours, Mike!

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.