<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.silverlight.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Silverlight Tip of the Day #103 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx</link><description>When calculating the positions of objects such as Images make certain to use integer values not floating point values. For example, take a look at this code that centers a map around a given position: private void CenterMap( double windowWidth, double</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>re: Silverlight Tip of the Day #103 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#275033</link><pubDate>Mon, 24 Aug 2009 16:19:46 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:275033</guid><dc:creator>mike.snow</dc:creator><description>&lt;p&gt;Hi, did you try using UseLayoutRounding ?&lt;/p&gt;
&lt;p&gt;Also, it's hard to know what you are doing wrong without seeing the code.&lt;/p&gt;
&lt;p&gt;You can post your code here for layout out your map or you can mail me your project and I will take a quick look.&lt;/p&gt;
&lt;p&gt;msnow @ microsoft.com&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;--Mike&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=275033" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #103 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#274822</link><pubDate>Mon, 24 Aug 2009 11:55:37 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:274822</guid><dc:creator>malignate</dc:creator><description>&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;I make a silverlight jump and run game at the moment and have the same problem: &lt;a rel="nofollow" target="_new" href="http://www.gpstudio.de/JnR.png"&gt;http://www.gpstudio.de/JnR.png&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I found your post and tried your solution, but it does not work. I also tried to add a pixel or two a scale transformation from with scaling in x and y direction of 1.01, but it has some other ugly side effects, especially at the background layer.&lt;/p&gt;
&lt;p&gt;Do you have another idea?&lt;/p&gt;
&lt;p&gt;Would be nice o get some tipps.&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=274822" width="1" height="1"&gt;</description></item><item><title>Silverlight Tip of the Day #103 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#266114</link><pubDate>Sat, 08 Aug 2009 22:36:22 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:266114</guid><dc:creator>NewsPeeps</dc:creator><description>&lt;p&gt;Thank you for submitting this cool story - Trackback from NewsPeeps&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=266114" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #103 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#239488</link><pubDate>Tue, 30 Jun 2009 06:25:26 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:239488</guid><dc:creator>DDtMM</dc:creator><description>&lt;p&gt;If you check the documentation on UseLayoutRounding you'll see it is True by default... yet I've gotten results similar to the top (bad) screenshot. &amp;nbsp;Maybe it is different in SL3? &amp;nbsp;I haven't tried.&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=239488" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #103 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#208118</link><pubDate>Fri, 17 Apr 2009 17:29:37 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:208118</guid><dc:creator>SharpGIS</dc:creator><description>&lt;p&gt;Instead of doing all that rounding yourself, isn't this what we have UseLayoutRounding=&amp;quot;True&amp;quot; for ?&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=208118" width="1" height="1"&gt;</description></item><item><title>Silverlight Tips of the Day - Summary Outline</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#202328</link><pubDate>Mon, 06 Apr 2009 22:20:02 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:202328</guid><dc:creator>Silverlight Tips of the Day - Blog by Mike Snow</dc:creator><description>&lt;p&gt;The purpose of this post is to create an outline summary all the blogs from my Silverlight Tips of the&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=202328" width="1" height="1"&gt;</description></item><item><title>Silverlight Tips of the Day – Week 12</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#202312</link><pubDate>Mon, 06 Apr 2009 22:13:05 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:202312</guid><dc:creator>Visual Web Developer Team Blog</dc:creator><description>&lt;p&gt;Most Recent Posts: Silverlight Tip of the Day #106 - Setting Default Browser from within VS Silverlight&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=202312" width="1" height="1"&gt;</description></item><item><title>WPF and Silverlight tips and tricks | WPF Dev</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#197098</link><pubDate>Fri, 27 Mar 2009 23:31:05 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:197098</guid><dc:creator>WPF and Silverlight tips and tricks | WPF Dev</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;WPF and Silverlight tips and tricks | WPF Dev&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=197098" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #102 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#196915</link><pubDate>Fri, 27 Mar 2009 17:30:26 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:196915</guid><dc:creator>Eric Willeke</dc:creator><description>&lt;p&gt;Try casting to float instead of int. I noticed in the course of doing some other work that a double value that's passed through AgCore isn't the same as went it went in. Investigation led me to realize that agcore.dll took everything in floats instead of doubles, and the difference was rounding error from the cast.&lt;/p&gt;
&lt;p&gt;It's been a while since I explored it, but I think something like this demonstrates it... might have to use different properties:&lt;/p&gt;
&lt;p&gt;double pi = Math.Pi;&lt;/p&gt;
&lt;p&gt;Canvas c = new Canvas();&lt;/p&gt;
&lt;p&gt;c.Width = pi;&lt;/p&gt;
&lt;p&gt;double pi2 = c.Width;&lt;/p&gt;
&lt;p&gt;Debug.Assert( pi == pi2 ); // Fails!&lt;/p&gt;
&lt;p&gt;Debug.Assert( pi.Equals( pi2 )); // Fails!&lt;/p&gt;
&lt;p&gt;Debug.Assert( (float) pi == (float) pi2 ); // Passes&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=196915" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #102 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#196810</link><pubDate>Fri, 27 Mar 2009 14:03:01 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:196810</guid><dc:creator>darktatami</dc:creator><description>&lt;p&gt;Awesome, I'm having a very simular issue with moving around my tile map. I'll do my calculations in ints and then change them to doubles before I move the map. Hopefully this cleans it up a bit, thanks again. :)&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=196810" width="1" height="1"&gt;</description></item><item><title>Silverlight Tip of the Day #102 – Use Integers for Layout Calculations</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2009/03/26/silverlight-tip-of-the-day-102-use-integers-for-layout-calculations.aspx#196335</link><pubDate>Thu, 26 Mar 2009 19:29:44 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:196335</guid><dc:creator>Microsoft Weblogs</dc:creator><description>&lt;p&gt;When calculating the positions of objects such as Images make certain to use integer values not floating&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=196335" width="1" height="1"&gt;</description></item></channel></rss>