Tag Archives: Silverlight

WPF/Silverlight vs. Jupiter Quirks – Opacity

Have you noticed the difference in how the Opacity property is handled by child elements the Windows 8 XAML vs. Silverlight or WPF?


Windows 8 XAML (Jupiter):

Continue reading

Tagged , , , , ,

BindableApplicationBar for Windows Phone – Now On NuGet

With some help from Shawn Oster – I had the BindableApplicationBar published on NuGet. Now there is no need to search for sources or assemblies on CodePlex if you need to quickly create an MVVM-friendly ApplicationBar. Just right-click on your project and select “Manage NuGet Packages…”


Then search for appbar, install it and voila! You can now use the BindableApplicationBar.

Continue reading

Tagged , , , , , , ,

Asynchronous UI development in WinRT, Silverlight, Windows Phone & WPF with async/await keywords of C# 5.0

This is a reblog of my article from http://labs.vectorform.com

C# 5.0 comes with the new async/await keywords that make asynchronous code easier to write, read and maintain. This is very nice if you have properly declared methods that support this pattern and Windows Runtime (or WinRT – the API for Windows 8 Metro Style Apps) comes with a lot of these methods for long running tasks or ones of nondeterministic duration – especially in I/O or web calls. It is however completely lacking in support for asynchronous UI development, even though one of the main goals of these new keywords was support for responsive UI.

Interactive coding often introduces the need to start an operation, like an animation or a dialog box and then wait for an event before switching the state of the UI, for example: running another animation or removing a dialog. Reading this article you will learn how to do it better using the upcoming features of C# 5.0, regardless of whether you develop in WinRT, Silverlight, WPF, Windows Forms or even Web Forms. The source code that comes with this article contains a library you can use to cut the amount of code you need to write by half!

Continue reading

Tagged , , , , , ,

Another XamlParseException – “Unknown parser error: Scanner 2147500037”

Yesterday I got one of those XamlParseExceptions that do not seem to make sense. It happened after I moved most of the code from my Windows Phone application to a class library. In fact the only things I left in the application project were the App class, the Properties folder and some resources that differentiate different applications that share the library. If you want to do something similar – you can have your MainPage class defined in a library and just need to update the WMAppManifest.xml to point at its new location, eg: NavigationPage=”MyClassLibrary;component/Pages/MainPage.xaml”.

Everything worked fine except for this bit:

        Binding="{Binding PageNumber}">
                    <DoubleAnimation ...

It kept throwing an exception:

Continue reading

Tagged , , ,

GridSplitters – Part 3: Limiting the Range of a GridSplitter

Sometimes I look at what people search for when they hit my blog and see some trending questions that don’t seem to have easily findable answers. This one seems to be related to how to set the limit for moving a GridSplitter… Well – you don’t actually touch the GridSplitter to do that. You need to modify your RowDefinition or ColumnDefinition. In a similar way that you can define MinWidth/MaxWidth/MinHeight/MaxHeight on any FrameworkElement – you can do MinWidth/MaxWidth on a ColumnDefinition and MinHeight/MaxHeight on a RowDefinition. By setting these – you limit how much the GridSplitter will be able to resize them. I actually take these into account in my SimpleGridSplitter implementation, so if you have lots of rows or columns in your WPF app – you can use that one. Silverlight works fine there with its own GridSplitter.

Continue reading

Tagged , , , , ,

Vibration Behaviors for Windows Phone – Part 1

So I got my wife an HTC Titan for Christmas and I loved the way it vibrates compared to my Focus. It just feels nice with much lower frequency, while the vibrations on the Focus are a bit like an electric shock. This got me thinking that it would be nice to have the same sort of haptic feedback you get on the 3 hardware buttons on the regular Silverlight buttons. While you could just handle the touch events on every button you choose – it is a lot of code that just gets duplicated all over your app and it is hard to update it globally – e.g. if you want to allow the user to switch it off everywhere or automatically preconfigure it when the app first runs based on the device used. The best solution for it seems to be to create a Behavior that you can easily attach to any button, so that is what I had set off to create.

Continue reading

Tagged , , , ,

“Moving GridSplitter with code behind” is not the right question

Occasionally I see people searching for how to move the GridSplitter with code behind…
This is not the right question. You can in theory move the GridSplitter itself with code – it is just a control that is hosted in a Grid (if used correctly), so by adjusting the Margins or ~Alignment properties – you can change its position, but what you really want is to resize the associated column/row – which will also incidentally move the GridSplitter.

Continue reading

Tagged , , , , ,

ProgressBar and PerformanceProgressBar performance issues with IsIndeterminate = true


The gist of this post is that if you use the ProgressBar that comes out of the box with the Windows Phone tools or use the PerformanceProgressBar that comes in the Silverlight Toolkit – you should always set its IsIndeterminate property back to false when you are done displaying it to not use up the CPU and drain the battery.

If you are using an older version of the Silverlight Toolkit – you should update to the latest one, because some of the older ones have a bug that will cause the PerformanceProgressBar to use up the CPU cycles even once you switch IsIndeterminate back to false.

Ideally – you should just use the non-Silverlight-rendered, OS-managed ProgressIndicator like this:

        IsVisible="{Binding IsWaitingForAnOperationToComplete}"
        IsIndeterminate="True" />

Continue reading

Tagged , , , , ,

Fixing WPF GridSplitter


While working on a WPF tool for work – I was creating ColumnDefinitions in a Grid dynamically (with code) and also dynamically adding GridSplitters to allow users (myself) to resize the columns. Well, it all worked OK, except for the many times that it did not. I thought I made some mistake when creating these GridSplitters, but it seemed like some other people had similar problems with GridSplitters, namely sometimes – they would not work when used with a mouse. When you drag a splitter – it would spring back to original position and stop being dragged or it would jump to some other random (?) position – maybe resizing one of the columns to 0. I tried to fix it by configuring the GridSplitters in different ways – in code behind, between Begin/EndInit blocks, in XAML – nothing helped. I simplified the repro and it seemed to be happening more often when the Grid had many GridSplitters. I checked the same layout in Silverlight and it worked without any problems (well, except for needing to reference another library since GridSplitters are not available in Silverlight using the basic Visual Studio application template). This seemed to indicate the WPF implementation is just somehow broken and it won’t work. Well then I guess I should implement the control myself – how hard would it be? – handle some mouse and keyboard events and resize an associated ColumnDefinition or RowDefinition…

The Fix – SimpleGridSplitter

Continue reading

Tagged , , , , ,

BindableApplicationBar RC1 + Windows Phone Prism Application Template

Today marks the RC1 release of the BindableApplicationBar. I have spent some time today to do some StyleCop and documentation cleanup and it seems ready. You can grab a zip file with the binary directly from here.

Another part of what I have been working on today is a Windows Phone application template. I have spent too many times working on boilerplate code and cleaning up the default Windows Phone Application template and decided to create something that will get me up to speed faster every time I want to create a phone app. It is called Windows Phone Prism Application and is available as a Visual Studio project template here.

Continue reading

Tagged , , , , , , , , , , , ,