locked
[RS5:1809][xml] XElement not available? RRS feed

  • Question

  • I'm trying to develop an UWP app that makes use of XML. I want to make some bindings in XAML using x:Bind, but I can't get the required x:DataType for my DataTemplate. I want to bind XElement, but I get a very short list of available types. 

    Overview of the code.

    [...]
    <Page
    xmlns:xml="using:System.Xml.Linq"
    >
    
     <DataTemplate x:Key="SomeTemplate" x:DataType="xml:XElement">
                <StackPanel HorizontalAlignment="Left">
                    <TextBox
                            Foreground="GhostWhite"
                            Style="{StaticResource MyTextBoxStyle}"
                            Text="{x:Bind Name.LocalName, Mode=TwoWay}" />
                    <TextBox
                            Foreground="LightGreen"
                            Style="{StaticResource MyTextBoxStyle}"
                            Text="{x:Bind Value, Mode=TwoWay}"/>
                </StackPanel>
            </DataTemplate>

    I can make it work with Binding, but I would rather have some optimisation by using x:Bind.

    I remember I could use XElement in the past by referencing System.Xml.Linq and now it's not available. So should or shouldn't it be available in xaml? Is it some bug?

    Min version and target Windows versions are 1809 (build 17763).



    Monday, October 8, 2018 4:44 PM

Answers

  • I've already tested it on two builds. 1803 and 1809 - same results. I can use XElement in DataType, though it's not suggested in the list as shown above in the screenshot. I think my problem is "solved". In the DataType field just put the type you want to use in System.Xml.Linq and it will work, even though it's not suggested in the list.

    • Marked as answer by Michał Kania Friday, October 12, 2018 7:59 AM
    Friday, October 12, 2018 7:57 AM

All replies

  • Hi,

    Does it work on build 1803? Do you have another device which is 1803 to make a test about this? Currently we need to know if this is caused by Windows 10 Build 1809

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 9, 2018 6:03 AM
  • Hi,

    Does it work on build 1803? Do you have another device which is 1803 to make a test about this? Currently we need to know if this is caused by Windows 10 Build 1809

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Hey,

    It doesn't work in 1803 and earlier and unfortunately I don't have a way to check it on a different PC if it works for previous Windows builds. I had Windows Insider build before October update, so it might also influence it. I would like to hear if you can reproduce it because in my case it's very easy to do.

    1. Create C# Windows Universal Blank App

    2. Add reference to the namespace System.Xml.Linq

    3. Try to create DataTemplate with x:DataType referencing XElement from System.Xml.Linq namespace.

    Tuesday, October 9, 2018 10:05 AM
  • I guess I tricked myself with the list which suggests that I can't use XElement, but by simply putting it in the DataType I can reference properties with x:Bind.
    Tuesday, October 9, 2018 7:03 PM
  • Hi,

    I get the same result as you said. Do you remember on which OS build this could be used? It seems you could not use the System.Xml.Linq for the x:datatype currently. This behavior has been changed. You might need to parse the XElement in to an object that could be referenced. Or you will need to use binding instead of x:bind.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 11, 2018 7:54 AM
  • I've already tested it on two builds. 1803 and 1809 - same results. I can use XElement in DataType, though it's not suggested in the list as shown above in the screenshot. I think my problem is "solved". In the DataType field just put the type you want to use in System.Xml.Linq and it will work, even though it's not suggested in the list.

    • Marked as answer by Michał Kania Friday, October 12, 2018 7:59 AM
    Friday, October 12, 2018 7:57 AM