locked
[XmlnsDefinition] replacement in WinRT

    Question

  • What is WinRT XAML metro style application replecement for [assembly: XmlnsDefinition] attribute from WPF/SL world?
    Thursday, February 9, 2012 12:35 PM

Answers

  • Hi ControlFlow,

    As you have probably found, there is no analagous attribute.

    You might be able to provide similar data in a custom IXamlMetadataProvider implementation, but since that is automatically generated for you I'm not sure it can be overridden.

    --Rob

    Friday, February 10, 2012 4:02 AM
    Moderator

All replies

  • Hi ControlFlow,

    As you have probably found, there is no analagous attribute.

    You might be able to provide similar data in a custom IXamlMetadataProvider implementation, but since that is automatically generated for you I'm not sure it can be overridden.

    --Rob

    Friday, February 10, 2012 4:02 AM
    Moderator
  • Rob, this is not an optional feature.  I'm trying to evaluate whether Windows Store is "Ready for Prime Time" here and I can accept the logic if dropping many of the WPF controls that we know and love (menus, routed commands, the commanding infrastructure, etc.).  I even kind-of agree with the direction they're taking the product.  But this feature, XmlnsDefinition, is critical to any reasonably complex, LOB architecture.  Is there any way you can find out what the reason was behind its demotion?  Is there a better way of mapping namespaces for XAML in Metro?  Will we see XmlnsDefinition in the near future?

    Thanks!

    Don Airey

    Monday, March 24, 2014 12:34 PM
  • Hi

    XmlnsDefinition is a key a feature for conditional compiling of xaml 

    Is there a alternate for mc:AlternateContent which is also not working?

    Developing a UniversalApp I do not see System.Windows.Markup to use;

    Thanks

    Dev




    • Edited by VMDevs Tuesday, May 6, 2014 3:47 PM
    Tuesday, May 6, 2014 3:40 PM
  • We have been working with WinRT/XAML for about a couple years now and I can say that the missing XmlnsDefinition feature is one of THE most annoying things about WinRT. It's silly that it's not available when it was even in Silverlight. I can understand if it was something that would affect performance (a reason why radial gradients aren't in WinRT), however XmlnsDefinition is only a compilation-time helper that makes it infinitely easier to reference custom controls and components.  It's something that should be easy to add, and I would certainly hope to see it by Windows 9.

    actiprosoftware.com - Professional WPF, WinRT, Silverlight, and WinForms UI controls and components

    Tuesday, May 6, 2014 4:03 PM
  • I'm currently searching this issue and workaround, see some discussion at the end of https://github.com/panthernet/GraphX/issues/21#issuecomment-105483227

    Microsoft MVP J# 2004-2010, Borland Spirit of Delphi 2001

    Tuesday, May 26, 2015 12:38 PM
  • There is a certain 'Zen' to programming in WinRT.  Moreover, I'm actively working on an approach which allows my company to target both WinRT and WPF, which has been a challenge.  The secret, I've learned, is to find the minimal subset of APIs that are either identical or have analogs in both.  In trying to separate the View from the View Model, I've been moved in the direction of placing more and more of the View in the XAML (I know, it sounds obvious until you actually try and do it in a real LOB application that covers both WinRT and WPF).  But to the point of the original question and my response: there is no analog to XmlnsDefinition in Win RT, so just bite the bullet and go with the 'using' statement in XAML.

    Also, Rob is right.  It's a complete pain-in-the-ass, but IXamlMetadataProvider is your escape hatch.  The compiler generates these files for you and you can use the version found in the 'obj' directory as a starting point for a custom metadata provider.  Note that you'll need one of these if you ever want to use the XAML parsing feature to construct/load XAML on-the-fly.

    Tuesday, May 26, 2015 1:06 PM