3 ms·
This is crazy talk. Yes Microsoft momentarily offered a browser plugin called Silverlight and it happened to use some WPF stuff but don't believe for a moment t
by revelation 9y ago
This is crazy talk. Yes Microsoft momentarily offered a browser plugin called Silverlight and it happened to use some WPF stuff but don't believe for a moment that this somehow means they wanted to make XAML the better HTML or have any sort of adoption beyond the Windows ecosystem. It was pretty much just a somewhat enhanced language for describing a scene graph because nobody wanted the code generation of the Forms days.
They strictly kept any sort of code or logic out of XAML, annoyingly so to the point where you are writing converter classes to negate an expression. Compare that with the mishmash that is React.
- int_19h 9y ago> They strictly kept any sort of code or logic out of XAML, annoyingly so to the point where you are writing converter classes to negate an expression For what it's worth, WPF does provide sufficient flexibility that it's possible to add support for expression-driven converters using markup extensions and an MSBuild task for compile-time codegen. Have a look at this: https://github.com/Microsoft/PTVS/blob/ebfc4ca8bab234d453f15ee426af3b208f3c143c/Python/Product/Cookiecutter/View/CookiecutterSearchPage.xaml#L54 https://github.com/Microsoft/PTVS/blob/ebfc4ca8bab234d453f15... It can also be used completely inline, i.e.: <TextBlock Text="{Binding Name, Converter={ext:Lambda 'x => x.ToUpper()'}"/> This is the codegen step that extracts those lambdas from XAML and processes them: https://github.com/Microsoft/PTVS/blob/6bf34d3611d34e94eddb6388cfc5d100be70097e/Common/Tools/BuildTasks/ExtractLambdasFromXaml.cs https://github.com/Microsoft/PTVS/blob/6bf34d3611d34e94eddb6... and this is the helper classes that are used in its output: https://github.com/Microsoft/PTVS/tree/6bf34d3611d34e94eddb6388cfc5d100be70097e/Common/Product/SharedProject/Wpf/LambdaConverter https://github.com/Microsoft/PTVS/tree/6bf34d3611d34e94eddb6... Note that it's language-agnostic; or rather, it uses the same language for expressions that the project itself does (so long as that language has a CodeDOM provider).
- m_fayer 9y agoThis is brilliant and needs to be extracted into a library of its own. Thanks for surfacing this!
- int_19h 9y agoI originally wrote this code back in 2011 with the intent to do just that (after some production use to prove the concept - which did happen; we've been shipping products that use this code since 2013)... but never found enough interest to actually motivate me to go and make it happen. Looking at the upvotes on this comment, I might reconsider :) Of course, if anyone wants to take this code and go for it, you're quite welcome. Note that it has been also licensed more permissively under MIT as part of RTVS - probably a better starting point for that: https://github.com/Microsoft/RTVS/tree/master/src/Common/Wpf/Impl/LambdaConverter https://github.com/Microsoft/RTVS/tree/master/src/Common/Wpf... https://github.com/Microsoft/RTVS/blob/master/src/Common/BuildTasks/ExtractLambdasFromXaml.cs https://github.com/Microsoft/RTVS/blob/master/src/Common/Bui...