Archive | Windows Phone RSS feed for this section

Application Insight for Windows Store and Windows Phone apps

21 Nov

In the launch keynote of Visual Studio 2013, Brian Harry announced and demoed a new service called Application Insights.

The service is available through Visual Studio Online and “collects, processes and presents a wide variety of telemetry including performance, usage, availability, exception, crash, environment, log and developer-supplied data from all components of a modern application – including clients (devices and browser), servers, databases and services.”

With Application Insights it is possible to gain full insight into your Windows Store and Windows Phone applications; how does the user actually use your app, which features are used the most or least, are there any performance issues and so on. All of this will be presented nicely in a dashboard that can easily be customized to your exact needs directly in Visual Studio Online.

Currently the service is available as limited preview and you can sign up from Visual Studio Online:
https://YOURALIAS.visualstudio.com/_appanalytics/_analyticssignup

Bluefragments have been part of the TAP program since early this year and have followed Tofino become what it is today (truly amazing work by some passionate guys!). Looking forward to integrate Application Insights into our Windows Phone and Windows Store apps.

// thomas

The parameter is incorrect

17 Dec

For the last couple of months we have been working on some different Windows Phone projects. Yesterday we ran into an exception in one of our projects. Sometimes when we navigated into a specific page we got an argument exception “The parameter is incorrect”. The exception was inconsistent but we got it more often when debugging compared to when we ran our project in release mode.

2012-12-17_013042

First step was of course to enable as much debugging info as possible which resulted in this StackTrace:

at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
at System.Windows.PresentationFrameworkCollection`1.Add(UIElement value)
at System.Windows.Controls.ItemsControl.AddVisualChild(Int32 index, DependencyObject container, Boolean needPrepareContainer)
at System.Windows.Controls.ItemsControl.AddContainers()
at System.Windows.Controls.ItemsControl.RecreateVisualChildren(IntPtr unmanagedObj)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.Phone.Controls.Pivot.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.Phone.Controls.PhoneApplicationFrame.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

The page was actually pretty simple – a Pivot control with 4 items each containing a usercontrol. So with the StackTrace in mind we looked for some dynamically sized controls within our usercontrols . First of all we tried to change the Pivot control with a Panorama control – still got the exception. So we had to go through our code and line by line we removed content – still got the exception. In the end we had removed all the content inside our usercontrols and the page was stripped down to contain only the most necessary properties. Still got the exception.

In the end I stumbled upon the naming of our usercontrols – not in the page but the x:name within the usercontrol itself. Some of the usercontrols had been giving names that was used as part of some animation. What caught my eye was that two of the usercontrols got the same x:name. I tried to change one of the names and boom! Problem solved.

So to take this little issue to the test I created a small sample demonstrating the issue. The sample automatically navigates from one page to another and back until the exception is through (takes about 2-5 minutes).

The issue is on both Windows Phone SDK 7.1 and 8.0.

// thomas

Resource Dictionary for Windows Phone

6 Nov

One of the missing templates in the Windows Phone SDK is Resource Dictionaries. If you work with styles and resource dictionaries, the missing template is a big thing.

Worry no more! I have created the template you need!

You can get them ItemTemplate from my SkyDrive and install it in your ItemTemplate folder, typically located here:
C:\Users\[USERNAME]\Documents\Visual Studio 2012\Templates\ItemTemplates\Visual C#\Windows Phone\1033

// thomas

Installation Folder in Windows Phone 8

2 Nov

The installation folders for Windows Phone apps (also known as appdata) are read-only and reading data from files in the folders hasn’t always been the best experience. We have been able to use GetResourceStream to stream files from the appdata folder and DataContext to work with a local database.

With Windows Phone 8 we got some improvements. We got a new property of the current package called InstalledLocation. It returns the installation folder as a StorageFolder and using the Path property it’s possible to get the full path of the installation folder. Using the StorageFolder we are able to work with the files in the appdata folder.

The content of the appdata folder can easily be accessed using the appdata or ms-appx URI scheme names. Although the two schemes point to the same location, there is an important difference in the usage of the two. Use “ms-appx:///” for accessing the appdata folder with APIs that are part of the new Windows Phone Runtime (part of the Windows namespace). In all other APIs use “appdata:/”.

If we want to get a file asynchronisly we can use Windows.Storage.StorageFile.GetFileFromApplicationUriAsync
to access the file. As the API is part of the new Windows Phone Runtime, it is required we use “ms-appx:///” to access our file:

If we just want to specify an Uri we can use “appdata:/”:

// thomas

Where is the Skype app for Windows Phone?

1 Nov

Yesterday I wrote a blog post asking about the missing Build app for Windows 8. Rumors says the app is built but failed certification hence not available for the attendees – it has not been confirmed by Microsoft!

Until today Nokia Lumia 800 have been my primary phone. Today I’m taking my new Nokia Lumia 920 (thank you Microsoft and Nokia!) and doing it the only true way – making it my primary phone. It’s a big phone but the technical features are awesome and combined with Windows Phone 8 I expect a great experience. I have customized it (making it my own) and I already love some of the new features – especially the “Rooms” feature – it’s really communication made easy!

For the last couple of months I have been addicted to Skype. With the new Skype app for Windows 8 my expectations for the running the app on a Windows Phone 8 device was pretty high. I have been running Skype on my Lumia 800 but it’s almost useless without a front faced camera. Open the store, searching for Skype and gets several results – but no Skype app?! Frustration kicking in! Searching the internet to get an answer.

Turns out that Skype have built a new app from the ground up for Windows Phone 8 supporting some of the new awesome features available in the Windows 8 app and using the new features available in Windows Phone 8. Skype have announced that it is soon-to-be available. Read the full story and get an overview of the new features at their blog or take a look at this video.

// thomas

Using the ProgressIndicator in the SystemTray in Windows Phone

30 Oct

In many cases Windows Phone developers implement and place their own progress indicators in Windows Phone apps.

When you add a new PhoneApplicationPage to the app it will by default set the IsVisible property on the SystemTray to true on the page. This is done in XAML by default in the VS template.

The system tray can also be accessed from codebehind. It is possible to set properties like IsVisible during the Loaded or OnNavigatedTo event wired up in the codebehind. It’s not possible to set the system tray as part of the pages constructor.

The system tray got a build-in progress indicator (ProgressIndicator) located in the top of the system tray. The progress indicator on the system tray can be used in the application to show progress in a uniformed way. However to be able to use the progress indicator you first need to instantiate it.

Once it’s instantiated you can set all the regular properties like Opacity and Color on it and it’s possible to reuse this “default” progress indicator in a very easy manner. It won’t take long to make this a bit more generic which you most likely would do if you’re building an app with more than one or two pages.

// thomas

Tiles and Notifications in Windows Phone 8

30 Oct

The tile is the front door to your app. A nice tile can mean the world to your app and the usage of it. Some developers/companies manage to use this opportunity and make great static and living tiles.

New Tile Sizes

With Windows Phone 8 we have a new set of sizes and templates available for our tiles. The user have the opportunity to customize the size of the tile based on three sizes: small, medium and wide. It is required to implement small and medium sizes tiles but wide is optional. The supported sizes is set using the redesigned Manifest file.


Screenshot from Visual Studio 2012

Windows Phone 8 supports multi resolutions. Tile icons (and app icons) are defined for WXGA (768×1280) and are automatically scaled to work for WVGA and 720p.

New Templates

Windows Phone 8 supports three templates: flip, iconic and cycle.

It is not possible to update the template for the default tile programmatically – it will require and update of the app. The template for secondary tiles can be updated programmatically. Furthermore it is not possible to know which tile size the user has pinned to the start screen so all properties should be set for the supported tile sizes.

Flip Template

The flip tile template flips from front to back and support all three available sizes: small, medium and wide. The properties for the flip tile template is available using the FlipTileData class.


Image is taken from the SDK help file.

The small flip tile is 159×159 pixels and only allows a small background image (SmallBackgroundImage) and a counter (Count).

The medium flip tile is 336×336 pixels and allows a background image (BackgroundImage), title (Title) and counter (Count) on one size and a backbackground image (BackBackgroundImage), back title (BackTitle) and back content (BackContent) on the other side.

The wide flip tile is 691×336 pixels and allows a background image (WideBackgroundImage), title (Title) and counter (Count) on one size and a backbackground image (WideBackBackgroundImage), back title (BackTitle) and back content (WideBackContent) on the other side.

Iconic Template

The iconic tile template displays an image in the center of the tile and support all three available sizes: small, medium and wide. The properties for the iconic tile template is available using the IconicTileData class.


Image is taken from the SDK help file.

The small iconic tile is 159×159 pixels and only allows a small icon image (SmallIconImage) and a counter (Count). The icon size is 110×110 pixels.

The medium iconic tile is 336×336 pixels and allows an icon image (IconImage), title (Title), background (BackgroundColor) and counter (Count). The icon size is 202×202 pixels.

The wide iconic tile is 691×336 pixels and allows a small icon image (SmallIconImage), title (Title), counter (Count) and three lines of content (WideContent1, WideContent2, WideContent3). The icon size is the same as the small iconic tile.

Cycle Template

The cycle tile template cycles between 1 and 9 images and support all three available sizes: small, medium and wide. The properties for the cycle tile template is available using the CycleTileData class.


Image is taken from the SDK help file.

The small cycle iconic tile is 159×159 pixels and only allows a small background image (SmallBackgroundImage) and a counter (Count).

The medium cycle tile is 336×336 pixels and allows a title (Title), counter (Count) and between 1 and 9 background images (CycleImage1, CycleImage2…).

The wide cycle tile is 691×336 pixels and allows the same properties as the medium cycle tile.

// thomas

Follow

Get every new post delivered to your Inbox.

Join 1,413 other followers