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

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

    56 comments

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

        FWIW, looks like another MSFT group has given UWP Xaml APIs a resounding vote of no confidence, ditching it altogether in favor of React Native:
        https://mspoweruser.com/microsoft-buries-uwp-ports-skype-to-react-native/

        It won't be long before other groups and external developers follow suit, if they haven't already.

        I think it is safe to say this issue has no chance of completion, if it did in the first place. It would be valuable to hear some thoughtful dialogue/contribution/discussion from any of the administrators/moderators/managers from the wpdev forum here to take a second or two to help cue us in on what is going on, but based on the history here and in this issue in particular (where questions are simply ignored), we're not going to get it.

        I could be pleasantly surprised and do welcome any productive dialogue, however.

      • Anonymous commented  ·   ·  Flag as inappropriate

        I would love to have IXamlTypeResolver in custom MarkupExtensions for the Visual Studio 2015 designer. Without this interface the usability is quite limited.

      • Dmitry 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)

      • Dmitry 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 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 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 Horrik commented  ·   ·  Flag as inappropriate
      • birbilis 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-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-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-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.

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

      • 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.

      ← Previous 1 3

      Feedback and Knowledge Base