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!!!

323 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 →

    An always happy Friday as I just got the TFS complete email :) As this hasn’t hit an insider preview SDK, i’m going to mark this still as “working on it” still BUT … this will be coming to an insider build near you!

    This item heart is markup extensions. There is one item that will not be there however that is relevant to markup extensions, IServiceProvider. I created a new item for that but we are working on this item [https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/19416094-iserviceprovider-for-markup-extensions-for-wpf-par]. We have created a new one and we are working on that (that includes IProvideValueTarget and INameScope) but feel we have enough to ship this and mark this larger work item done and we do point out in reference to more work items need to happen, namely the work around IServiceProvider.

    Also XamlServices.Load / Save isn’t directly related to markup extenstion so we’re viewing that as out of scope. Also per documentation, System.Windows.Markup.XamlReader and XamlWriter are the preferred ways to do this, which are in UWP. (https://msdn.microsoft.com/en-us/library/system.xaml.xamlservices(v=vs.110).aspx and https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.markup.xamlreader

    53 comments

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

        Additionally to my previous message, the real LocalizationExtension from our projects is used like x:Static extension, specifying localization type and property:

        static message: <TextBlock Text="{x:Static Member=local:Localization.SomeMessage}">

        dynamic message: <TextBlock Text="{local:Localization Member=local:Localization.SomeMessage}">

        In the second case we can change language at runtime. To implement such extension we need IXamlTypeResolver to resolve the type (and reflection to resolve the property)

      • DmitryDmitry commented  ·   ·  Flag as inappropriate

        I frequently use custom markup extensions to provide a dynamic value on a property. For that I build a Binding in my markup extension and return the result of calling Binding.ProvideValue method sending IServiceProvider from my MarkupExtension.ProvideValue. You can't disagree (I guess) that Binding could be installed correctly without IServiceProvider. One of the examples I can suggest is dynamic localization in Xaml (very simple, just to show the idea), here is the code:

        public class LocalizationManager : INotifyPropertyChanged
        {
        public static readonly LocalizationManager Instance = new LocalizationManager();
        private static readonly Dictionary<string, string> RuLanguage = new Dictionary<string, string> {{"SomeMessage", "Некоторое сообщение"}};
        private static readonly Dictionary<string, string> NeutralLanguage = new Dictionary<string, string> {{"SomeMessage", "Some Message"}};

        private CultureInfo _currentUiCulture;

        public CultureInfo CurrentUICulture
        {
        get => _currentUiCulture;
        set
        {
        _currentUiCulture = value;
        OnPropertyChanged();
        }
        }

        public string GetLocalizedString(string id) => string.Equals(CurrentUICulture?.TwoLetterISOLanguageName, "ru", StringComparison.OrdinalIgnoreCase) ? RuLanguage[id] : NeutralLanguage[id];

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

        public event PropertyChangedEventHandler PropertyChanged;
        }

        public class DynamicLocalization : MarkupExtension, IValueConverter
        {
        public string LocalizeId { get; set; }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
        var localizationBinding = new Binding
        {
        Path = new PropertyPath("CurrentUICulture"),
        Source = LocalizationManager.Instance,
        Converter = this
        };
        return localizationBinding.ProvideValue(serviceProvider);
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => LocalizationManager.Instance.GetLocalizedString(LocalizeId);

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException();
        }

        To use in Xaml:
        <TextBlock Text="{local:LocalizationManager LocalizeId=SomeMessage}" />

        To change localization:
        LocalizationManager.Instance.CurrentUICulture = new CultureInfo("ru");

        Currently it is the only way to provide dynamic values in a custom markup extension that I know (suggest others if you know). I can't find any benefit of custom markup extensions without IServiceProvider. In that case you can return only static values based on some static input through the markup extension properties.

      • Praveen PotturuPraveen Potturu commented  ·   ·  Flag as inappropriate

        @Clint, it is not just about Windows 10 mobile getting it. I have many users left out on anniversary update with no path forward. I need to support them too.

      • Geert van HorrikGeert van Horrik commented  ·   ·  Flag as inappropriate

        > "this will be coming to an insider build near you"

        Does this mean that it will only work on the Creators Fall Update (RS3) and beyond? Is it tied to an OS version instead of a compiler / tooling version?

        If so, we're in catch-22 again since the parts we have developed for UWP need to work on pc, tablet *and* mobile (yes, windows 10 mobile). Given the recent rumors and non-communication about W10M by Microsoft, I can't really expect (or rely on) Windows 10 Mobile to receive the creators fall update. And I already need to take care of a lot of "forgotten" phone devices still on older versions where the composition API is not available.

        If this feature is not tied to the OS but to the compiler that will be backwards compatible, then I'm all happy. Or if someone @ Microsoft can just verify something about W10M and the fall update, I'm happy as well. If not, I think a lot of developers won't be able to use this in the foreseeable future.

      • Geert van HorrikGeert van Horrik commented  ·   ·  Flag as inappropriate
      • birbilisbirbilis commented  ·   ·  Flag as inappropriate

        Ahem, GitHub and NuGet are publicly available libraries. You can't be doing analysis on just them. Should have some readiness tool that one can run on their private codebase and get some analysis that they can contribute back to you via the tool

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

        Awww Clint, big hugs. I have nothing but massive respect for you and the team there. Please don't mistake my good-natured jabs (I used emoticons!) at your *means and processes* as a personal attack (which, in my world, would also mean name-calling, insulting, denigrating, and nasty language, etc.) on you.

        In fact, from my perspective, means and processes are the very reason why your team is operating at a fraction of awesome that I see the rest of MSFT operate these days. They really are a liability.

        That said, I would also kindly ask that you please consider my position as well. Does it seem professional and respectful to ask the community you serve for examples for a particular issue, lose them, and then ask for them again two years later? Even after these examples are once again provided (keep in mind digging through history is not exactly easy or pleasant!), state that they have not been provided and do not provide reasons on why when inquired? Or even ignoring communications altogether (this has happened several times now). Does this seem to you to be a great example of a community leader if not member to follow?

        I feel I am being reasonable here but I am open to feedback, as always. As long as that doesn't mean getting a link to your guidelines. :) I'm on YOUR side here, buddy. Means and processes, maybe not so much.

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

        > As of now, you haven't provided a scenario for YOUR applications.

        Since carrying a conversation doesn't seem to be at the top of Clint's favorite hobbies. :) Christophe: Can you please confirm that the link I provided below contains the types of examples you are looking for, and if you were perhaps able to find the others in that Twitter conversation? Please let me know if there is anything that I can assist with getting you what you are looking for and/or if what I have provided (again twice now spanning nearly two years of time :) ) somehow falls short, and if so why. Clint really didn't go into it or explain, so I am still curious to know why he feels I have not submitted scenarios/examples when, in fact, I have (from my perspective, at least). Thank you for any clarification and/or assistance that you can provide, team!

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

        > not everything is on github

        Haha right! There is always email, I know. ;)

        > We can and do a lot of analysis

        Clearly. ;)

        > As of now, you haven't provided a scenario for YOUR applications.

        Way to make it personal, Clint. ;) But really, I am interested in why the examples in the link I provided below do not count. As I mentioned, there are more from myself and others in that conversation, but I cannot sift through Twitter as well as your historically legendary and award-winning analytics apparatus probably can. Or are you saying that so much time has passed (it's been nearly two years., after all ;) ) that they are no longer valid and do not count for some reason? Please let me know what I am missing here.

      • Clint Rutkas [MSFT]AdminClint Rutkas [MSFT] (Admin, Windows Developer) commented  ·   ·  Flag as inappropriate

        @mike, not everything is on github. That is one signal of many. We can and do a lot of analysis. That is why we know 70% of all nuget packages should be ready for .NET Standard 2.0.

        Per Christophe, we’re gathering scenarios to make the right choices in implementation and prioritization. As of now, you haven't provided a scenario for YOUR applications.

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

        Sweet. Thanks, @Christophe! Really appreciate your efforts here, and for putting up with all my grief. As I described to you numerous times I am overwhelmingly invested in this at this point. Can't turn back now. :)

        In addition to discussions here, I think your UserVoice items would benefit tremendously if linked to a GitHub issue. I would suggest for this issue linking it to this one:
        https://github.com/Microsoft/xaml-standard/issues/27

        UserVoice is OK at showing sentiment, but GitHub is wayyyyy better integrated and offers much more granular control over expression of that sentiment. Not to mention, offering the ability to integrate directly with the code responsible for the implementation of the idea/issue.

        Thank you for any consideration!

      • Christophe Philippona [MSFT]AdminChristophe Philippona [MSFT] (Admin, Windows Developer) commented  ·   ·  Flag as inappropriate

        I appreciate the enthusiasm @Mike-EEE. We're gathering scenarios to make the right choices in implementation and prioritization.

        Markup extensions have been used in a lot of creative ways. We’ve done research to see where and why you want to use markup extensions in UWP. That’s not to say however that we’ve covered all the possible scenarios. We're opening the discussion up to the community to make sure we capture your scenarios.

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

        @Clint... thanks, I know that Christophe is indeed part of the Xaml team. I spoke with him on the phone a few weeks ago and was really impressed with his professionalism. I say this as the poor guy essentially listened to me b*tch his ear of for over an hour as we discussed the UWP group. Or I should say, *I* complained about the UWP group. :)

        It was during this phone call that I sadly learned that the examples of markup extensions that I and others provided Tim nearly two years ago were not captured or maintained, so Christophe had to make the request of shame to find them *yet again*. I try to be supportive, but I am sure you can understand the frustration of:

        1) Having to explain to a principle manager of a MSFT UX manager the benefits and power of markup extensions.
        2) Providing examples upon request.
        3) Discuss these markup extensions and more on a phone call.
        4) Wait two years. ;)
        5) Having to explain to the principle design staff of MSFT UX the benefits and power of markup extensions (again).
        6) Having to provide examples of markup extensions once again, which are literally saturated in WPF documentation, examples, and projects throughout the ecosystem.

        You will have to forgive me if I am not feeling the passion here. No other group that has designed a flavor of Xaml has demonstrated such friction to employ a feature that is so obvious and available in literally every other version of Xaml you can find.

        I hope you find this as constructive, and I hope even more you can understand the frustration here. To show I am a good sport, I finally did a little digging and was able to yield one example. Twitter is very difficult to navigate so I am not able to find the others at the moment, but I know they were provided. You will have to forgive me for not feeling the desire to spend more time than I have to as I am not confident it will matter in any meaningful way:

        https://twitter.com/MikeEEE76/status/627098857147600896

        If you read parts of that discussion, it's pretty shocking to see how similar the discussion there is much like the discussion here... two years later. ;)

        Finally, you really should be on the Xaml Standard repo. There is not a lot of love there for UWP, I'm afraid. It's all WPF, Avalonia, and even Noesis. I am holding out hope that now that we have this platform we can land on a, well, standard, that we all can finally be proud of, once again.

      ← Previous 1 3

      Feedback and Knowledge Base