How can we improve the Windows dev platform?

Add Markup Extensions to (and Improve) WinRT Xaml System (System.Xaml Parity)

Much effort was made in WPF Xaml Serialization to decouple it from the presentation assemblies and moved into its own assemblies, System.Xaml, and System.Windows.Markup.

This Xaml System had it's own serialization/deserialization mechanism in XamlServices class. Furthermore, this Xaml system had a very powerful component/concept that is conspicuously absent in WinRT: Markup Extensions.

Markup Extensions are found in the following Xaml Systems:
- WPF
- Silverlight 5
- Xamarin.Forms (notably NOT a Microsoft technology, but recognizes their power nonetheless)

This feature is to ask for Xaml serialization featureset parity with WPF/System.Xaml. That means:
- Custom Markup Extensions
- XamlServices.Load and Save
- All default system markup extensions "{x:Null}, {x:Static}, etc." found in WPF/Silverlight5.
- IProvideValueTarget interface
- INameScope interface
- ... and more!

YEAH!!! XAML!!! WHOOOOOOOOOOO!!!

197 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Mike-EEEMike-EEE shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
    Anonymous shared a merged idea: Allow using of Binding like a custom markup extension for XAML  ·   · 

    17 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Titus RockefellerTitus Rockefeller commented  ·   ·  Flag as inappropriate

        WPF and Silverlight are still better technologies five years after the fact. They don't use these strange, magic string tokens like UWP that sort-of, kind-of masquerade like markup extensions. These markup extensions feel like a team of outsourced, junior developers made them -- basically having absolutely no clue about what .NET is and getting paid to act like it.

        Nope, WPF and Silverlight use real, live markup extensions, the way God intended!!! Also, System.Xaml can be used in all scenarios, not just the under-featured client-tier that UWP has cobbled together. It would be nice to see a separate assembly that can be used outside of clients, but somehow think the outsourced and low-quality culture there won't even consider it.

        Seriously, does anyone over there actually do any work?!?! It's been five years since Silverlight and 1.5 years since this vote was put together!!!

      • Bradley MastersonBradley Masterson commented  ·   ·  Flag as inappropriate

        So sad that Microsoft and the Windows group used to be full of smart people who cared and were passionate about the technologies they worked on. Now it is a shell of an organization that simply sits on its hands, waiting for a paycheck. Very disappointing to see that this has taken so long, or really to even identify it as a problem in the first place. Clearly an IQ exodus has taken place.

        Please get your act together and be competitive like you were back in the day. Other Microsoft groups are running circles around you, and far more transparent!

      • Josh McFaddenJosh McFadden commented  ·   ·  Flag as inappropriate

        Echoing the sentiments here. Why has this taken so long? Xaml system in UWP is a terrible joke and is not even close to older systems. String values are passed back and forth between COM and it is a mess to work with!!! Might as well code it all by hand and ditch the designer altogether. I also too agree with making this open source and cross platform so that all .NET applications can use it for the powerful serialization engine it is, not the UI cluster it has become in UWP, which was clearly written by a team of interns.

        The GitHub vote below says it all. It is overwhelmingly the most popular vote in that repo. LISTEN TO YOUR DEVELOPERS!!!

      • Juan MarcoJuan Marco commented  ·   ·  Flag as inappropriate

        Wow over 14 months to simply say you will not strive to make your product like one that was better than it created nearly a decade ago? And this is with a high-ish vote count. I do not even know where to start with that. Does anyone over there even care?

        From the looks of it, "on the backlog" looks like where ideas go to die. Some of these issues are four years and counting:
        https://wpdev.uservoice.com/forums/110705-universal-windows-platform/status/410014

        This group has a rep for sititng around and collecting a paycheck. Now I see why. Guess we'll have to go to Visual Studio or open source for this.

      • Anonymous commented  ·   ·  Flag as inappropriate

        There is old lack of native XAML
        https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/7232264-add-markup-extensions-to-and-improve-winrt-xaml

        I had seen post about custom markup extensions on UWP apps but it is not work at all
        https://msdn.microsoft.com/en-us/windows/uwp/xaml-platform/customresource-markup-extension
        At first, I install latest version of Visual Studio and try to create custom extension for localization but described in your article way with derive from CustomXamlResourceLoader class doesn't work :(
        I still have compiler errors:
        Cannot assign 'Localizing' into property 'Text', type must be assignable to 'String'
        Type 'local:Localizing' is used like a markup extension but does not derive from MarkupExtension.

        Second, please, see ABindingExtension class and read the article about it
        http://makeloft.xyz/lessons/xaml/custom-binding-extensions

        public abstract class ABindingExtension : Binding, IValueConverter
        {
        protected ABindingExtension()
        {
        Source = Converter = this;
        }

        protected ABindingExtension(object source) // Source, RelativeSource, null for DataContext
        {
        var relativeSource = source as RelativeSource;
        if (relativeSource == null && source != null) Source = source;
        else RelativeSource = relativeSource;
        Converter = this;
        }

        public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);

        public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
        throw new NotImplementedException();
        }
        }

        This class very good and memory safe alternative for classical MarkupExtension. This approach works even on old Windows Phone Silverlight where is not MarkupExtension class.

        I tried to apply this way to UWP but there are two artificial limitations of XAML-parser.

        Look at sample

        public abstract class ABindingExtension : Binding, IValueConverter
        {
        protected ABindingExtension()
        {
        Source = Converter = this;
        }

        protected ABindingExtension(object source) // Source, RelativeSource, null for DataContext
        {
        var relativeSource = source as RelativeSource;
        if (relativeSource == null && source != null) Source = source;
        else RelativeSource = relativeSource;
        Converter = this;
        }

        public abstract object Convert(object value, Type targetType, object parameter, string culture);

        public virtual object ConvertBack(object value, Type targetType, object parameter, string culture)
        {
        throw new NotImplementedException();
        }
        }

        public class Localizing : ABindingExtension
        {
        public override object Convert(object value, Type targetType, object parameter, string culture)
        {
        return "test"; // return value by key
        }
        }

        For example
        <Control>
        <Control.DataContext> // is object
        <Localizing/> // called Convert method like expected!
        <Control.DataContext>
        </Control>

        output => Works fine!
        But

        <TextBlock>
        <TextBlock.Text> // is string
        <Lokalizing/>
        <TextBlock.Text>
        </TextBlock>

        output => Cannot assign 'Localizing' into property 'Text', type must be assignable to 'String'

        Also
        <Control DataContext="{local:Localizing}"/>

        output => Type 'local:Localizing' is used like a markup extension but does not derive from MarkupExtension.

        Pease, check this artificial limitaions for Bindings becouse all works fine, but only XAML-preprocessor get errors!

        P.S. May be you will be interested by SwichConverter and some other power improvements for XAML and MVVM

        <Grid.Resources>
        <SwitchConverter x:Key="NumberSwitchConverter" Default="Hello">
        <Case Key="0" Value="Zero"/>
        <Case Key="1" Value="One"/>
        </SwitchConverter>
        </Grid.Resources>
        <TextBlock Text="{Binding Number, Converter={StaticResource NumberSwitchConverter}}"/>

        Number==0 => out: Zero
        Number==1 => out: One
        Number==2 => out: Hello

        Please, see code samples and Aero Framework library
        https://onedrive.live.com/?authkey=%21AMT2QVotfWTReos&cid=C8D6E2F8053DDCFB&id=C8D6E2F8053DDCFB%2123902&parId=C8D6E2F8053DDCFB%2123896&action=locate

        Thanks!

      • LarryLarry commented  ·   ·  Flag as inappropriate

        Without this, I cannot bind a Uid in a data template (if that is incorrect, someone please let me know!).

      • MysticTazMysticTaz commented  ·   ·  Flag as inappropriate

        Additionally, WinRT Xaml REALLY needs x:Type and support for TypeConverter's, which WinRT also doesn't have yet.

      • Mike-EEEMike-EEE commented  ·   ·  Flag as inappropriate

        Additionally, this assembly should also be self-contained and distributable, just like System.Xaml. Meaning, we should be able to use this assembly for Xaml serialization no matter where it's needed, whether it is in the client, server, anywhere... just like System.Xaml.

      Feedback and Knowledge Base