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
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;
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
at Microsoft.Phone.Shell.ApplicationBarItemContainer.set_IconUri(Uri value)
at Microsoft.Phone.Shell.ApplicationBarIconButtonContainer.UpdateProperties(Object sender, BoolEventArgs args)
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)
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.
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:
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.
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
During the recent TechEd 2011 US event there was a pretty cool image being shown off where a bunch of WP7 application Live Tiles were featured in action.
My TWiT app was in that list and damn this wall looked great, check out a screenshot of it below and see if you can spot the TWiT app :).
Live Tile Wall – TechEd US 2011
I am very happy to announce the release of Paul Thurrott’s official app for Windows Phone 7 which I built for Penton Media. The app is live in the Marketplace as of Saturday and can be yours today for $1.99, simply search for “Paul Thurrott” to find it.
Note: all proceeds go to Penton Media who hired me to build this application
v1.0 Features include:
- Read most recent articles from WinSupersite, WinSupersite Blog and Windows IT Pro
- Read the latest posts to his Windows Phone blog
- See Exclusive content generated for his mobile apps (interesting short-form posts and/or links, similar to Twitter)
- Listen to his Windows Weekly Podcast from TWiT
While I don’t control this application (it is built for Penton Media) I am optimistic that its features will continue to expand in the future and I for one have many ideas.
Please send all feedback, questions and bugs to Penton directly by emailing email@example.com
So if you’re a fan of Paul or simply want a great source of news around the Microsoft technology world then go buy the app from Marketplace!
My TWiT Windows Phone 7 application has a feature that many people (including myself) like which shows the shows which most recently published their new episodes in the app tile and auto updates every hour.
Today I am happy to announce a small enhancement to this Tile feature which changes how many shows it can display by double the number to four.
Here is what you should now see:
I really hope everyone likes this change and remember you can make suggestion and vote on other peoples suggestions over in the new UserVoice site I setup for the TWiT app, found here: http://twitwp7.uservoice.com/
Thank you as always for everyone’s support.
While the TWiT App for Windows Phone 7 is built by one person, its feature priority truly has been in the hands of the users since the start. Thanks to numerous friend who tested the application in its early stages, my own use of the app on an almost daily basis and the emails I’ve received over the last year has all impacted what features and bugs I worked on.
Recently though I decided to setup a more formal way for people to submit feedback and after some research into my options UserVoice seems to be the best approach. So without further ado here is the official TWiT app UserVoice forum: https://twitwp7.uservoice.com
I look forward to see how well this works and learn even more about what features YOU the users want and what bugs drive you crazy. Your voice is heard by me and I strive to make this app better for everyone.
I am happy to announce that TWiT update v1.6 has been approved for release and is now being published in the Marketplace.
This releases fixes some issues introduced by update v1.5, below is a list of things that I fixed.
Summary of Fixes
- Live Audio Playback Fixed: Once again Live Audio playback should work
- Episode List Loading-time Improvements: Fixed an issue where the show episode page would load multiple times behind the scenes due to a bug causing a delay in loading the episodes list. While this does not fix all loading issues with the episodes list it should at least make things better
- Error Information Improvements: When an error occurs and the user agrees to send me the “Exception” detail for diagnosis it will include the version number of the app; this will greatly help me debug future issues
- Other Fixes: Behind the scenes I have fixed some other issues that could at times cause errors so the app should be more stable
Known Issues in v1.6
Unfortunately not every issues is resolved by update 1.6, there are still issues with as listed below:
- Playing back episodes that were in-progress when you had version 1.4 or earlier installed – I cannot fix this but in the future hope to avoid it from happening again
- The word “Calendar” is misspelled on the Live Audio panorama page – I will fix this in version v1.7
- Episode list in the show page is still a bit slow to load and laggy to use – I will attempt to improve this in version v1.7 and really hope to fix it this time
- Some new shows are still not correctly listed. This can even cause playback issues so I’m looking to address this in v1.7
- Some shows names have been changed and this is not properly updated – Should be fixed in version 1.7
- Paul Thurrott’s Twitter is not properly listed in the application – Should be fixed in version 1.7
- A few other crashes that happen occasionally it seems though I have been unable to reproduce all of them.(please keep those error reports coming and add detail when possible)
What about a “Paid Version” without Ads?
Also I have heard “loud and clear” that people want an ad-free paid version of the app. I hope to release this soon once a few more bugs are resolved.
This has not happened yet for one simple reason; I just don’t believe in charging people for an application until I’m happy that all the core features work as expected. I do appreciate everyone’s patience on this matter and I’m working hard to get this ready for you.
Thanks again for everyone who reported issues, please continue to send me errors and feedback as I do read every email I get, though I cannot always respond personally.