none
BUG?:CustomXmlElement.CustomXmlProperties.CustomXmlPlaceHolder doesn't work? RRS feed

  • Question

  • ...
    ((CustomXmlElement)r).CustomXmlProperties.CustomXmlPlaceHolder;                             <-  Null reference no matter what value's in the <w:placeholder />
    ((CustomXmlElement)r).CustomXmlProperties.OfType<CustomXmlPlaceholder>().First();  <-- this works all right
    ...


    _________________________ My Blog: xiaoyuvax.spaces.live.com Follow me on Twitter: twitter.com/xiaoyuvax
    Monday, October 26, 2009 1:04 PM

All replies

  • Hi,

    I tried the same code in my machine and the CustomXmlPlaceHolder can be loaded correctly. can you double check your code?

    Tuesday, November 3, 2009 8:23 AM
  • can you paste your code here,so that i can make sure you are on the same situation...

    please note there is an explicit cast,which cos the Object to be cast as CustomXmlElement... 

    _________________________ My Blog: xiaoyuvax.spaces.live.com Follow me on Twitter: twitter.com/xiaoyuvax
    Tuesday, November 3, 2009 8:30 AM
  • my sample document's main document part is like this:

    <w:document>
        <w:body>
            <w:customXml w:uri="te" w:element="Keytips">
                <w:customXmlPr>
                    <w:placeholder w:val="[Fill in your name]"/>
                    <w:attr w:name="status" w:val="draft"/>
                </w:customXmlPr>
                <w:p>
               ....

    And I am using the following code to get the placeholder, it works fine.  btw, i am using the August 2009 Community Technical Preview.

    var cx = ((CustomXmlElement)(docEle.Body.FirstChild)).CustomXmlProperties.CustomXmlPlaceholder;
    System.Diagnostics.Debug.Assert(cx != null);
    Friday, November 6, 2009 9:52 AM
  • i've double checked my code again,still doesn't work ...

    see the following screen Cap form the watch window(you'll see how weird it is):

    can you check out another detail: r is CustomXmlRun  // is not a CUstomXmlBlock nor otherwise...


    _________________________ My Blog: xiaoyuvax.spaces.live.com Follow me on Twitter: twitter.com/xiaoyuvax
    Sunday, November 8, 2009 2:10 PM
  • it is really weird :)

    see my result:

    the xml fragment:

    <w:body>
            <w:p>
                <w:r>
                    <w:rPr>
                        <w:rFonts w:hint="eastAsia"/>
                    </w:rPr>
                    <w:t>abc</w:t>
                </w:r>
                <w:customXml w:uri="te" w:element="Keytips">
                    <w:customXmlPr>
                        <w:placeholder w:val="[Fill in your name]"/>
                        <w:attr w:name="status" w:val="draft"/>
                    </w:customXmlPr>
                    <w:r>
                        <w:t>dam</w:t>
                    </w:r>
                </w:customXml>
            </w:p>
    <w:body>

    my code:
                    var docEle = doc.MainDocumentPart.Document;
                    var r = docEle.Body.FirstChild.FirstChild.NextSibling();
                    var ce1 = ((CustomXmlElement)r).CustomXmlProperties.CustomXmlPlaceholder;
                    var ce2 = ((CustomXmlElement)r).CustomXmlProperties.OfType<CustomXmlPlaceholder>().First();
                    System.Diagnostics.Debug.Assert(ce1 != null);
                    System.Diagnostics.Debug.Assert(ce2 != null);

    there is no assertion when running the about code. and the watch window also shows ce1 and ce2 are not null.

    Maybe you want to try the next version CTP. Wait a couple of days.... :)

    Monday, November 9, 2009 2:11 AM
  • i'm also looking forward to the next version of the SDK, since i've met many a such weirdness... lol


    _________________________ My Blog: xiaoyuvax.spaces.live.com Follow me on Twitter: twitter.com/xiaoyuvax
    Monday, November 9, 2009 4:11 AM