Dmitry Lyalin's Applications for Windows Phone 7

Windows Phone 7

ApplicationBar Errors–Dynamically adding buttons

Recently I ran into two errors around code I was writing to dynamically add buttons into the ApplicationBar. My application is targeted to Windows Phone 7.0 (NoDo) but my development tools are Mango Beta 2.

What I was trying to accomplish is add a ApplicationBarIconButton into my Main.xaml’s (XAML created) ApplicationBar, sounds simple right?

To do this I created the button at runtime and tried to add it into the “buttons” collection by calling .Add(). When I did this got the error below:

System.ArgumentException was unhandled
  Message=This list does not support that type

  StackTrace:
      at Microsoft.Phone.Shell.ApplicationBarItemList`1.System.Collections.IList.Add(Object value)

I thought maybe when this code executed mattered, so I tried it from both the Constructor of Main.xaml and the Loaded event, didn’t make a difference.

Next after asking around my peers and playing around with the API we discovered that NOT setting the Click handler until AFTER I add the button into the ApplicationBar avoided this error, crazy but it works.

Here what works:

Uri shareUriButton = new Uri("Images/Buttons/appbar.share.rest.png", UriKind.Relative);

ApplicationBarIconButton shareButton = new ApplicationBarIconButton(shareUriButton);
shareButton.Text = "Share";
shareButton.IsEnabled = true;
this.ApplicationBar.Buttons.Add(shareButton);
shareButton.Click += new EventHandler(buttonShare_Click);

Even though this resolved my immediate problem I decided to play around with the API some more and tried to add a button without setting the IconUri first and got another vague error, easy enough to avoid but I wanted it to be a searchable issue, here is the error you get:

System.ArgumentNullException was unhandled
Message=Cannot clear the icon while in a list
Parameter name: value

  StackTrace:
       at Microsoft.Phone.Shell.ApplicationBarItemContainer.set_IconUri(Uri value)
       at Microsoft.Phone.Shell.ApplicationBarIconButtonContainer.UpdateProperties(Object sender, BoolEventArgs args)
       at Microsoft.Phone.Shell.ApplicationBarItemContainer.BeginAttachToAppBar()
       at Microsoft.Phone.Shell.ApplicationBarIconButtonContainer.BeginAttachToAppBar()
       at Microsoft.Phone.Shell.ApplicationBarItemList`1.Insert(Int32 index, IApplicationBarIconButton item)
       at Microsoft.Phone.Shell.ApplicationBarItemList`1.Add(IApplicationBarIconButton item)
       at Microsoft.Phone.Shell.ApplicationBarItemList`1.System.Collections.IList.Add(Object value)

Recap

So to recap when adding an ApplicationBarIconButton into the ApplicationBar make sure to:

  • Specify a valid IconUri BEFORE you add the button into the ApplicationBar’s buttons collection
  • Set the “Click” event handler AFTER you add it to the ApplicationBar’s buttons collection

Hope this helps someone. I don’t know if this is an old issue or a new issue, this could perhaps even be fixed in the final version of the Mango developers tools but if not then your answer how to work around the problem is above.

Update (8.31.2011)

MSDN has been updated thanks to our talented technical writer contractor Nicole McAllister, so check out the official post that confirms the above solution to the problem:

http://msdn.microsoft.com/en-us/library/hh394044(v=VS.92).aspx

Nicole didn’t just update MSDN, but it was her idea that led to the solution originally! So once again huge thanks for Nicole for helping me backfill MSDN for various missing pieces of documentation.


TWiT v1.8 Released to Marketplace

SplashScreenImage

I am once again happy to report that the TWiT app for Windows Phone 7 has been updated and is now available in the Marketplace in v1.8.

(v1.7 was also released one day before v1.8 therefore this blog post covers the  release notes for both versions)

The goal of these rapid release is to focus on bug fixes, performance improvements and overall application stability. After perhaps one or two more release I will be shifting my focus almost exclusively to the Mango (Windows Phone 7.5) version of the app to be released later this fall (4th quarter, 2011)

v1.7 & v1.8 Changes/Fixes include:

  • During audio/video playback I have added back an improved version of the slider for seeking to a specific position with the podcast (by popular demand)
  • Some people were experiencing problems playing video versions of TWiT shows which should now be mostly resolved (see note below for some more detail)
  • Included some performance improvements that should make certain parts of the application “snappier” and allow for quicker resume after tombstoning
  • Added new TWiT network show “Ham Nation” and a few other tweaks/fixes to the show data
  • Removed the last Panorama tab “More” and instead added a Panorama-wide “…” menu with most of the same options
  • Added a “Rate this App” link in the “…” Panorama Menu (Please rate this app and support us!)
  • Removed “Featured Shows” feature as it was not used often (based on user feedback)
  • Live playback now works on app resume from tombstoning (possibly broken in v1.6)
  • New splash screen graphic (as displayed above)
  • Various other bug fixes in various parts of the app including the media player
  • Fixed the spelling of “Calendar”

Video playback notes:

As stated above video playback has had some bug fixes but there might still be issues caused by things such as:

  • Problems with your phones connection to the Internet. Video playback requires a more stable and stronger connection then audio which tends to work even during a weak connection to the Internet
  • New TWiT shows often get published with the audio content first and the video isn’t available right away, so you cannot play the video and will get an error if you try. During those times playing audio will likely work
  • Live video feed is still not available to me in the platform

Technical Notes #WP7DEV:

  • Behind the scenes im also happy to be moving the application to AgFx caching framework for all data loading/caching. This is an EXCELLENT framework for Windows Phone 7 and makes working in a tombstoning oriented data model much easier
  • I have updated to the latest version of the Microsoft Ad Control as they released various bug fixes and improvements
  • I am using the Mango version of the developer tools to makes changes to this app in 7.0 mode, which is working great

Silverlight User Group Presentation: Building TWiT for WP7 (slides)

image

I want to thank everyone who attended my presentation last night at the Silverlight User Group where I talked about my experience building TWiT for Windows Phone 7, and how you can learn from my experience.

The presentation didn’t have code demos but instead focused on learning how to take an application from an idea all the way through being published and really hope everyone enjoyed it.

Channel9 Presentation

Update: This presentation was recorded by my buddy Peter Laudati and is now up on Channel9! Enjoy the presentation if you missed it and send me your feedback.

http://channel9.msdn.com/posts/Developing-TWiTtv-for-Windows-Phone-7-From-Concept-to-Marketplace

Slides

http://cid-c6b45be43711d8b8.office-df.live.com/view.aspx/Public/Silverlight^_UG^_BuildingTWiTApp^_WP7^_Start-To-End.pptx

(Special thanks to @WayneHRichmond for hosting the event and taking the picture above)


Dmitry Lyalin’s WP7 Sample Application – Now Live!

For a longtime now I have been wanting to put together a sample application for Windows Phone 7 that will be a single place for all my sample code that can be shared with the world. Today I’m happy to announce the first step in this process as I have published this project with its first sample.

Get the source code and details here:

http://lyalinsamples.codeplex.com/

The first sample is all about Integrating with the Music and Video hub, key features include:

  • Create entries in the Music and Video hub categories including: New, History or Now Playing items
  • Creates the Image for Music and Video hub categories dynamically using UserControls (by passing them through WriteableBitmap)
  • Demonstrates how to capture parameters passed back from Music and Video hub when the application is resumed and how to load your "player" to resume where the user left of

Along with these features I include a list of known issues (platform limitations in v1) so be sure to go to the link and read all about it. I look forward to see people learn from this sample and hear your feedback so do post back all suggestions, corrections, etc.


App reviews of WP7 applications

image

One of the things missing right now is an easy way for a developer to see a list of all the reviews for their WP7 Marketplace application(s).

Luckily a guy named Tom Verhoeff has created a tool to do this using your Application ID and rendered in Silverlight, Check it out: http://wp7reviews.tomverhoeff.com/

Here is the review list for my TWiT app for WP7, worked great, thanks Tom!


TWiT for WP7 v1.0 is LIVE

image

I am VERY happy, very proud to announce that TWiT (v1.0) for Windows Phone 7 has been published to the marketplace.

Thank you folks, for your support

Big THANK YOU to my wife, for her patience during all those lost nights and weekends I spent working on this since July

Big THANK YOU to my testers, you know who you are, your feedback was invaluable.

Big THANK YOU to the local DPE team who supported me, thank you!

Big THANK YOU to TWiT network for your support and encouragement throughout this large undertaking

Application Details

Description: “TWiT for Windows Phone 7 brings you all the networks netcast content to your mobile device in an easy to use Media Hub. Listen or watch great shows on demand such as This Week In Tech, Windows Weekly, Security Now, This Week In Google and much more (28 shows to choose from and growing)”

Zune Marketplace Link: http://bit.ly/evwZjh
(You’ll need the free Zune.net client on your machine to access this link)

Don’t know know what TWiT is? click here to learn all about this amazing netcast network! (Video / audio podcasts of 28 shows)

Upcoming releases

Patch v1.1 (Pending Marketplace Approval)

  • Minor bug exists in v1.0 where under certain conditions the Cache will store the wrong episodes for a show and not update from RSS feed, this has been fixed
  • Application will be moved for Entertainment category (instead of Music and Video)
  • A few other Misc. fixes

This is already submitted for marketplace approval and I hope to have it out next week (Week of 11/29).

Patch v1.2 (Tentative)

  • Adding Live audio feed!
  • More Misc. bug fixes

Bugs? Suggestions?

Please be sure to report all suggestions and issues to me by emailing twitwp7@lyalin.com.


Windows Phone Toolkit R2 (November)

Microsoft’s David Anson of the Windows Phone 7 Toolkit group is proud to announce the second release of the Toolkit. This update brings with it additional controls and transition effects that will make building stunning WP7 Metro applications even easier.

New Features Summary:

  • Listpicker control
  • LongListSelector control
  • TransitionFrame
  • AutoCompleteBox

imageimageimageimage