Dictionary Initializers - Real LIfe Usage

Topics: C# Language Design, General
Dec 8, 2014 at 8:46 AM

Just thought you might want to know how the new C# 6 features are being used in real-life.

Perspex (https://github.com/grokys/Perspex) is a project I'm working on that aims to be a cross-platform WPF-like UI framework (big idea, I know).

I'm using dictionary initializers to allow setting attached properties and binding in object initializers:


It's a super-useful feature! The only way it could be improved would be by allowing a generic subscript operator to provide type-checking, which is something you might consider for the next C# version!

Hope you find it interesting.
Dec 8, 2014 at 9:05 PM
I particularly like what I've seen. WPF looks abandoned or in mantrnience mode and the API is quite old fashioned.

I will focus more in c# and forget about XAML. C# is more expressive and object initializers, collection initializers and now dictionary initializers should be enough to represent the tree structure of a UI.

I hope you the best luck, tell me when is production ready.
Dec 9, 2014 at 4:33 PM
That project is very compelling. The business layers of applications i have written would greatly benefit from data binding and attached properties that are manageable from code as you have shown.
Dec 9, 2014 at 7:52 PM
Agree; this is a cool project. Best of luck to you with it! I'd love to see a modern, cross-platform UI framework for .NET that isn't behind a huge paywall and MS has given every indication that it has no plans to do anything here.