<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Customizing &#8220;lookful&#8221; WPF controls &#8211; Take 2</title>
	<atom:link href="http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/</link>
	<description>Random musings from the developers at Tranxition</description>
	<lastBuildDate>Fri, 30 Oct 2009 13:52:19 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: jan</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-153</link>
		<dc:creator>jan</dc:creator>
		<pubDate>Wed, 07 Oct 2009 20:06:59 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-153</guid>
		<description>oh never mind, i figured it out.
sorry for the spam =)</description>
		<content:encoded><![CDATA[<p>oh never mind, i figured it out.<br />
sorry for the spam =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jan</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-151</link>
		<dc:creator>jan</dc:creator>
		<pubDate>Wed, 07 Oct 2009 19:18:11 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-151</guid>
		<description>Hi! Thanks for this post. I downloaded the project file and it works on the multi-line but not if there&#039;s just one word in it and Trimming = ”CharacterEllipsis” as Kevin noted above. Do you have an updated project file?
Thanks</description>
		<content:encoded><![CDATA[<p>Hi! Thanks for this post. I downloaded the project file and it works on the multi-line but not if there&#8217;s just one word in it and Trimming = ”CharacterEllipsis” as Kevin noted above. Do you have an updated project file?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Jones</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-150</link>
		<dc:creator>Richard Jones</dc:creator>
		<pubDate>Wed, 07 Oct 2009 08:12:57 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-150</guid>
		<description>To solve the problem with calculating IsTextTrimmed when the field contains a single word, a simpler solution is to add the line:
formattedText.Trimming = TextTrimming.None
after
formattedText.MaxTextWidth = textBlock.ActualWidth
(rather than Kevin&#039;s extra code from August 8th). This means that formattedText&#039;s height always increases if its content needs to wrap around.

I have another problem: The IsTextTrimmed property is recalculated if the textblock size is changed (e.g. if the UI is resized). However, it doesn&#039;t get recalculated if the textblock&#039;s content is changed. I&#039;m using binding to set the textblock&#039;s value, and IsTextTrimmed is calculated correctly when the field is displayed initially. However if the underlying Text value is then changed to something else, IsTextTrimmed doesn&#039;t get recalculated (unless you jiggle the edge of the UI!)

It seems that where we register the handler for the SizeChangedEvent, we also need to do something similar for when the Text property&#039;s value is changed.
I&#039;ve tried various things but haven&#039;t found an elegant solution. Any ideas?</description>
		<content:encoded><![CDATA[<p>To solve the problem with calculating IsTextTrimmed when the field contains a single word, a simpler solution is to add the line:<br />
formattedText.Trimming = TextTrimming.None<br />
after<br />
formattedText.MaxTextWidth = textBlock.ActualWidth<br />
(rather than Kevin&#8217;s extra code from August 8th). This means that formattedText&#8217;s height always increases if its content needs to wrap around.</p>
<p>I have another problem: The IsTextTrimmed property is recalculated if the textblock size is changed (e.g. if the UI is resized). However, it doesn&#8217;t get recalculated if the textblock&#8217;s content is changed. I&#8217;m using binding to set the textblock&#8217;s value, and IsTextTrimmed is calculated correctly when the field is displayed initially. However if the underlying Text value is then changed to something else, IsTextTrimmed doesn&#8217;t get recalculated (unless you jiggle the edge of the UI!)</p>
<p>It seems that where we register the handler for the SizeChangedEvent, we also need to do something similar for when the Text property&#8217;s value is changed.<br />
I&#8217;ve tried various things but haven&#8217;t found an elegant solution. Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: STEVE F</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-148</link>
		<dc:creator>STEVE F</dc:creator>
		<pubDate>Wed, 16 Sep 2009 19:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-148</guid>
		<description>Anyone have code for this working in a textbox.
If so could you email it to me at steve_44@inbox.com</description>
		<content:encoded><![CDATA[<p>Anyone have code for this working in a textbox.<br />
If so could you email it to me at <a href="mailto:steve_44@inbox.com">steve_44@inbox.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-141</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 14 Aug 2009 20:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-141</guid>
		<description>hempel, Jean-Marie and kevin,

Thank You!!!! Handling wrapped TextBlocks was the final missing piece, it works perfectly now!</description>
		<content:encoded><![CDATA[<p>hempel, Jean-Marie and kevin,</p>
<p>Thank You!!!! Handling wrapped TextBlocks was the final missing piece, it works perfectly now!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kevin</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-140</link>
		<dc:creator>kevin</dc:creator>
		<pubDate>Sat, 08 Aug 2009 16:03:06 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-140</guid>
		<description>I found this can be resolved by this:

// If there is only a word
if (!string.IsNullOrEmpty(formattedText.Text) &amp;&amp; 
    !formattedText.Text.Contains(&quot; &quot;))
{
  return (int)formattedText.Width &gt; 
         (int)textBlock.ActualWidth);
}</description>
		<content:encoded><![CDATA[<p>I found this can be resolved by this:</p>
<p>// If there is only a word<br />
if (!string.IsNullOrEmpty(formattedText.Text) &amp;&amp;<br />
    !formattedText.Text.Contains(&#8221; &#8220;))<br />
{<br />
  return (int)formattedText.Width &gt;<br />
         (int)textBlock.ActualWidth);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kevin</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-139</link>
		<dc:creator>kevin</dc:creator>
		<pubDate>Sat, 08 Aug 2009 15:44:21 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-139</guid>
		<description>I find it doesn&#039;t work if there is only one word in the Text and I set Trimming=&quot;CharacterEllipsis&quot;.</description>
		<content:encoded><![CDATA[<p>I find it doesn&#8217;t work if there is only one word in the Text and I set Trimming=&#8221;CharacterEllipsis&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Customizing &#34;lookful&#34; WPF controls &#171; The Tranxition Developer Blog</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-98</link>
		<dc:creator>Customizing &#34;lookful&#34; WPF controls &#171; The Tranxition Developer Blog</dc:creator>
		<pubDate>Wed, 04 Feb 2009 20:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-98</guid>
		<description>[...] Customizing &quot;lookful&quot; WPF&#160;controls  [UPDATE: This solution has been superceded by a much better implementation in this later post.] [...]</description>
		<content:encoded><![CDATA[<p>[...] Customizing &quot;lookful&quot; WPF&nbsp;controls  [UPDATE: This solution has been superceded by a much better implementation in this later post.] [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hempelcx</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-97</link>
		<dc:creator>hempelcx</dc:creator>
		<pubDate>Wed, 04 Feb 2009 18:26:58 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-97</guid>
		<description>Great, Jean-Marie!

I had a hunch that algorithm wouldn&#039;t work for multi-line text boxes and if I remember correctly, is partly why I added the condition on TextWrapping (though it&#039;s been a while, now).

Glad you got it working; I&#039;m updating the code sample to reflect the more inclusive algorithm. It now works with multi-line TextBlocks and with TextWrapping enabled or disabled.</description>
		<content:encoded><![CDATA[<p>Great, Jean-Marie!</p>
<p>I had a hunch that algorithm wouldn&#8217;t work for multi-line text boxes and if I remember correctly, is partly why I added the condition on TextWrapping (though it&#8217;s been a while, now).</p>
<p>Glad you got it working; I&#8217;m updating the code sample to reflect the more inclusive algorithm. It now works with multi-line TextBlocks and with TextWrapping enabled or disabled.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jean-Marie Pirelli</title>
		<link>http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-96</link>
		<dc:creator>Jean-Marie Pirelli</dc:creator>
		<pubDate>Wed, 04 Feb 2009 15:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/#comment-96</guid>
		<description>I found out that the algorithm does not work for a multi-line text box. I changed it like this:

Replace the last return statement in CalculateIsTextTrimmed by:

            formattedText.MaxTextWidth = textBlock.ActualWidth;

            return (formattedText.Height &gt; textBlock.ActualHeight);

So, the FormattedText instance is given a max width, so if it has to occupy more height than the given TextBlock, it means that the text was trimmed.
This also works for a single-line text block.</description>
		<content:encoded><![CDATA[<p>I found out that the algorithm does not work for a multi-line text box. I changed it like this:</p>
<p>Replace the last return statement in CalculateIsTextTrimmed by:</p>
<p>            formattedText.MaxTextWidth = textBlock.ActualWidth;</p>
<p>            return (formattedText.Height &gt; textBlock.ActualHeight);</p>
<p>So, the FormattedText instance is given a max width, so if it has to occupy more height than the given TextBlock, it means that the text was trimmed.<br />
This also works for a single-line text block.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
