<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : TIP: XAML Markup &amp; Entities (Dynamic)</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : XAML Snippets : TIP: XAML Markup &amp; Entities (Dynamic)]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 13 May 2026 19:12:08 +0000</pubDate>
  <lastBuildDate>Mon, 02 Nov 2009 10:00:57 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=10865</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[TIP: XAML Markup &amp; Entities (Dynamic) : Thank you! I use &amp;#039;&amp;amp;#x0a;&amp;#039;...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=10865&amp;PID=54485&amp;title=tip-xaml-markup-entities-dynamic#54485</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4605">zitz</a><br /><strong>Subject:</strong> 10865<br /><strong>Posted:</strong> 02 November 2009 at 10:00am<br /><br />Thank you! I use '&amp;#x0a;' instead '&lt;linebreak/&gt;'<br><br>For C++, MFC<br><table width="99%"><tr><td><pre class="BBcode"><br>CString CMarkupHelper::StringToMarkupFormat( LPCTSTR szString )<br>{<br>&nbsp;&nbsp; &nbsp;CString sString = szString;<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("&amp;"), _T("&amp;amp;") );<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("&lt;"), _T("&amp;lt;") );<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("&gt;"), _T("&amp;gt;") );<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("'"), _T("&amp;apos;") );<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("\""), _T("&amp;quot;") );<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("\r\n"), _T("&amp;#x0a;") );<br>&nbsp;&nbsp; &nbsp;sString.Replace( _T("\n"), _T("&amp;#x0a;") );<br>&nbsp;&nbsp; &nbsp;return sString;<br>}<br></pre></td></tr></table><br>]]>
   </description>
   <pubDate>Mon, 02 Nov 2009 10:00:57 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=10865&amp;PID=54485&amp;title=tip-xaml-markup-entities-dynamic#54485</guid>
  </item> 
  <item>
   <title><![CDATA[TIP: XAML Markup &amp; Entities (Dynamic) : Hi,Sometimes you need to insert...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=10865&amp;PID=36096&amp;title=tip-xaml-markup-entities-dynamic#36096</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2676">jpbro</a><br /><strong>Subject:</strong> 10865<br /><strong>Posted:</strong> 01 June 2008 at 10:43pm<br /><br />Hi,<BR><BR>Sometimes you need to insert dynamically generated text from XAML unaware sources (such as user input, log files, etc...). Trying to include this text may cause the markup to be invalid and prevent the CJ controls from displaying the markup properly.<BR><BR>To prevent this, you should sanitize all plain-text that you want to add to your markup controls before sending it to the control. Right now I'm using this function and it has been working (although I don't know if the list is exhaustive, so I'd appreciate any input if there are bugs):<BR><BR><table width="99%"><tr><td><pre class="BBcode"><BR>Public Function xamlEncodePlaintext(ByVal pPlainText As String) As String<BR>&nbsp;&nbsp; ' Convert illegal characters to XAML entities<BR>&nbsp;&nbsp; pPlainText = Replace$(pPlainText, "&amp;", "&amp;amp;")<BR>&nbsp;&nbsp; pPlainText = Replace$(pPlainText, "&lt;", "&amp;lt;")<BR>&nbsp;&nbsp; pPlainText = Replace$(pPlainText, "&gt;", "&amp;gt;")<BR>&nbsp;&nbsp; pPlainText = Replace$(pPlainText, "'", "&amp;apos;")<BR>&nbsp;&nbsp; pPlainText = Replace$(pPlainText, """", "&amp;quot;")<BR>&nbsp;&nbsp; ' Expand VB newline characters to XAML &lt;LineBreak/&gt; tags<BR>&nbsp;&nbsp; pPlainText = Replace$(pPlainText, vbNewLine, "&lt;LineBreak/&gt;")<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; xamlEncodePlaintext = pPlainText<BR>End Function<BR></pre></td></tr></table><BR><BR>I've also added (as a convenience) the conversion of VB NewLines to &lt;LineBreak/&gt; elements to preserve line spacing.<BR><BR>To use it (for this example, put a TextBox (Text1) and a CJ Label (Label1) on your form):<BR><BR><table width="99%"><tr><td><pre class="BBcode"><BR>Private Sub Form_Load<BR><BR>Me.Text1.Text = "&lt;This is a test of plain-text XAML entity encoding &amp; markup&gt;" &amp; vbNewline &amp; vbNewline &amp; "You shouldn't see any XAML in your label caption!"<BR>&nbsp;&nbsp;&nbsp; <BR>With Me.Label1&nbsp;&nbsp; ' CJ label<BR>&nbsp;&nbsp;&nbsp; .EnableMarkup = True<BR>&nbsp;&nbsp;&nbsp; .Caption = "&lt;TextBlock&gt;" &amp; xamlEncodePlaintext(Me.Text1.Text) &amp; "&lt;/TextBlock&gt;"<BR>End With<BR><BR>End Sub<BR></pre></td></tr></table><BR><BR>Pretty simple &amp; straight-forward, but hopefully it will be of some use to someone!<BR><BR>]]>
   </description>
   <pubDate>Sun, 01 Jun 2008 22:43:53 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=10865&amp;PID=36096&amp;title=tip-xaml-markup-entities-dynamic#36096</guid>
  </item> 
 </channel>
</rss>