Tag Archives: XAML

High performance XAML charts… using Win2D

ScreenCap

Hi! 

Over the last couple of years I got quite a few questions about the Chart control that I ported from Silverlight Toolkit and shared in WinRT XAML Toolkit. Mostly about performance and customizing the design. Well, the update performance is something I recently tweaked a little bit by removing some of the animations, but really – the control is fairly complicated and uses lots of XAML to enable customizing all the different parts and so it works best for static charts with just a few data points. I haven’t actually used the control much, so every time I get asked how to change anything in it – I have to investigate it myself and often get lost in all that code.

Continue reading

Advertisements
Tagged , , ,

Exiting a WPF app

So this is a developing story. I’m working on a WPF app again these days and how do you exit a WPF when you’re done running? Normally a user or your code might close the main/last window and the app would exit, but what else can you do?

  • Application.Current.Shutdown() is what I’ve been trying and it wouldn’t work. Why? It turns out – it needs to be invoked on the dispatcher thread… ugh. Anyways – it seems to be THE WPF way, so I’m sticking with it:
    Application.Current.Dispatcher.Invoke(Application.Current.Shutdown);
  • Environment.Exit(0) should work WPF or not.
  • Process.GetCurrentProcess().Kill() is a rather sudden, but sure way to kill your own process.
Tagged ,

Cannot deserialize XBF metadata type list as NullableBoolToBoolConverter was not found in namespace

I was trying to get something working last night and kept hitting this exception when my app was trying to InitializeComponent() at one point.

CannotDeserializeXbf

First-chance exception at 0x750D1D4D in App1.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x037CDDC0. HRESULT:0x802B000A The text associated with this error code could not be found.

WinRT information: Windows.UI.Xaml.Markup.XamlParseException: The text associated with this error code could not be found.

Cannot deserialize XBF metadata type list as ‘NullableBoolToBoolConverter’ was not found in namespace ‘WinRTXamlToolkit.Converters’. [Line: 0 Position: 0]

at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)

All this seemed complete and utter bogus, since NullableBoolToBoolConverter was obviously there and it would work perfectly well in other projects or solution configurations, so let’s look what was happening.

  • NullableBoolToBoolConverter is defined in WinRTXamlToolkit – a .NET Class Library that I’d typically build as Any CPU. It has a ton of controls, converters and other such goodies and of course it typically works just fine.
  • NullableBoolToBoolConverter is used in WinRTXamlToolkit.Debugging – another .NET Class Library that has an in-app XAML visual tree debugger tool – essentially a TreeView control that displays information about the visual tree of your application – hierarchy of UI elements and their properties. The main control in the library uses NullableBoolToBoolConverter and it normally works when used from a .NET Windows Store app.
  • The problem is that WinRTXamlToolkit.Debugging is a .NET Class Library and there is still a small, but important range of WinRT XAML apps written in C++ that can’t use it, so I created a managed WinRT component library – WinRTXamlToolkit.Debugging.WinRTProxy that C++/CX projects can reference. It’s fairly straightforward to do it seems – you just create a proxy class in the WinRT Component library that has methods that invoke methods in the referenced class library (WinRTXamlToolkit.Debugging) and now you can use it from C++/CX. I prefer to keep WinRTXamlToolkit.Debugging a regular .NET class library because WinRT Components have limitations that would limit the APIs I currently have in WinRTXamlToolkit.Debugging. The proxy methods in the WinRTProxy library still have these limitations, but at least I can use it from a native app. The problem is that it wouldn’t work and keep giving me that exception, so what’s up?

It turns out WinRT XAML generates these files – XamlTypeInfo.g.cs that allow the XAML parser to see the types it can use and I noticed that file was missing in the obj folder of WinRTXamlToolkit.Debugging.WinRTProxy. To get it to generate I simply added one empty UserControl to WinRTXamlToolkit.Debugging.WinRTProxy and everything started working fine! Weird but it works. So now I’m left with figuring out how to wrap this all as a NuGet component with native versions of the .NET libraries, since I’ve previously only packaged Any CPU binaries…

Tagged , , , , , ,

The Elusive ArgumentException in a List Control…

The last week or so I have been struggling with a bug that was keeping me away from updating WinRT XAML Toolkit. After adding an ItemTemplateSelector for my custom ListBox – I started getting ArgumentExceptions with a vague “Value does not fall within the expected range.” message and of course none of my code on the stack. At first I thought my custom ListBox subclass was causing some problems that the platform couldn’t handle, but then after replacing it with a regular ListBox it kept happening. Finally I noticed that replacing the DataTemplate I was using with another one that was simpler stopped the exception. Then I modified that template to look the same as the one I wanted to use – and it still worked fine! It took me probably 2 minutes of playing spot the difference to notice that the bad template had a DataTemplate inside of the DataTemplate! That obviously doesn’t generate a good list item! Hopefully this post helps someone working with a ListBox, ListView or GridView and getting these ArgumentExceptions that crash the app with no details of where they come from…

Tagged ,

The five minute gauge control for WinRT/XAML

Wow, gauge controls are pretty easy to implement. Why would anyone pay for one? 🙂

This one took me literally 5 minutes. True, it is just a UserControl and it only shows 0-360 values I needed to debug some compass code, but it’s easy to build on it so I thought I’d share it since all my other blog post ideas need quite a bit more time than 5 minutes… 🙂

gauges

Continue reading

Tagged , , , ,

Layout and Formatting with Windows 8 XAML Development

When designing a user experience, one of the first things you need to figure out is where to position things on the screen, how they should flow when the content changes, and what shape or color they should be. This article is about the tools you have at your disposal with Windows 8 XAML to control layout and formatting on this exciting new platform.

Read more on Safari Books Online

Tagged , ,

Windows 8 Development with XAML and C# – New and Missing Controls

Although the Windows 8 XAML platform brings back a lot of the controls that exist in WPF and Silverlight, and adds some completely new ones, there are some controls that you might find missing and wonder what to do. In this article we cover a list of some of these controls, along with some suggested ways to cope with their loss.

Read more on Safari Books Online

Tagged , , ,

Windows 8 Development with XAML and C# – Controls

User interfaces are usually composed of reusable controls that encapsulate the logic for rendering the view, taking input and manipulating data. Windows 8 XAML has a wide range of such controls and this is a terse overview of these controls that you can use to check if you know them all.

Read more on Safari Books Online

Tagged , , ,

Windows 8 Development with XAML and C# – Introduction

Why develop for Windows 8?

Windows 8 is a platform with high potential. Based on the trends, Windows 8 is expected to run on half a billion devices within a year or two. Since previous versions of Windows are already running on over a billion machines today, and upgrading from any existing version will cost a mere $15 to $40 – this is just a deal that is hard to miss. Windows 8 is every bit as stable and incrementally improved in its desktop flavor, but it also has a new and exciting part in its touch-centric start screen and app store support.

Read more on Safari Books Online

Tagged , , ,

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?

Silverlight/WPF:

Windows 8 XAML (Jupiter):

Continue reading

Tagged , , , , ,