<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6249909800506859886</id><updated>2011-12-26T03:14:43.196-08:00</updated><category term='How do I know it&apos;s PHP'/><category term='Not everything is about WPF'/><category term='Conferences'/><category term='iPhone'/><category term='xkcd'/><category term='WCF'/><category term='WPF'/><category term='Exception Handling'/><title type='text'>The WPF developer dude</title><subtitle type='html'>i wish my brain had a GC too...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-2670575101749555163</id><published>2010-10-02T01:22:00.000-07:00</published><updated>2010-10-02T01:26:56.668-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>My iPhone development career has kicked off</title><content type='html'>And&amp;nbsp;with a great start.&lt;br /&gt;&lt;br /&gt;As mentioned in my previous post, I attended the &lt;a href="http://iphonedevcon.com/"&gt;iPhoneDevCon &lt;/a&gt;in San Diego. I was really surprised when I found out that it was the very first iPhone / iPad exclusive one. I felt special.&lt;br /&gt;&lt;br /&gt;Anyway, the conference was great, important people were there, really important people. To name some:&lt;br /&gt;&lt;br /&gt;-&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Aaron_Hillegass"&gt;Aaron Hillegass&lt;/a&gt; - Founder of &lt;a href="http://www.bignerdranch.com/"&gt;Big Nerd Ranch&lt;/a&gt;&amp;nbsp;and really important modern internet / macintosh pioneer. Also, author of several iPhone development books. He said that if you want to learn iPhone development, &lt;a href="http://www.amazon.com/iPhone-Programming-Ranch-Guide-Guides/dp/0321706242/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1286007338&amp;amp;sr=8-2-spell"&gt;this book&lt;/a&gt; is the definitive first step. Then he added "please buy it". I will definitely check it out.&lt;br /&gt;&lt;br /&gt;His conference was basically about how we are in the golden age of mobile development, and how we should exploit it and prepare for whatever is next.&lt;br /&gt;&lt;br /&gt;-&amp;nbsp;&lt;a href="http://www.linkedin.com/in/barneylee"&gt;Lee Barney&lt;/a&gt; - Writer of many books such as iPhone, AJAX, PHP.&lt;br /&gt;&lt;br /&gt;One of his conference (the one I attended) was about a new approach to programming to minimize code, bugs and complexity. Really, really interesting approach.&lt;br /&gt;&lt;br /&gt;This conference really got heated up at some point. The info he presented was really, really interesting, but is sounded too good to be true. At least I had my doubts, so I started asking him about the details and cons of this approach. A lot of really interesting questions arose from this, and at some point it turned into a debate of how good or bad the approach was.&lt;br /&gt;&lt;br /&gt;Basically, this approach is using a "funnel" in which all you code will get in, be validated, if validation passes, the funnel will spit out a result, if not it will return 'nil' (that's objective-C 'null'), so you can send a failure notification. But&amp;nbsp;I will go into more detail on this once I try it.&lt;br /&gt;&lt;br /&gt;- Jonathan Saggau (&lt;a href="http://jonathansaggau.com/blog/"&gt;blog&lt;/a&gt;) - An excellent programmer. I was surprised by how young he looks, really encourages me to keep plowing through my career.&lt;br /&gt;&lt;br /&gt;One of his conferences was about third party controls that mimic iPhone controls that apple does not provide through the iPhone SDK, such as the calendar view and the album cover view. You can find these in these websites: &lt;a href="http://three20.info/"&gt;three20&lt;/a&gt;, &lt;a href="http://tweetmeme.com/story/407168209/life-kid-kal-a-calendar-component-for-the-iphone"&gt;KAL Calendar&lt;/a&gt; and &lt;a href="http://fajkowski.com/blog/2009/08/02/openflow-a-coverflow-api-replacement-for-the-iphone/"&gt;OpenFlow CoverFlow&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;-&lt;br /&gt;&lt;br /&gt;Most importantly (to me), I got really, really used to XCode and objective-C, which is no walk in the park. They are really different from what I've been learning right now (Visual Studio and C# respectively). Like a co-worker said: "It's like moving from Spanish to German, the structure of the sentences is completely different". And yes, it is. I won't go into detail here, but I will do a post to compare C# and objective-C really soon.&lt;br /&gt;&lt;br /&gt;Anyway, I know this post was really brief; but it would take a week to talk about everything I learned in the conferences. I pinpointed the most important conferences I attended, and really important / good programmers, so if you want to improve your career as an iPhone developer, you should definitely check out these persons I mentioned and their work.&lt;br /&gt;&lt;br /&gt;Next post will have code, I promise!&lt;br /&gt;&lt;br /&gt;Thanks for reading, and happy coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-2670575101749555163?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/2670575101749555163/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/10/my-iphone-development-career-has-kicked.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2670575101749555163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2670575101749555163'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/10/my-iphone-development-career-has-kicked.html' title='My iPhone development career has kicked off'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-4304568140223505949</id><published>2010-09-21T12:34:00.000-07:00</published><updated>2010-09-21T12:34:20.959-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><title type='text'>Haven't blogged in a while</title><content type='html'>Well, lately I've been broadening my work fields, I'm really excited about it. Been working with WCF (as I have stated before), Silverlight, iPhone (learning only, not professionally yet) and soon iPad (oh! and some StarCraft II =P). But the real reason I haven't blogged is because I haven't found any really interesting problems / solutions to blog about, but with these new fields I'm working on I bet I'll find some really soon.&lt;br /&gt;&lt;br /&gt;This Monday through Wednesday (Sep 27 - 29, 2010) I'll be attending the iPhone DevCon in San Diego, which will kick-off my professional iPhone development. I'm THRILLED about it, perhaps that will be my next post.&lt;br /&gt;&lt;br /&gt;Anyway, I guess I'd better think of a new name for my blog, because "WPF dude" doesn't quite describe what I work on and blog about anymore.&lt;br /&gt;&lt;br /&gt;Thanks to everyone who reads me, and I hope you have found my blog at least a bit useful.&lt;br /&gt;&lt;br /&gt;Thanks for reading and happy coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-4304568140223505949?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/4304568140223505949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/09/havent-blogged-in-while.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/4304568140223505949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/4304568140223505949'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/09/havent-blogged-in-while.html' title='Haven&apos;t blogged in a while'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-7393551641115895912</id><published>2010-08-03T15:28:00.000-07:00</published><updated>2010-08-03T15:29:11.173-07:00</updated><title type='text'>Get WPF control from HWND handle</title><content type='html'>Just a quick post. I can't believe this is so easy and I spent hours trying to find something like this...&lt;br /&gt;&lt;br /&gt;Anyway, I asked in &lt;a href="http://stackoverflow.com/"&gt;StackOverflow&lt;/a&gt;, and turns out this is how you do it:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="prettyprint" style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"&gt;&lt;code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;span class="kwd" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: darkblue; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;var&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; rootVisual &lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;=&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="typ" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;HwndSource&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="typ" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;FromHwnd&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;(&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;hWnd&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;).&lt;/span&gt;&lt;span class="typ" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;RootVisual&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Yup, that easy.&lt;br /&gt;&lt;br /&gt;Thanks to &lt;a href="http://stackoverflow.com/users/364001/quartermeister"&gt;quartermeister &lt;/a&gt;for a &lt;a href="http://stackoverflow.com/questions/3400834/control-fromhandle-for-wpf/3401000#3401000"&gt;great answer&lt;/a&gt;. It deserves your upvote.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-7393551641115895912?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/7393551641115895912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/08/get-wpf-control-from-hwnd-handler.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/7393551641115895912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/7393551641115895912'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/08/get-wpf-control-from-hwnd-handler.html' title='Get WPF control from HWND handle'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-2069427002310067841</id><published>2010-07-28T22:40:00.000-07:00</published><updated>2010-07-28T22:49:20.450-07:00</updated><title type='text'>The GifImage (Animated GIFs for WPF)</title><content type='html'>So... Steve Ballmer... no GIF support in WPF? Ended up &lt;a href="http://www.youtube.com/watch?v=wvsboPUjrGc"&gt;too tired after a conference&lt;/a&gt; or something?&lt;br /&gt;&lt;br /&gt;Anyway, I found some code in codeplex (I can't find the link, I'll put a reference as soon as I find it), but I modified it a bit to fit our needs.&lt;br /&gt;&lt;br /&gt;The code I found started the gif right away or something. I don't remember right, so I created a few methods to show / hide (you probably won't need those) and to start / stop the animation (start / stop will be useful for you). As well as an AutoStart property, so you don't have to call the Start() method manually.&lt;br /&gt;&lt;br /&gt;So since you love downloading WPF projects,&amp;nbsp;here you go:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://rapidshare.com/files/409724702/GifImageProject.zip" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="_blank"&gt;&lt;img border="0" bx="true" height="242" src="http://4.bp.blogspot.com/_V1EbWLB6mo8/TFEUK5YNLDI/AAAAAAAAACw/OFWnfDxgGDI/s400/ballmer.jpg" width="400" alt="Click me for the code" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And here's the code. It's small this time:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media.Imaging;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; GifImageProject&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GifImage : Image&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Memmbers&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; GifBitmapDecoder _gifDecoder;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; Int32Animation _animation;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _isInitialized;&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Memmbers&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Properties&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; FrameIndex&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt;)GetValue(FrameIndexProperty); }&lt;br /&gt;            set { SetValue(FrameIndexProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty FrameIndexProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"FrameIndex"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GifImage), &lt;span class="kwrd"&gt;new&lt;/span&gt; FrameworkPropertyMetadata(0, &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyChangedCallback(ChangingFrameIndex)));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ChangingFrameIndex(DependencyObject obj, DependencyPropertyChangedEventArgs ev)&lt;br /&gt;        {&lt;br /&gt;            GifImage image = obj &lt;span class="kwrd"&gt;as&lt;/span&gt; GifImage;&lt;br /&gt;            image.Source = image._gifDecoder.Frames[(&lt;span class="kwrd"&gt;int&lt;/span&gt;)ev.NewValue];&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Defines whether the animation starts on it's own&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; AutoStart&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;bool&lt;/span&gt;)GetValue(AutoStartProperty); }&lt;br /&gt;            set { SetValue(AutoStartProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty AutoStartProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"AutoStart"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;bool&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GifImage), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(&lt;span class="kwrd"&gt;false&lt;/span&gt;, AutoStartPropertyChanged));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AutoStartPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;bool&lt;/span&gt;)e.NewValue)&lt;br /&gt;                (sender &lt;span class="kwrd"&gt;as&lt;/span&gt; GifImage).StartAnimation();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GifSource&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;)GetValue(GifSourceProperty); }&lt;br /&gt;            set { SetValue(GifSourceProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty GifSourceProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"GifSource"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GifImage), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty, GifSourcePropertyChanged));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GifSourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// Reinitialize animation everytime image is changed&lt;/span&gt;&lt;br /&gt;            (sender &lt;span class="kwrd"&gt;as&lt;/span&gt; GifImage).Initialize();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Properties&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Private Instance Methods&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Initialize()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// initialize the gifDecoder&lt;/span&gt;&lt;br /&gt;            _gifDecoder = &lt;span class="kwrd"&gt;new&lt;/span&gt; GifBitmapDecoder(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"pack://application:,,,"&lt;/span&gt; + &lt;span class="kwrd"&gt;this&lt;/span&gt;.GifSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);&lt;br /&gt;            &lt;span class="rem"&gt;// initialize the animation&lt;/span&gt;&lt;br /&gt;            _animation = &lt;span class="kwrd"&gt;new&lt;/span&gt; Int32Animation(0, _gifDecoder.Frames.Count - 1, &lt;span class="kwrd"&gt;new&lt;/span&gt; Duration(&lt;span class="kwrd"&gt;new&lt;/span&gt; TimeSpan(0, 0, 0, _gifDecoder.Frames.Count / 10, (&lt;span class="kwrd"&gt;int&lt;/span&gt;)((_gifDecoder.Frames.Count / 10.0 - _gifDecoder.Frames.Count / 10) * 1000))));&lt;br /&gt;            &lt;span class="rem"&gt;// repeat forever&lt;/span&gt;&lt;br /&gt;            _animation.RepeatBehavior = RepeatBehavior.Forever;&lt;br /&gt;            &lt;span class="rem"&gt;// set the image source&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Source = _gifDecoder.Frames[0];&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// set this to true so it doesn't get initialized again&lt;/span&gt;&lt;br /&gt;            _isInitialized = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Private Instance Methods&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Public Instance Methods&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Shows and starts the gif animation&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Show()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Visibility = Visibility.Visible;&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.StartAnimation();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Hides and stops the gif animation&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Hide()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Visibility = Visibility.Collapsed;&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.StopAnimation();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Starts the animation&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; StartAnimation()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!_isInitialized)&lt;br /&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.Initialize();&lt;br /&gt;&lt;br /&gt;            BeginAnimation(FrameIndexProperty, _animation);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Stops the animation&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; StopAnimation()&lt;br /&gt;        {&lt;br /&gt;            BeginAnimation(FrameIndexProperty, &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Public Instance Methods&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Thanks for reading, and I hope you find it useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-2069427002310067841?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/2069427002310067841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/07/gifimage-animated-gifs-for-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2069427002310067841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2069427002310067841'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/07/gifimage-animated-gifs-for-wpf.html' title='The GifImage (Animated GIFs for WPF)'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_V1EbWLB6mo8/TFEUK5YNLDI/AAAAAAAAACw/OFWnfDxgGDI/s72-c/ballmer.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-8889760968399012984</id><published>2010-07-16T21:09:00.000-07:00</published><updated>2010-07-17T03:31:31.665-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>The SegmentedSlider</title><content type='html'>Ok, I have to admit this was real fun to program. It was challenging and there was a lot of trial and error, but it's finished, and here it is.&lt;br /&gt;&lt;br /&gt;So basically this is a Slider with a segmented range. The regular WPF slider goes from, say, -1000 to +1000, and you can go through&amp;nbsp;the whole range&amp;nbsp;in a single mouse movement. That's pretty cool. But what if you wanted the user to be able to go to very granular values in that Slider? Say, you want to give the user the possibility of going to values like .01 or 10.76, you would need a HUUUUUUUUGE slider to do that. Of course you can also have a TextBox and have the user type the specific value, but some users are too lazy to type.&lt;br /&gt;&lt;br /&gt;Anyway, the cool thing about this segmented slider, is instead of showing you all the 2000 numbers at once, it goes by segments, so depending on your segment size you can be as granular as you want with your values. And of course, unless you want to give&amp;nbsp;your users a really bad time, don't do a range of -1000 to 1000 with segments of 10, unless of course&amp;nbsp;you want&amp;nbsp;your users to remember their teenage years.&lt;br /&gt;&lt;br /&gt;Anyway, this image will illustrate the way the slider works (sorry, I used paint and I'm no graphic designer):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_V1EbWLB6mo8/TEEfACUC07I/AAAAAAAAACc/b_hRi9zo0Qo/s1600/SegmentedSlider.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" hw="true" src="http://2.bp.blogspot.com/_V1EbWLB6mo8/TEEfACUC07I/AAAAAAAAACc/b_hRi9zo0Qo/s320/SegmentedSlider.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Get it? Hope you do, cause creating that image was no walk in the park.&lt;br /&gt;&lt;br /&gt;Every time the user is done moving the Slider's Thumb, the Thumb will return to the middle (unless the user is getting close to the absolute Min / Max), once the Thumb is back in the middle, there will be a range of, say -100 to the left and + 100 to the right.&lt;br /&gt;&lt;br /&gt;So yeah, the first thing I needed to do was to create a Threshold property, which controls the range I just mentioned. Once the threshold was there I needed AbsoluteMaximum and AbsoluteMinimum properties, which of course, control the real max and min of the slider. The regular Slider's Minimum and Maximum properties are used to represent the range, and are changed every time the slider's value changes.&lt;br /&gt;&lt;br /&gt;Here's everything I just described&amp;nbsp;in a quick&amp;nbsp;glance:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CalculateLimits()&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold != 0)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;double&lt;/span&gt; spaceLeftMax = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMaximum - &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value;&lt;br /&gt;        &lt;span class="kwrd"&gt;double&lt;/span&gt; spaceLeftMin = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMinimum - &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value;&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// if the space left in the max limit is smaller than the threshold, don't use the threshold&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (spaceLeftMax &amp;lt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Maximum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMaximum;&lt;br /&gt;        }&lt;br /&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;// else use the threshold&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Maximum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value + &lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold;&lt;br /&gt;        }&lt;br /&gt;        &lt;span class="rem"&gt;// if the space left in the min limit is smaller than the threshold, use the AbsoluteMinimum&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (spaceLeftMin &amp;gt; -&lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Minimum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMinimum;&lt;br /&gt;        }&lt;br /&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;// else use the threshold&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Minimum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value - &lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;Basically, when the slider's value is changed, the range is&amp;nbsp;recalculated like so:&lt;br /&gt;&lt;br /&gt;RangeMax = value + Threshold;&lt;br /&gt;RangeMin = value - Threshold;&lt;br /&gt;&lt;br /&gt;Only there are a few other operations to make sure we don't go over the absolute limits (that's what spaceLeftMax and spaceLeftMin are used for).&lt;br /&gt;&lt;br /&gt;This is the core method of the slider. The rest are just properties and validation. I had to make sure the limits are not recalculated while the user is dragging the Thumb, or else, the thumb would never leave the center (every time the thumb is move, the value of the slider is changed). Also some coersions to make sure the Value doesn't go over the AbsoluteMax / Min and vice versa.&lt;br /&gt;&lt;br /&gt;Binding gave me a lot of trouble too, so I had to create a relative value called SegmentValue to replace the regular Value. The problem was that when the Value was changed, the MaximumProperty went through the Validate method (a WPF standard method for DependencyProperties, I'll blog about this some time); basically, when the Value property reached the Max, the Maximum property said "Hey, this Value guy needs more space, I'll move a bit so he can get here",&amp;nbsp;which caused&amp;nbsp;some weird recursion problems, etc.&lt;br /&gt;&lt;br /&gt;So to fix this, I created the SegmentValue property, make sure YOU BIND TO THAT, instead of the regular Value property, or else, the slider won't work (believe me, I created the code).&lt;br /&gt;&lt;br /&gt;Anyway, since I know how you like downloading WPF projects, here it is.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://rapidshare.com/files/407389706/SegmentedSliderProject.zip"&gt;Download project&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And here's the whole SliderSegment&amp;nbsp;code so my blog looks cool.&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Data;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Input;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; SegmentedSliderProject&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SegmentedSlider : Slider&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Constructors&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; SegmentedSlider()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// Loaded is used just to bind the SegmentedSlider.ValueProperty to the SegmentValuePropertie&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Loaded += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(UndefinedLimitsSlider_Loaded);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Constructors&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Threshold Property&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// This controls the segment size, the Threshold is applied both to the left and right. If there's a&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// threshold of 100, the segment range will go from -100 to +100&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; Threshold&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(ThresholdProperty); }&lt;br /&gt;            set { SetValue(ThresholdProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ThresholdProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"Threshold"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(SegmentedSlider),&lt;br /&gt;            &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(10d, ThresholdPropertyChanged));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ThresholdPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            SegmentedSlider slider = sender &lt;span class="kwrd"&gt;as&lt;/span&gt; SegmentedSlider;&lt;br /&gt;&lt;br /&gt;            slider.CalculateLimits();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Threshold Property&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; SegmentValue Property&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// This value is treated as a relative value for each segment. And it's used instead&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// of the other Value (which I call absolute value in the scope of this class)&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; SegmentValue&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(SegmentValueProperty); }&lt;br /&gt;            set { SetValue(SegmentValueProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty SegmentValueProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"SegmentValue"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(SegmentedSlider),&lt;br /&gt;            &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(0e, SegmentValuePropertyChanged, CoerceSegmentValue));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SegmentValuePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;double&lt;/span&gt; SegmentValue = (&lt;span class="kwrd"&gt;double&lt;/span&gt;)e.NewValue;&lt;br /&gt;            SegmentedSlider slider = sender &lt;span class="kwrd"&gt;as&lt;/span&gt; SegmentedSlider;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// don't update any values if the user is dragging the slider, only when the value is changed by a different input&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// I. E. a databound TextBox&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (slider._isThumbDragging)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// use the SegmentValue to update the maximum / minimum before updating the actual Value&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// this skips the MaximumValidateValue method, avoiding some problems when updating the Max and Value&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (slider.SegmentValue &amp;gt;= slider.Maximum)&lt;br /&gt;            {&lt;br /&gt;                slider.Maximum = slider.SegmentValue + slider.Threshold;&lt;br /&gt;            }&lt;br /&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (slider.SegmentValue &amp;lt;= slider.Minimum)&lt;br /&gt;            {&lt;br /&gt;                slider.Minimum = slider.SegmentValue - slider.Threshold;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// set the SegmentValue to the actual value&lt;/span&gt;&lt;br /&gt;            slider.Value = slider.SegmentValue;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; CoerceSegmentValue(DependencyObject sender, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            SegmentedSlider slider = (SegmentedSlider)sender;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)&lt;span class="kwrd"&gt;value&lt;/span&gt; &amp;lt; slider.AbsoluteMinimum)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; slider.AbsoluteMinimum;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)&lt;span class="kwrd"&gt;value&lt;/span&gt; &amp;gt; slider.AbsoluteMaximum)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; slider.AbsoluteMaximum;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; SegmentValue Property&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; AbsoluteMaximum&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; AbsoluteMaximum&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(AbsoluteMaximumProperty); }&lt;br /&gt;            set { SetValue(AbsoluteMaximumProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty AbsoluteMaximumProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"AbsoluteMaximum"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(SegmentedSlider),&lt;br /&gt;            &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(10d, AbsoluteMaximumPropertyChanged, CoerceAbsoluteMaximum));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; CoerceAbsoluteMaximum(DependencyObject sender, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            SegmentedSlider slider = (SegmentedSlider)sender;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)&lt;span class="kwrd"&gt;value&lt;/span&gt; &amp;lt; slider.AbsoluteMinimum)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; slider.AbsoluteMinimum;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)&lt;span class="kwrd"&gt;value&lt;/span&gt; &amp;lt; slider.SegmentValue)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; slider.SegmentValue;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AbsoluteMaximumPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            (sender &lt;span class="kwrd"&gt;as&lt;/span&gt; SegmentedSlider).CalculateLimits();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; AbsoluteMaximum&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; AbsoluteMinimum&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; AbsoluteMinimum&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(AbsoluteMinimumProperty); }&lt;br /&gt;            set { SetValue(AbsoluteMinimumProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty AbsoluteMinimumProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"AbsoluteMinimum"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(SegmentedSlider),&lt;br /&gt;            &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(-10d, AbsoluteMaximumPropertyChanged, CoerceAbsoluteMinimum));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; CoerceAbsoluteMinimum(DependencyObject sender, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            SegmentedSlider slider = (SegmentedSlider)sender;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)&lt;span class="kwrd"&gt;value&lt;/span&gt; &amp;gt; slider.SegmentValue)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; slider.SegmentValue;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AbsoluteMinmumPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            (sender &lt;span class="kwrd"&gt;as&lt;/span&gt; SegmentedSlider).CalculateLimits();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; AbsoluteMinimum&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Event Handlers and Overrides&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UndefinedLimitsSlider_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// Bind SegmentValue to the actual Value so they are in sync&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// this method should only be called when the value changes by something different than dragging the slider&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// it's specifically made to avoid a problem with the "Maximum" property validation&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.GetBindingExpression(SegmentedSlider.ValueProperty) == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.SetBinding(SegmentedSlider.ValueProperty, &lt;span class="kwrd"&gt;new&lt;/span&gt; Binding(&lt;span class="str"&gt;"SegmentValue"&lt;/span&gt;) { Source = &lt;span class="kwrd"&gt;this&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// If no value has been set through binding, trigger limit calculation&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.SegmentValue == 0)&lt;br /&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.CalculateLimits();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnValueChanged(&lt;span class="kwrd"&gt;double&lt;/span&gt; oldValue, &lt;span class="kwrd"&gt;double&lt;/span&gt; newValue)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnValueChanged(oldValue, newValue);&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// only recalculate limits on ValueChanged IF the thumb is not being dragged&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// I. E. it's ok to update if a TextBox bound to the slider's "Value" property is updated&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// if we update while the thumb is being dragged we'll get some erratic behavior&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!_isThumbDragging)&lt;br /&gt;                CalculateLimits();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnPreviewMouseLeftButtonDown(e);&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// indicate dragging has started&lt;/span&gt;&lt;br /&gt;            _isThumbDragging = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnPreviewMouseLeftButtonUp(e);&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// calculate limits when drag ends&lt;/span&gt;&lt;br /&gt;            CalculateLimits();&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// indicate dragging has ended&lt;/span&gt;&lt;br /&gt;            _isThumbDragging = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Event Handlers and Overrides&lt;br /&gt;        &lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Threshold Behavior&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _isThumbDragging = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CalculateLimits()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold != 0)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;double&lt;/span&gt; spaceLeftMax = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMaximum - &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value;&lt;br /&gt;                &lt;span class="kwrd"&gt;double&lt;/span&gt; spaceLeftMin = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMinimum - &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value;&lt;br /&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// if the space left in the max limit is smaller than the threshold, don't use the threshold&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (spaceLeftMax &amp;lt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.Maximum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMaximum;&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;// else use the threshold&lt;/span&gt;&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.Maximum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value + &lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold;&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="rem"&gt;// if the space left in the min limit is smaller than the threshold, use the AbsoluteMinimum&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (spaceLeftMin &amp;gt; -&lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.Minimum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.AbsoluteMinimum;&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;// else use the threshold&lt;/span&gt;&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.Minimum = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Value - &lt;span class="kwrd"&gt;this&lt;/span&gt;.Threshold;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Threshold Behavior&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="csharpcode"&gt;Thanks for reading and happy coding!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-8889760968399012984?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/8889760968399012984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/07/segmentedslider.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/8889760968399012984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/8889760968399012984'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/07/segmentedslider.html' title='The SegmentedSlider'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_V1EbWLB6mo8/TEEfACUC07I/AAAAAAAAACc/b_hRi9zo0Qo/s72-c/SegmentedSlider.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-6872733490558018614</id><published>2010-07-16T11:35:00.000-07:00</published><updated>2010-07-16T13:06:25.047-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How do I know it&apos;s PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><title type='text'>I hate PHP, and here's why</title><content type='html'>This is a post from an old blog I had. It's basically how I started hating PHP. It was titled "My PHP nightmare". I hope you enjoy it and you hate PHP as much as I do. Thanks.&lt;br /&gt;&lt;br /&gt;------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;My PHP nightmare &lt;/b&gt;[October 1st 2009]&lt;br /&gt;&lt;br /&gt;So I was doing some PHP code in notepad last week; at this time I had a demo version of  Expression Web, and I noticed it reads PHP files, and just like Visual Studio with C#, it has keyword highlighting and some syntax checking; it doesn’t have autocomplete, but that’s ok. Anyway, after accidentaly finding out about these features of Expression Web, I decided to give it a shot. Unlucky for me, my PHP library files, are saved as .inc files, which Expression does not recognize as PHP files, thus, no syntax checking, no highlighting. I decided to save the file as .php to work with it, and when I finished, save it back as .inc, it worked, I had a good time doing my PHP library code in Expression, and then I hit save as…, FileName.inc.&lt;br /&gt;&lt;br /&gt;Hell broke loose when I uploaded my newly saved .inc file. My PHP headers didn’t work. Basically for headers to work, the webpage MUST be empty before you set the headers (no printing, not even a space character). I used the header to redirect to a different page when certain conditions were met:&lt;br /&gt;&lt;br /&gt;header(”Location: SomeOtherPage.php”);&lt;br /&gt;&lt;br /&gt;They worked before, but not anymore. What could’ve had happened? The error lacked information to base my search upon, or to ask around, and my code looked almost exactly the same as it was before. The error I was getting was:&lt;br /&gt;&lt;br /&gt;Cannot modify header information – headers already sent in YourClassName.inc : 1&lt;br /&gt;&lt;br /&gt;Where 1 is the line that threw the error. But wait… That’s the line where I declare the class… how can this be wrong:&lt;br /&gt;&lt;br /&gt;class MyClass&lt;br /&gt;{}&lt;br /&gt;&lt;br /&gt;So I checked my code line by line, I started googling all over the place, searching for “echo” keywords, to find out what was being printed before the header (remember? headers don’t work if you print something on the page before setting them). Double checked the code line by line, compared both files again and again. Until I stumbled upon this solution in Google (after 6 hours of searching and trying code). My .inc file could've been saved in an encoding that PHP does not like... Honestly, I was skeptic, and the fact that this solution was for a third party library made me doubt it even more. But I decided to take the code I had saved from Expression, put it in a notepad file, and from there, save again as .inc. Believe it or not, this solved my problem. It seems like the encoding from Expression, makes the file print an empty space once it gets to the webpage, hence, the headers did not work.&lt;br /&gt;&lt;br /&gt;My problem was the encoding that Expression used to save my file as .inc, PHP (or Apache) didn’t like it; my solution was to copy it over to notepad, and from there, save as .inc.&lt;br /&gt;&lt;br /&gt;Lucky for me, there was another problem with another file that I left for later, after solving this problem; this file had the exact same error, took me 2 minutes to fix it.&lt;br /&gt;&lt;br /&gt;Well this was my PHP nightmare from last week. I hope this helps someone out there who is struggling with PHP too.&lt;br /&gt;&lt;br /&gt;Thanks for reading, and happy coding.&lt;br /&gt;&lt;br /&gt;------------&lt;br /&gt;&lt;br /&gt;Oh God how I HATE PHP....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-6872733490558018614?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/6872733490558018614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/07/i-hate-php-and-heres-why.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/6872733490558018614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/6872733490558018614'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/07/i-hate-php-and-heres-why.html' title='I hate PHP, and here&apos;s why'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-6920314702434606521</id><published>2010-07-14T03:00:00.000-07:00</published><updated>2010-07-14T03:23:28.303-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>The Slider's Thumb, and the inferior ToolTip</title><content type='html'>So yeah, I was trying to get the Slider's Thumb, and I was having a lot of trouble finding a good way to do so. Why did I need the thumb you ask? Because I was having some trouble with the deficient options the Slider's ToolTip provides. I needed to show the ToolTip right above the Thumb, and some little Microsoft programmer decided to test our patience when trying to show the ToolTip ABOVE the Thumb.&lt;br /&gt;&lt;br /&gt;This is the regular ToolTip position:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_V1EbWLB6mo8/TD1z9amT_tI/AAAAAAAAABg/eFIGYzfIKJ4/s1600/toolTipBelow.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" rw="true" src="http://4.bp.blogspot.com/_V1EbWLB6mo8/TD1z9amT_tI/AAAAAAAAABg/eFIGYzfIKJ4/s320/toolTipBelow.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;It's fine, as long as you don't want anything fancy.&lt;br /&gt;&lt;br /&gt;Now what about moving it to the top:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Slider&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="8"&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="someSlider"&lt;/span&gt; &lt;span class="attr"&gt;ToolTip&lt;/span&gt;&lt;span class="kwrd"&gt;="Good day to you sir!"&lt;/span&gt;&lt;br /&gt; &lt;span class="attr"&gt;ToolTipService&lt;/span&gt;.&lt;span class="attr"&gt;Placement&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_V1EbWLB6mo8/TD12T-KaIlI/AAAAAAAAABo/Pu6VYlwsHg0/s1600/toolTipTop.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" rw="true" src="http://1.bp.blogspot.com/_V1EbWLB6mo8/TD12T-KaIlI/AAAAAAAAABo/Pu6VYlwsHg0/s320/toolTipTop.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;It's aligned to the Top Left of the Slider, not the Thumb anymore. No matter where your cursor is, the ToolTip is now fixed in that position.&lt;br /&gt;&lt;br /&gt;Let's try the center:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Slider&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="8"&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="someSlider"&lt;/span&gt; &lt;span class="attr"&gt;ToolTip&lt;/span&gt;&lt;span class="kwrd"&gt;="Good day to you sir!"&lt;/span&gt;&lt;br /&gt; &lt;span class="attr"&gt;ToolTipService&lt;/span&gt;.&lt;span class="attr"&gt;Placement&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_V1EbWLB6mo8/TD12wL6dxnI/AAAAAAAAABw/ebxsFqdLJNU/s1600/toolTipCenter.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" rw="true" src="http://1.bp.blogspot.com/_V1EbWLB6mo8/TD12wL6dxnI/AAAAAAAAABw/ebxsFqdLJNU/s320/toolTipCenter.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Same problem. Pretty annoying.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;So yeah, apparently it was difficult to keep the ToolTip aligned with the Thumb (which is by default), if you change the position of the ToolTip with the ToolTipService, then the ToolTip is aligned to the absolute position of the Slider, and we don't want that. We want to keep the ToolTip aligned to the Thumb, but ABOVE it. So I had to decide between go have fun and drink beer with my friends, or do code to get the Thumb and set the ToolTip to THAT instead of the Slider itself.... hmmmmm decisions...&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;So yeah, I created a Slider that shares its Thumb.&amp;nbsp;But most importantly (to me) two properties to handle the Thumb's position from XAML, you can even bind to them.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;First this is one way to get the Thumb:&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; DependencyObject GetThumb(DependencyObject root) &lt;br /&gt;{ &lt;br /&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (root &lt;span class="kwrd"&gt;is&lt;/span&gt; Thumb) &lt;br /&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; root; &lt;br /&gt; &lt;br /&gt;    DependencyObject thumb = &lt;span class="kwrd"&gt;null&lt;/span&gt;; &lt;br /&gt; &lt;br /&gt;    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; VisualTreeHelper.GetChildrenCount(root); i++) &lt;br /&gt;    { &lt;br /&gt;        thumb = GetThumb(VisualTreeHelper.GetChild(root, i)); &lt;br /&gt; &lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (thumb &lt;span class="kwrd"&gt;is&lt;/span&gt; Thumb) &lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; thumb; &lt;br /&gt;    } &lt;br /&gt; &lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; thumb; &lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;Or this is another one that a fellow programmer in &lt;a href="http://stackoverflow.com/questions/3233000/get-the-thumb-of-a-slider/3233806#3233806"&gt;StackOverflow&lt;/a&gt; suggested:&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Thumb GetThumb(Slider slider) &lt;br /&gt;{ &lt;br /&gt;    var track = slider.Template.FindName(&lt;span class="str"&gt;"PART_Track"&lt;/span&gt;, slider) &lt;span class="kwrd"&gt;as&lt;/span&gt; Track; &lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; track == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;null&lt;/span&gt; : track.Thumb; &lt;br /&gt;}&lt;/pre&gt;Use whichever you like the most, I haven't tested speed or anything (if you do, comment with your results). Anyway, that was the tricky part, now that I have the Thumb, I can pull off&amp;nbsp;the ToolTip trick, and put it&amp;nbsp;wherever the hell I want it.&lt;br /&gt;&lt;br /&gt;Another deficiency that really surprised me is that if you try to use StringFormat while binding on the Slider's thumb, it doesn't take it. Why? Beats me. Take this for example:&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Slider&lt;/span&gt; &lt;span class="attr"&gt;&lt;br /&gt;ToolTip&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding RelativeSource={RelativeSource Self},&lt;br /&gt; Path=Value, StringFormat=The Value: \{0:0.00\}}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;It still shows up like this:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_V1EbWLB6mo8/TD2OXrztq5I/AAAAAAAAACI/XkrVqvbSuXE/s1600/inferiorToolTip.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="275" rw="true" src="http://3.bp.blogspot.com/_V1EbWLB6mo8/TD2OXrztq5I/AAAAAAAAACI/XkrVqvbSuXE/s640/inferiorToolTip.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;What's up with that? It clearly states that the value should show only 2 decimals, and that it should show a prefix of "The Value: ". It clearly DOES NOT. Why? Beats me too.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Anyway, with my superior ToolTip solution,&amp;nbsp;I can put the ToolTip wherever the hell I want it, and however the hell I want it:&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_V1EbWLB6mo8/TD2Ojzskr1I/AAAAAAAAACQ/hy5RAR0Ahdo/s1600/superiorToolTip.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="224" rw="true" src="http://3.bp.blogspot.com/_V1EbWLB6mo8/TD2Ojzskr1I/AAAAAAAAACQ/hy5RAR0Ahdo/s640/superiorToolTip.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;I don't want to bore you with the details of the ThumbToolTipText or ThumbToolTipPlacement properties, they're basically DependencyProperties with a PropertyChanged callback, whenever the properties change I run some code to update the Thumb's ToolTip.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;But here's the code if you really want it:&lt;/div&gt;&lt;a href="javascript:expandcollapse('subtopic0001')"&gt;&lt;br /&gt;Click to show code&lt;/a&gt;&lt;br /&gt;&lt;span class="posthidden" id="subtopic0001"&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; FriendlySlider : Slider&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Get the thumb&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Thumb Thumb&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.GetThumb(&lt;span class="kwrd"&gt;this&lt;/span&gt;) &lt;span class="kwrd"&gt;as&lt;/span&gt; Thumb;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; DependencyObject GetThumb(DependencyObject root)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (root &lt;span class="kwrd"&gt;is&lt;/span&gt; Thumb)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; root;&lt;br /&gt;&lt;br /&gt;            DependencyObject thumb = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; VisualTreeHelper.GetChildrenCount(root); i++)&lt;br /&gt;            {&lt;br /&gt;                thumb = GetThumb(VisualTreeHelper.GetChild(root, i));&lt;br /&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (thumb &lt;span class="kwrd"&gt;is&lt;/span&gt; Thumb)&lt;br /&gt;                    &lt;span class="kwrd"&gt;return&lt;/span&gt; thumb;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; thumb;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Get the thumb&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Thumb ToolTip Dependency Propertes&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; PlacementMode ThumbToolTipPlacement&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (PlacementMode)GetValue(ThumbToolTipPlacementProperty); }&lt;br /&gt;            set { SetValue(ThumbToolTipPlacementProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ThumbToolTipPlacementProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"ThumbToolTipPlacement"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(PlacementMode),&lt;br /&gt;            &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(FriendlySlider), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(PlacementMode.Top, ThumbToolTipPlacementChanged));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ThumbToolTipText&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;)GetValue(ThumbToolTipTextProperty); }&lt;br /&gt;            set { SetValue(ThumbToolTipTextProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ThumbToolTipTextProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"ThumbToolTipText"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;),&lt;br /&gt;            &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(FriendlySlider), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(&lt;span class="kwrd"&gt;null&lt;/span&gt;, ThumbToolTipPlacementChanged));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ThumbToolTipPlacementChanged&lt;br /&gt;            (DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            FriendlySlider slider = sender &lt;span class="kwrd"&gt;as&lt;/span&gt; FriendlySlider;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (slider.Thumb != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;                slider.UpdateToolTip();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Thumb ToolTip Dependency Propertes&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Setup ToolTip&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; FriendlySlider()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.Loaded += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(FriendlySlider_Loaded);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FriendlySlider_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            UpdateToolTip();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UpdateToolTip()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt;(&lt;span class="kwrd"&gt;this&lt;/span&gt;.Thumb.ToolTip == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.Thumb.ToolTip = &lt;span class="kwrd"&gt;new&lt;/span&gt; ToolTip();&lt;br /&gt;&lt;br /&gt;            (&lt;span class="kwrd"&gt;this&lt;/span&gt;.Thumb.ToolTip &lt;span class="kwrd"&gt;as&lt;/span&gt; ToolTip).Content = &lt;span class="kwrd"&gt;this&lt;/span&gt;.ThumbToolTipText;&lt;br /&gt;&lt;br /&gt;            ToolTipService.SetPlacement(&lt;span class="kwrd"&gt;this&lt;/span&gt;.Thumb.ToolTip &lt;span class="kwrd"&gt;as&lt;/span&gt; ToolTip, &lt;span class="kwrd"&gt;this&lt;/span&gt;.ThumbToolTipPlacement);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Setup ToolTip&lt;br /&gt;    }&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;So yeah, bottom line, pretty deficient ToolTip options&amp;nbsp;for the Slider. Guess no Thumbs up for Microsoft this time (get it? Thumbs?).&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Thanks for reading, and happy coding!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-6920314702434606521?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/6920314702434606521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/07/rule-of-thumb-sliders-thumb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/6920314702434606521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/6920314702434606521'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/07/rule-of-thumb-sliders-thumb.html' title='The Slider&apos;s Thumb, and the inferior ToolTip'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_V1EbWLB6mo8/TD1z9amT_tI/AAAAAAAAABg/eFIGYzfIKJ4/s72-c/toolTipBelow.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-1222715222301756454</id><published>2010-06-25T11:31:00.000-07:00</published><updated>2010-06-25T15:51:18.127-07:00</updated><title type='text'>Dude, I'm so glad I'm not any of these guys</title><content type='html'>New post featuring: &lt;a href="http://www.sadtrombone.com/"&gt;The GNU/Stallmans&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/xSkCny-HtTw&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/xSkCny-HtTw&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Somebody owes an apology to the internet...&lt;br /&gt;&lt;br /&gt;They're almost like real &lt;a href="http://tantek.com/presentations/2008/06/how-to-be-a-superhero/ndynamitehandsup.jpg"&gt;Napoleon Dynamites&lt;/a&gt;, only he's cooler.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-1222715222301756454?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/1222715222301756454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/06/dude-im-so-glad-im-not-any-of-these.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1222715222301756454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1222715222301756454'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/06/dude-im-so-glad-im-not-any-of-these.html' title='Dude, I&apos;m so glad I&apos;m not any of these guys'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-3158212947200104451</id><published>2010-06-22T03:10:00.000-07:00</published><updated>2010-06-22T10:19:25.957-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Conferences'/><title type='text'>My second conference</title><content type='html'>Well, it's been a long time since the conference happened, but I really want to blog about it.&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;First of all, I want to thank the persons who invited me, teachers Consuelo Salgado&amp;nbsp;and Miguel Leyva. Consuelo was my Programming II teacher, she taught us some advanced C++ features (such as pointers and files), and two semesters later, she&amp;nbsp;taught us&amp;nbsp;a Database class. Miguel was our networking&amp;nbsp; teacher, and we learned a lot of interesting stuff&amp;nbsp; with him too (such as the OSI model, TCP/IP, etc.).&lt;/div&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;Anyway, I humbly (and really thankfully) accepted their offer; this time I was going to share the podium with 3 other persons, I had no idea who they were, and oh surprise. I arrived at the school, I was looking for Consuelo and Miguel to let them know that I was there already, when I find another one of my programming teachers, Diana Cazas (with her, we learned ASP.net with VisualBasic.net), I was really surprised and excited to see her, I told her I was there because I was invited to speak in a conference, and she said: "Oh yeah, me too! we're going to be there together!". This was a really REALLY big WTF moment in my life. I mean, she WAS my teacher, I learned a lot of stuff from HER, plus, she has like 10 years&amp;nbsp; of working experience. I got so nervous after learning that I was sharing the podium with MY TEACHER. "What can I say that she doesn't know?" was a question that circled my mind for a while.&lt;/div&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;Anyway, my teacher was the first person I learned&amp;nbsp;that was&amp;nbsp;sharing the podium with me, 20 minutes later, we get to the conference room where everyone was waiting for us, and I get introduced to the other two persons: an entrepreneur, owner of 5 companies; and another programmer / IT technician with around 12 years experience... yeah... my teacher, an entrepreneur with 5 companies, and a programmer with 12 years of working experience. Me? Oh yeah, a young programmer with 3 years of experience. I felt honored, but scared at the same time.&lt;/div&gt;&lt;br /&gt;Anyway, the conference started, and we&amp;nbsp;started answering the students' questions. Among some questions I can remember:&lt;br /&gt;&lt;br /&gt;- &lt;strong&gt;From what you learned&amp;nbsp;in school. What subject helped you the most?&lt;/strong&gt;&lt;br /&gt;My answer: I learned to learn on my own, investigate, doubt, and compare.&lt;br /&gt;&lt;br /&gt;- &lt;strong&gt;When did you decide you were going to work on your field and why?&lt;/strong&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;In my case: Second semester, when I learned C++ pointers and files with teacher Consuelo. The reason is because I realized I was really good when started tutoring my classmates in the subject because they were doing bad,&amp;nbsp;all of them did good after&amp;nbsp;I tutored them btw =P.&lt;/div&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;* This question was really important because (at least in Mexico), the Computer Information Systems major is really broad, and there are many paths you can take like: programming, networking, database administration, software design, auditing, among others.&lt;/div&gt;&lt;br /&gt;- &lt;strong&gt;What helps you&amp;nbsp;stay competent and current in your field?&lt;/strong&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;In my case: Read, read,&amp;nbsp;read! And of course, lots of&amp;nbsp;practice.&lt;/div&gt;&lt;br /&gt;Anyway, these are some of the questions that I can remember.&lt;br /&gt;&lt;br /&gt;Another thing that really got into me, is something my programming teacher Diana Cazas said:&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;- "When asked to do something difficult, don't think&amp;nbsp;WHY&amp;nbsp;CAN'T YOU do it, think&amp;nbsp;HOW CAN YOU do it."&lt;/div&gt;&lt;br /&gt;And yeah, she's right, in software, pretty much everything is possible, so it's stupid to say something can't be done, we should rather concentrate our energy in looking for a good way to do it,&amp;nbsp;and not&amp;nbsp;on&amp;nbsp;thinking excuses on why we can't do it.&lt;br /&gt;&lt;br /&gt;I also got this recognition that I'm very proud of, it's the second one I get, and I hope is not the last:&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;a href="http://1.bp.blogspot.com/_V1EbWLB6mo8/TCCHMeFVpGI/AAAAAAAAABU/YF5yF7csgJY/s1600/IMAG0041.jpg" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" ru="true" src="http://1.bp.blogspot.com/_V1EbWLB6mo8/TCCHMeFVpGI/AAAAAAAAABU/YF5yF7csgJY/s320/IMAG0041.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It says:&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;"To L. I. Juan Carlo Toribio Rojas for his valuable contribution in the 'Graduates Forum', where he shared his experiences in the professional scope.&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;May 7 2010&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;Signed by Julio Blas Flores, Director"&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;Where L. I. means "Licenciado en Informatica", in Mexico is common to acquire a title like this after finishing a bachelors degree.&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;The conference was a really great experience for me, sharing the podium with such succesful people was really astonishing, and being able to speak among them and have them agree with me, was priceless. The students were really attentive and interested on what we all had to say, and they really wanted to know our roles in our companies, and how we got there. In the end, I'm sure we all helped them out at least one bit.&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;Thanks for reading, I know this was long, and there was no code, but it's something that I'm really proud of, and I'd like to share with the world, so here it is.&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;Thanks again to my teachers&amp;nbsp;Consuelo and Miguel for inviting me, and thanks to everyone who shared the moment with me.&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;I promise, next post will have code!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-3158212947200104451?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/3158212947200104451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/06/my-second-conferenct.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/3158212947200104451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/3158212947200104451'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/06/my-second-conferenct.html' title='My second conference'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_V1EbWLB6mo8/TCCHMeFVpGI/AAAAAAAAABU/YF5yF7csgJY/s72-c/IMAG0041.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-2996650049535978725</id><published>2010-06-21T13:22:00.000-07:00</published><updated>2010-06-21T14:04:00.783-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xkcd'/><title type='text'>XKCD Monthly Tribute: Commented edition</title><content type='html'>Yeah, I'm starting a new series.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://imgs.xkcd.com/comics/commented.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://imgs.xkcd.com/comics/commented.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://xkcd.com/156/"&gt;http://xkcd.com/156/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-2996650049535978725?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/2996650049535978725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/06/xkcd-montly-tribute-commented-edition.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2996650049535978725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2996650049535978725'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/06/xkcd-montly-tribute-commented-edition.html' title='XKCD Monthly Tribute: Commented edition'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-1785647628580744694</id><published>2010-06-15T17:24:00.001-07:00</published><updated>2011-04-28T19:05:58.916-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>The Cartesian Grid</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;The CartesianGrid. I was here at work, working like usual, when I got assigned to create a control that shows a set of controls arranged in a 2x2 grid, and it worked all right, the controls were there. It needed to have selection, so I used a ListBox (yes, ListBox is lighter than ListView), I didn't need special functionality from the ListView anyway (at least not yet). Anyway, everything was merry, until I was told me the grid should show X and Y coordinates in the 2x2 grid (X = A, B, C to n1, Y = 1, 2, 3 to n2), and yes, hell broke loose.&lt;br /&gt;&lt;br /&gt;I started looking into it, reading here and there, looking for code that was close to what I needed, and oh surprise, I found NOTHING (well not really a surprise, WPF is such a young technology). I spent like 8 hours investigating, when I finally got assigned to something else. It was a relief, but I knew the grid coordinates would come back to hunt me, and so they did. So this time, I decided I would create them on my own, using methods I already knew or at least had read about in books, and yes, that worked.&lt;br /&gt;&lt;br /&gt;Sorry for the long story, but you have to know what I felt like, and you have to realize the excitement I felt when I finished my CartesianGrid, I almost jumped out of my chair, LITERALLY. So now that you know the story, and know how I felt, I'm really happy to share my code with you. Let's code!&lt;br /&gt;&lt;br /&gt;First of all, this is what you will end up with:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://www.screencast.com/users/CarloToribio/folders/Jing/media/3818dc5a-19d4-424a-bae6-899fb8433b61"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;Finished CartesianGrid Video&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_V1EbWLB6mo8/TBgkp8fCKVI/AAAAAAAAABA/aPGeq0G3Mjw/s1600/cartesianGrid.png"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;br /&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5483172849353107794" src="http://4.bp.blogspot.com/_V1EbWLB6mo8/TBgkp8fCKVI/AAAAAAAAABA/aPGeq0G3Mjw/s320/cartesianGrid.png" style="cursor: pointer; height: 320px; width: 275px;" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;And &lt;/span&gt;&lt;/span&gt;&lt;a href="http://rapidshare.com/files/399481612/CartesianGrid.zip.html"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;here's the project&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;Now let the fun begin:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; System.Globalization;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; System.Windows;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; System.Windows.Controls;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; System.Windows.Controls.Primitives;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; System.Windows.Media;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; CartesianGridProject&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/// &amp;amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/// Interaction logic for Window1.xaml&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/// &amp;amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;partial&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Window1 : Window&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Window1()&lt;br /&gt;{&lt;br /&gt;InitializeComponent();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Button_Click(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;cartesianGrid.Children.Add(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Label() { Content = &lt;/span&gt;&lt;/span&gt;&lt;span class="str"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;"Hello"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; });&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// First of all, inherit from UniformGrid, why do all the arranging logic when Bill Gates already did it for me?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; CartesianGrid : UniformGrid&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#region&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Members&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; _columns;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; _rows;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; _margin = 22;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; LinearGradientBrush _linearGradientBrush;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; _fontFamily = &lt;/span&gt;&lt;/span&gt;&lt;span class="str"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;"Myriad Pro"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; _fontSize = 18;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Members&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#region&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Properties&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; ShowCoordinatesText&lt;br /&gt;{&lt;br /&gt;get { &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;)GetValue(ShowCoordinatesTextProperty); }&lt;br /&gt;set { SetValue(ShowCoordinatesTextProperty, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;); }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;readonly&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; DependencyProperty ShowCoordinatesTextProperty =&lt;br /&gt;DependencyProperty.Register(&lt;/span&gt;&lt;/span&gt;&lt;span class="str"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;"ShowCoordinatesText"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;(CartesianGrid), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; FrameworkPropertyMetadata(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;, FrameworkPropertyMetadataOptions.AffectsRender));&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/* &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         * This part:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         * new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         * Is so whenever that property changes (ShowCoordinatesText) it tells the WPF drawing system it should re-render the control.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         * So whenever you have a DependencyProperty that will affect the visual state of your control, use a FrameworkPropertyMetadata&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         * object, and set it's FrameworkPropertyMetadataOptions to AffectsRender. There's plenty more options, but I'll go over them&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         * as I create more controls&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;         */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Properties&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#region&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Constructors&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; CartesianGrid()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;             * Just setting some private member I will use throughout my class, right now they're used in one method (at&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;             * least most of them), but this will make it a lot easier to extend the class later on.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;             */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;_linearGradientBrush = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; LinearGradientBrush();&lt;br /&gt;&lt;br /&gt;_linearGradientBrush.StartPoint = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(0.5, 1);&lt;br /&gt;_linearGradientBrush.EndPoint = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(0.5, 0);&lt;br /&gt;&lt;br /&gt;_linearGradientBrush.GradientStops.Add(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; GradientStop(Color.FromArgb(0xFF, 0x0A, 0x4C, 0x7D), 0));&lt;br /&gt;_linearGradientBrush.GradientStops.Add(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; GradientStop(Color.FromArgb(0xFF, 0x0D, 0x5E, 0x9B), 0.996));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Constructors&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#region&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Overrides&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;override&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; OnRender(DrawingContext drawingContext)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;             * This is where the fun starts. First of all, if the ShowCoordinatesText property is set to false, do nothing,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;             * otherwise, carry on.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;             */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (!&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.ShowCoordinatesText)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.Margin = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Thickness(0);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// This is the margin where the coordinates will show up, I'm using 22 right now, and only for the left and top margins&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// (remember that margins are set like Thickness(&amp;amp;lt;LEFT&amp;gt;, &amp;amp;lt;TOP&amp;gt;, &amp;amp;lt;RIGHT&amp;gt;, &amp;amp;lt;BOTTOM&amp;gt;), and the coordinates will show up&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// on the left and top of the control, so no need to set the bottom and right margins.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.Margin = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Thickness(_margin, _margin, 0, 0);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// These are some offsets I use to draw the letters, numbers and lines&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; xOffset = (&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.RenderSize.Width) / _columns;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; yOffset = (&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.RenderSize.Height) / _rows;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Some variables of the x and y positions, to make the code more readable and prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; x1 = 0;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; x2 = 0;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; y1 = 0;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; y2 = 0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// And this guy will help me center the numbers and latters right in the middle of each Row / Column&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; centerMargin = 0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Set the pen I will use to draw everything&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;Pen pen = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Pen(Brushes.Navy, 1);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Freeze the pen to improve performance (won't change any of it's attributes anyway)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (pen.CanFreeze)&lt;br /&gt;pen.Freeze();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Now, let's start drawing!! We'll use the DrawingContext object (drawingContext) that the OnRender event provides us,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// this is the drawingCotnext object that is used by WPF to draw the control, so we might as well use it.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// This draws the line on top (I'm using a -1 offset so the line is not drawn behind the items, because the items would&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// cover it)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawLine(pen, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.RenderSize.Width, -1), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(-1, -1));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// This draws the line on the left (-1 here too for the same reason)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawLine(pen, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(-1, -1), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(-1, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.RenderSize.Height));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// I know nowadays this is an odd way to initialize and indexing variable, but I'll use it outside the for loop,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// so live with it.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; i;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (i = 0; i &amp;amp;lt; _columns; i++)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// draw the text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;FormattedText formattedText =&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; FormattedText((i + 1).ToString(),&lt;br /&gt;CultureInfo.CurrentCulture,&lt;br /&gt;FlowDirection.LeftToRight,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Typeface(_fontFamily),&lt;br /&gt;_fontSize,&lt;br /&gt;_linearGradientBrush);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;/* this is the little equation to calculate the center of the column drawn, so I can use the value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;                 * as a margin and the text will end up right in the center of the column&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;                 * basically, I'm taking the offset diving it by 2, to get the absolute center, then subtract half the width of the&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;                 * number I'm drawing, then I add the real left offset, so it pushes, sounds complex, but it's not =P.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;                 * This way the number center is aligned with the center of the column, otherwise, the left edge&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;                 * of the number would be align to the center of the column, and no, we don't want that&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;                 */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;centerMargin = (i * xOffset) + ((xOffset / 2) - (formattedText.Width / 2));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// draw the number&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawText(formattedText, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(centerMargin, -_margin + 3));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// update the offsets so they move one notch to the right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;x1 = (xOffset * i) - 1;&lt;br /&gt;x2 = 0;&lt;br /&gt;y1 = xOffset * i;&lt;br /&gt;y2 = _margin * -1.5;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Draw the separator&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawLine(pen, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(x1, x2), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(y1, y2));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;x1 = (xOffset * i) - 1;&lt;br /&gt;x2 = 0;&lt;br /&gt;y1 = xOffset * i;&lt;br /&gt;y2 = _margin * -1.5;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// this draws one last separator on the right (the code above is where I used i outside the for loop&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawLine(pen, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(x1, x2), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(y1, y2));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// no need to reinitialize i, I saved myself some coding&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (i = 0; i &amp;amp;lt; _rows; i++)&lt;br /&gt;{&lt;br /&gt;FormattedText formattedText = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; FormattedText(((&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;char&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;)(i + 65)).ToString(),&lt;br /&gt;CultureInfo.CurrentCulture,&lt;br /&gt;FlowDirection.LeftToRight,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Typeface(_fontFamily),&lt;br /&gt;_fontSize,&lt;br /&gt;_linearGradientBrush);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// same logic to get the absolute center, only this time I use they height of the letter, not the width&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;centerMargin = (i * yOffset) + ((yOffset / 2) - (formattedText.Height / 2));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// draw the letter&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawText(formattedText, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(-_margin + 6, centerMargin));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// update offsets&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;x1 = 0;&lt;br /&gt;x2 = (yOffset * i) - 1;&lt;br /&gt;y1 = _margin * -1.5;&lt;br /&gt;y2 = yOffset * i;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// using extension method to snap to pixels, supposedly this is a solution for pixelation, but it doesn't work here&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawLine(pen, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(x1, x2), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(y1, y2));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// use i outside the for loop again (I hope I don't scare any potential employers for doing this, sheesh)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;x1 = 0;&lt;br /&gt;x2 = (yOffset * i) - 1;&lt;br /&gt;y1 = _margin * -1.5;&lt;br /&gt;y2 = yOffset * i;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// draw the last separator on the bottom&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;drawingContext.DrawLine(pen, &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(x1, x2), &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Point(y1, y2));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// send back the drawingContext object&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.OnRender(drawingContext);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;override&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Size ArrangeOverride(Size arrangeSize)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Here I call invalidate visual. This method gets called when the control contents are rearranged (that is, when the&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// the number of Rows / Columns changes, in the case of the UniformGrid)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.InvalidateVisual();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Now get the number of columns and rows (this method happens before OnRender, and OnRender needs the number of&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// columns and rows&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.Columns != 0 &amp;amp;&amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.Rows != 0)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// if explictly set, just get them from their properties&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;_rows = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.Rows;&lt;br /&gt;_columns = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.Columns;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.ArrangeOverride(arrangeSize);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// if not explicitly set, calculate the size of the largets of its children (since it's a UNIFORM grid, every cell&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// will be as big as the biggest one, that is, if a control needs a 10x10, and another a 100x100, the 10x10 will be&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// 100x100 to keep the uniformity, otherwise it would be called NotUniformGrid.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// Once we have the size of the largest child, divide the actual height / width of the grid, by the height / width&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// of said child, THAT will give you the number of rows and columns&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;Size arrangedSize = &lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.ArrangeOverride(arrangeSize);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; maxChildDesiredWidth = 0.0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;double&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; maxChildDesiredHeight = 0.0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;//  Measure each child, keeping track of max desired width &amp;amp; height.  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; i = 0, count = Children.Count; i &amp;amp;lt; count; ++i)&lt;br /&gt;{&lt;br /&gt;UIElement child = Children[i];&lt;br /&gt;&lt;br /&gt;Size childDesiredSize = child.DesiredSize;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (maxChildDesiredWidth &amp;amp;lt; childDesiredSize.Width)&lt;br /&gt;{&lt;br /&gt;maxChildDesiredWidth = childDesiredSize.Width;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (maxChildDesiredHeight &amp;amp;lt; childDesiredSize.Height)&lt;br /&gt;{&lt;br /&gt;maxChildDesiredHeight = childDesiredSize.Height;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; (maxChildDesiredHeight == 0 || maxChildDesiredWidth == 0)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; arrangedSize;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// calculate the columns&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;_columns = Convert.ToInt32(Math.Floor(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.DesiredSize.Width / maxChildDesiredWidth));&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;// calculate the rows&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;&lt;br /&gt;_rows = Convert.ToInt32(Math.Floor(&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;.DesiredSize.Height / maxChildDesiredHeight));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; arrangedSize;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="preproc"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms';"&gt; Overrides&lt;br /&gt;}&lt;br /&gt;}  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-1785647628580744694?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/1785647628580744694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/06/cartesian-grid.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1785647628580744694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1785647628580744694'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/06/cartesian-grid.html' title='The Cartesian Grid'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_V1EbWLB6mo8/TBgkp8fCKVI/AAAAAAAAABA/aPGeq0G3Mjw/s72-c/cartesianGrid.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-4040098240852945441</id><published>2010-06-08T12:43:00.000-07:00</published><updated>2010-06-08T12:53:03.681-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><title type='text'>What's going on?</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Gonna keep on blogging next week, I've been going through some personal stuff, but I'm tying the loose ends now. Anyway, there's a lot of stuff I want to blog about:&lt;br /&gt;&lt;br /&gt;- I created a cool CartesianGrid control for WPF (basically it's a UniformGrid that shows X and Y axes coordinates, pretty fun stuff)&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;- My conference in Mexico (which went great! I'll post pics)&lt;br /&gt;- WCF (I haven't had a lot of time to study lately for these problems, but I'm picking up again soon)&lt;br /&gt;- &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;a href="http://www.sadtrombone.com/" target="_blank"&gt;Make some more fun of PHP&lt;/a&gt; (haha love that)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;There's more stuff I want to blog about, but that's what I can remember right now. What hurts more is that I've stopped studying for my WCF certification for almost 3 weeks now, which would also give me some more material to blog about.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-4040098240852945441?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/4040098240852945441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/06/whats-going-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/4040098240852945441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/4040098240852945441'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/06/whats-going-on.html' title='What&apos;s going on?'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-8065345144129340328</id><published>2010-05-25T13:17:00.000-07:00</published><updated>2010-05-26T18:42:39.637-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How do I know it&apos;s PHP'/><title type='text'>How do I know it's PHP? Google edition</title><content type='html'>Fill the blank:&lt;br /&gt;&lt;br /&gt;- If you google "___ sucks", you get more than 12,000,000 results.&lt;br /&gt;- What is PHP?&lt;br /&gt;&lt;br /&gt;Oh yes, &lt;a href="http://www.sadtrombone.com"&gt;PHP made my day again lol&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Anyway, here are the results:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.google.com/search?q=php+sucks"&gt;PHP Sucks&lt;/a&gt; - 12,600,000 results&lt;br /&gt;&lt;a href="http://www.google.com/search?hl=en&amp;q=C%23+sucks&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai="&gt;C# Sucks&lt;/a&gt; - 200,000 results (proximately 1.5% of PHP results)&lt;br /&gt;&lt;a href="http://www.google.com/search?hl=en&amp;q=C%2B%2B+sucks&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai="&gt;C++ Sucks&lt;/a&gt; - 279,000 results (a little more than C#, I'm surprised)&lt;br /&gt;&lt;a href="http://www.google.com/search?hl=en&amp;q=visual+basic+sucks&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai="&gt;Visual Basic sucks&lt;/a&gt; - WOAH! 163,000 results, even less than C#, now I AM surprised&lt;br /&gt;&lt;br /&gt;I lol at PHP.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-8065345144129340328?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/8065345144129340328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/05/how-do-i-know-its-php-google-edition.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/8065345144129340328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/8065345144129340328'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/05/how-do-i-know-its-php-google-edition.html' title='How do I know it&apos;s PHP? Google edition'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-9053451117009398832</id><published>2010-05-06T18:10:00.000-07:00</published><updated>2010-05-06T18:24:20.360-07:00</updated><title type='text'>2nd conference in Mexico</title><content type='html'>I'm very honored to have been invited again to speak in a conference in the university I graduated from Universidad Autónoma de Baja California (aka UABC). The first time I didn't have this blog, so I didn't blog it, but this time I do.&lt;br /&gt;&lt;br /&gt;The first conference was back in November 2008, and I had a lot of fun. Students were really attentive and I think I helped out in their careers even a bit. I talked a little bit about C# 3.0, WPF, Silverlight, LINQ, and about the project I was working on back then. But what I stressed out the most is that they should read and be willing to learn anything new that comes out; since I believe that's what really helps you be competitive in today's programming market, technology evolves extremely fast, and you need to catch up as much as you can. And to enforce their reading, I gave out some books.&lt;br /&gt;&lt;br /&gt;Anyway, this time I'll be talking about my career as a programmer, and not about programming per se. I won't be alone this time either, it'll be me and I'm guessing around 4 more people (all UABC graduates), we'll all be speaking and answering the students' questions. It sounds like it'll be even more fun than last time!&lt;br /&gt;&lt;br /&gt;Well, hope everything goes well, and sure hope I get invited again! And I take this chance to semi-publicly thank my teachers who invited me there, Consuelo and Miguel.&lt;br /&gt;&lt;br /&gt;Thanks!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-9053451117009398832?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/9053451117009398832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/05/2nd-conference-in-mexico.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/9053451117009398832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/9053451117009398832'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/05/2nd-conference-in-mexico.html' title='2nd conference in Mexico'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-2567800361348675695</id><published>2010-05-03T14:13:00.000-07:00</published><updated>2010-05-03T14:24:50.744-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><title type='text'>At the Visual Studio 2010 launch event in San Diego</title><content type='html'>Not really what I expected, they gave out a VS2010 Ultimate TRIAL WTH Bill Gates, where is my full copy?? Anyway, I'm learning interesting stuff, I'll blog about it later in the week. Among others:&lt;br /&gt;&lt;br /&gt;SmallBasic - Programming for kids&lt;br /&gt;Extension manager - Integrated extension manager in VS2010&lt;br /&gt;XAML intellisense - Self explanatory&lt;br /&gt;&lt;br /&gt;It's not as good as I thought, but not too bad either.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-2567800361348675695?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/2567800361348675695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/05/at-visual-studio-2010-launch-event-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2567800361348675695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2567800361348675695'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/05/at-visual-studio-2010-launch-event-in.html' title='At the Visual Studio 2010 launch event in San Diego'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-1408422756121025854</id><published>2010-04-14T23:52:00.000-07:00</published><updated>2010-04-15T00:27:20.731-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Exception Handling'/><title type='text'>The StackTrace</title><content type='html'>Well, here's a quick one. Ever wondered how to log an exception with to-the-line detail? Well, this is what you need. The StackTrace .net class can get a lot of info of your exception into an object that you can actually use.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://rapidshare.com/files/376073737/StackTraceConsoleProject.zip.html"&gt;Download project here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A few things are required though:&lt;br /&gt;&lt;br /&gt;1) Preferably, you must deploy in Debug mode (so the JIT compiler Code Optimization doesn't kick in). If Code Optimization is on, you will get inaccurate line numbers, although pretty close, but inaccurate. You can still deploy in release mode, but make sure Code Optimization is turned off (from the project's Properties, Build Tab):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_V1EbWLB6mo8/S8a72f-ZsOI/AAAAAAAAAAw/UkOjjfQgXR0/s1600/codeoptimization.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 212px;" src="http://3.bp.blogspot.com/_V1EbWLB6mo8/S8a72f-ZsOI/AAAAAAAAAAw/UkOjjfQgXR0/s320/codeoptimization.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5460258143203864802" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You must be asking yourself "Why does code optimization causes inaccurate line numbers?", well the answer is simple. The JIT compiler code optimization, takes your code (methods, loops and such), and uses a mechanism called "Inline Methods" to optimize your code (&lt;a href="http://blogs.msdn.com/ericgu/archive/2004/01/29/64717.aspx"&gt;more details about inline methods here&lt;/a&gt;). So, when inline methods are used, your code actually changes, because the lines change, hence, the inaccuracy of the line numbers. You could say, the JIT makes your methods smaller by converting a method call into a one line operation.&lt;br /&gt;&lt;br /&gt;2) You MUST include your Program Debug Database files (PDB). This is essential or the StackTrace class will NOT be able to get any info about your exception.&lt;br /&gt;&lt;br /&gt;Let's do some code now:&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Diagnostics;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; StackTraceConsoleProject&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;        {&lt;br /&gt;            FailClass FAIL = &lt;span class="kwrd"&gt;new&lt;/span&gt; FailClass();&lt;br /&gt;            &lt;br /&gt;            FAIL.Fail();&lt;br /&gt;&lt;br /&gt;            Console.Read();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// FAIL class will fail&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; FailClass&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// FAIL method will fail.&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Fail()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Exception(&lt;span class="str"&gt;"Fail class has FAILED."&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.GetFAILInfo(ex);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// This gets the FAIL info&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="ex"&amp;gt;The FAIL exception&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GetFAILInfo(Exception ex)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; infoString = String.Empty;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// Generate your stack trace class and provide it with your exception&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// fNeedFileInfo is set to true so it gets the file name, number, etc. Otherwise it won't&lt;/span&gt;&lt;br /&gt;            StackTrace stackTrace = &lt;span class="kwrd"&gt;new&lt;/span&gt; StackTrace(ex, &lt;span class="kwrd"&gt;true&lt;/span&gt; &lt;span class="rem"&gt;/* fNeedFileInfo */&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// This for loop will navigate through the stack of your exception and display the whole trace&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// of the call to the method that caused the exception. In this case, just one method is displayed&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; stackTrace.FrameCount; i++)&lt;br /&gt;            {&lt;br /&gt;                StackFrame frame = stackTrace.GetFrame(i);&lt;br /&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(frame.GetFileName()))&lt;br /&gt;                {&lt;br /&gt;                    infoString = String.Format(&lt;span class="str"&gt;"File name: {0}\nMethod Name: {1}\nLine number: {2}\n\n"&lt;/span&gt;,&lt;br /&gt;                    Path.GetFileName(frame.GetFileName()), frame.GetMethod().ToString(), frame.GetFileLineNumber().ToString());&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// print the info&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span class="str"&gt;"Exception info: {0} \n{1}"&lt;/span&gt;, ex.Message, infoString);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, you have to realize that including the PDB files is potentially dangerous, as it makes reverese engineering your application a lot easier, so doing this sort of exception tracking is recommended in the testing phase of the app, and not for production.&lt;br /&gt;&lt;br /&gt;Hope this helps you as it helped me. Thanks for reading, and happy coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-1408422756121025854?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/1408422756121025854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/04/stacktrace.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1408422756121025854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1408422756121025854'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/04/stacktrace.html' title='The StackTrace'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_V1EbWLB6mo8/S8a72f-ZsOI/AAAAAAAAAAw/UkOjjfQgXR0/s72-c/codeoptimization.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-2770047550787122162</id><published>2010-04-14T13:16:00.000-07:00</published><updated>2010-04-14T14:48:02.033-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How do I know it&apos;s PHP'/><title type='text'>How do I know it's PHP? No method overloading</title><content type='html'>- It's a "general-purpose programming language" that has no method overloading.&lt;br /&gt;- What is PHP?&lt;br /&gt;&lt;br /&gt;Or perhaps there is a &lt;a href="http://www.dinke.net/blog/en/2007/08/01/method-overloading-in-php5/"&gt;really painful way&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Anyway, I just wanted to make fun of PHP. &lt;a target="_blank" href="http://www.sadtrombone.com/"&gt;PHP sucks... hahaha...&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-2770047550787122162?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/2770047550787122162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/04/how-do-i-know-its-php-no-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2770047550787122162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/2770047550787122162'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/04/how-do-i-know-its-php-no-method.html' title='How do I know it&apos;s PHP? No method overloading'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-1933149615578944180</id><published>2010-04-13T00:26:00.001-07:00</published><updated>2010-04-13T01:17:07.008-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF Learning</title><content type='html'>Just finished chapter one, pretty cool stuff. &lt;a href="http://www.amazon.com/MCTS-Self-Paced-Training-70-503-PRO-Certification/dp/0735625654/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1271143625&amp;sr=8-1"&gt;This is the book&lt;/a&gt; I'm reading, it's actually the first time I read a Microsoft training kit book, and it's pretty nice, so far I've understood everything I believe. So yeah, WCF is not bad at all!&lt;br /&gt;&lt;br /&gt;Few acronyms I have to memorize:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SOAP&lt;/strong&gt; - Service Oriented Application&lt;br /&gt;&lt;strong&gt;MSMQ&lt;/strong&gt; - Microsoft Message Queuing&lt;br /&gt;&lt;strong&gt;MEP&lt;/strong&gt;  - Message Exchange Patterns&lt;br /&gt;&lt;strong&gt;DSL&lt;/strong&gt;  - Domain Specific Language&lt;br /&gt;&lt;strong&gt;MTOM&lt;/strong&gt; - Message Transmition Optimization Mechanism (MTOM sounds funny)&lt;br /&gt;&lt;br /&gt;I can only remember &lt;strong&gt;SOAP&lt;/strong&gt;, &lt;strong&gt;MEP&lt;/strong&gt; and of course &lt;strong&gt;MTOM&lt;/strong&gt; right now. I suck at memorizing stuff.&lt;br /&gt;&lt;br /&gt;Anyway, coming next, the different types of Service Contracts, then MEPs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-1933149615578944180?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/1933149615578944180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/04/wcf-learning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1933149615578944180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/1933149615578944180'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/04/wcf-learning.html' title='WCF Learning'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-5746252015122229100</id><published>2010-04-06T17:11:00.000-07:00</published><updated>2010-04-06T17:21:15.599-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><title type='text'>WCF Certification</title><content type='html'>Guess I'm gonna have to make a new blog when I get it: "The WCF dude", or maybe merge them? "The WP/CF dude". W and F stand for the same words in both acronyms anyway, and it looks cool. Or maybe just forget about the acronym "The Windows Presentation and Communication Foundation Dude"? nah...&lt;br /&gt;&lt;br /&gt;The WP/CF dude blog. Coming soon...&lt;br /&gt;&lt;br /&gt;Anyway, I'll be posting about my progress and what I learn about WCF. Some big ass books I gotta read...&lt;br /&gt;&lt;br /&gt;Stay tuned for some WCF magic!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-5746252015122229100?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/5746252015122229100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/04/wcf-certification.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/5746252015122229100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/5746252015122229100'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/04/wcf-certification.html' title='WCF Certification'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-9112206973566221492</id><published>2010-03-29T12:49:00.000-07:00</published><updated>2010-03-29T12:54:14.013-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Not everything is about WPF'/><title type='text'>How I became a programmer</title><content type='html'>I just posted &lt;a target="_blank"  href="http://stackoverflow.com/questions/2462351/how-do-the-young-start-programming-nowadays/2540704#2540704"&gt;this answer in stackoverflow.com&lt;/a&gt;, I thought it would look cool in my blog:&lt;br /&gt;&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;1984:&lt;/span&gt; I was born.&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;1986:&lt;/span&gt; My first NES game console (which doomed me to be an indoors geek)&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;1996:&lt;/span&gt; My first personal computer, a Pentium&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;1996 - 1997:&lt;/span&gt; My dad hated me because I always broke the computer doing my experiments, but that helped me learn&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;1997 - 1999:&lt;/span&gt; I knew my way pretty good around the computer and started gaming there (Doom, Doom II, Wolfstein 3D, Duke Nukem I believe)&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;1999:&lt;/span&gt; I was an expert Windows 95 / 98 user, I knew a lot of features and I could do a lot of things in MS-DOS (In junior high I chose computer class because I knew I'd ace it, and I did)&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2000 - 2002:&lt;/span&gt; My interest for programming started, up until then, computers told me what I could do with them, and I wanted to make computers do what I wanted them to&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2002:&lt;/span&gt; My first C++ "Hello World" program int main { cout &lt;&lt; "Hello world!"; return 0; }, also C++ basics (loops and control structures)&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2003:&lt;/span&gt; C++ pointers and files, also data structures (I never got to study graphs though =()&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2004:&lt;/span&gt; Started learning C# and asp.net on my own, I made my first asp.net real world application as social service for my university, it was a success! Although it was really poorly coded.&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2004-2:&lt;/span&gt; Delphi, pascal, unix, as400, PHP, databases (loved databases, hated the rest)&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2005:&lt;/span&gt; Got really good with C# and asp.net, started experimenting with Windows Apps&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2006:&lt;/span&gt; They started teaching us the .net framework in school (although in VB, I asked the teacher if I could do my homework in C# and she said: NO! YOU GOTTA LEARN WHAT I TEACH YOU!) Also I learned a little bit of PROLOG, I thought it was fun&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2007 - 2009:&lt;/span&gt; First programming job C# and asp.net (also database managing / programming)&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;2009:&lt;/span&gt; Second programming job C# and WPF (I'm currently here)&lt;br /&gt;&lt;br /&gt;Yeah, I blame the NES.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-9112206973566221492?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/9112206973566221492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/03/how-i-became-programmer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/9112206973566221492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/9112206973566221492'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/03/how-i-became-programmer.html' title='How I became a programmer'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-6442079519176745171</id><published>2010-03-04T22:21:00.000-08:00</published><updated>2010-03-04T22:58:19.584-08:00</updated><title type='text'>Drawing the grid</title><content type='html'>I ended up using a different method than what I explained in my previous post. The big difference is that I'm not using the list of visuals, and I'm not overriding the same stuff. My class still derives from framework, but since it isn't interactive (no clicks, mouse over, etc.) I didn't need to grab a visual, add that stuff, and put in the the list of visuals. Let's code.&lt;br /&gt;&lt;br /&gt;First of all &lt;a href="http://rapidshare.com/files/359158599/GridTest.zip.html" Target="_blank"&gt;here's the project file&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now, let us begin explaining.&lt;br /&gt;&lt;br /&gt;The important thing here is to override the OnRender() method, why? Because at that time, the object inheriting from FrameworkElement already knows what's its DesiredSize (this is the size it WANTS to use to be drawn, the ActualSize is what its AFTER being drawn, by the end of the OnRender, the DesiredSize and ActualSize usually differ).&lt;br /&gt;&lt;br /&gt;So, now that we know what size the grid desires to have, we can do something. In my case, I'm using that information to know how many grids and rows I'll draw, with some cool looking code, I was able to achieve that. Here's the code:&lt;br /&gt;&lt;br /&gt;The CustomGrid:&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; GridTest&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CustomGrid : FrameworkElement&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Dependency Properties&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; _minimumCellSize = 50;&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; CellHeight&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(CellHeightProperty); }&lt;br /&gt;            set { SetValue(CellHeightProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty CellHeightProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"CellHeight"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CustomGrid), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(_minimumCellSize, VisualPropertyChangedCallback), &lt;span class="kwrd"&gt;new&lt;/span&gt; ValidateValueCallback(CellSizeValidateCallback));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; CellWidth&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(CellWidthProperty); }&lt;br /&gt;            set { SetValue(CellWidthProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty CellWidthProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"CellWidth"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CustomGrid), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(_minimumCellSize, VisualPropertyChangedCallback), &lt;span class="kwrd"&gt;new&lt;/span&gt; ValidateValueCallback(CellSizeValidateCallback));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Brush Stroke&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (Brush)GetValue(StrokeProperty); }&lt;br /&gt;            set { SetValue(StrokeProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty StrokeProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"Stroke"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Brush), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CustomGrid), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(Brushes.Transparent, VisualPropertyChangedCallback));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; StrokeThickness&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt;)GetValue(StrokeThicknessProperty); }&lt;br /&gt;            set { SetValue(StrokeThicknessProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty StrokeThicknessProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"StrokeThickness"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;double&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CustomGrid), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(0E, VisualPropertyChangedCallback));&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; DashStyle DashStyle&lt;br /&gt;        {&lt;br /&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (DashStyle)GetValue(DashStyleProperty); }&lt;br /&gt;            set { SetValue(DashStyleProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty DashStyleProperty =&lt;br /&gt;            DependencyProperty.Register(&lt;span class="str"&gt;"DashStyle"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DashStyle), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CustomGrid), &lt;span class="kwrd"&gt;new&lt;/span&gt; UIPropertyMetadata(&lt;span class="kwrd"&gt;new&lt;/span&gt; DashStyle(), VisualPropertyChangedCallback));&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// all the dependency properties are tied to this callback so the visual updates itself when any of them changes&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; VisualPropertyChangedCallback(DependencyObject o, DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// this method invalidates the state of the visual, causing a render&lt;/span&gt;&lt;br /&gt;            (o &lt;span class="kwrd"&gt;as&lt;/span&gt; CustomGrid).InvalidateVisual();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; CellSizeValidateCallback(&lt;span class="kwrd"&gt;object&lt;/span&gt; target)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// just so the grid's height or width don't go below 50&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// this method is called by both Height and Width DependencyProperties&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)target &amp;lt; _minimumCellSize)&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Dependency Properties&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; Overrides&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// override drawing to draw the grid&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnRender(DrawingContext drawingContext)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// get the RenderDesiredSize, and divide it by the size of its cells so we know how many cells to draw vertically&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; cellsVertically = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)Math.Ceiling(&lt;span class="kwrd"&gt;this&lt;/span&gt;.RenderSize.Height / &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellHeight);&lt;br /&gt;            &lt;span class="rem"&gt;// same horizontally&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; cellsHorizontally = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)Math.Ceiling(&lt;span class="kwrd"&gt;this&lt;/span&gt;.RenderSize.Width / &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellWidth);&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// this offsets are used to move right or down to draw the next row or column&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;double&lt;/span&gt; verticalOffset = 0;&lt;br /&gt;            &lt;span class="kwrd"&gt;double&lt;/span&gt; horizontalOffset = 0;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// the pen is defined here, with the stroke and thickness set in the xaml&lt;/span&gt;&lt;br /&gt;            Pen pen = &lt;span class="kwrd"&gt;new&lt;/span&gt; Pen(&lt;span class="kwrd"&gt;this&lt;/span&gt;.Stroke, &lt;span class="kwrd"&gt;this&lt;/span&gt;.StrokeThickness);&lt;br /&gt;&lt;br /&gt;            pen.DashStyle = &lt;span class="kwrd"&gt;this&lt;/span&gt;.DashStyle;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// draw vertical cells&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt;= cellsHorizontally; i++)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; j = 0; j &amp;lt; cellsVertically; j++)&lt;br /&gt;                {&lt;br /&gt;                    drawingContext.DrawLine(pen,&lt;br /&gt;                        &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(horizontalOffset, verticalOffset),&lt;br /&gt;                        &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(horizontalOffset, &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellHeight + verticalOffset));&lt;br /&gt;&lt;br /&gt;                    verticalOffset += &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellHeight;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                horizontalOffset += &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellWidth;&lt;br /&gt;                verticalOffset = 0;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            horizontalOffset = 0;&lt;br /&gt;            verticalOffset = 0;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// draw horizontal cells&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt;= cellsVertically; i++)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; j = 0; j &amp;lt; cellsHorizontally; j++)&lt;br /&gt;                {&lt;br /&gt;                    drawingContext.DrawLine(pen,&lt;br /&gt;                        &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(horizontalOffset, verticalOffset),&lt;br /&gt;                        &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(&lt;span class="kwrd"&gt;this&lt;/span&gt;.CellWidth + horizontalOffset, verticalOffset));&lt;br /&gt;&lt;br /&gt;                    horizontalOffset += &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellWidth;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                verticalOffset += &lt;span class="kwrd"&gt;this&lt;/span&gt;.CellHeight;&lt;br /&gt;                horizontalOffset = 0;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// and we're done! We're actally using the FrameworkElement's own DrawingContext,&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// so no need to add it anywhere or anything&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt; Overrides&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The XAML:&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="GridTest.Window1"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:local&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:GridTest"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="Window2"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="244"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="600"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;&amp;lt;!-- The sliders, textblocks, textboxes and stuff --&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Height:"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="5,0"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="40"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Slider&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="theSliderX"&lt;/span&gt; &lt;span class="attr"&gt;Minimum&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;Maximum&lt;/span&gt;&lt;span class="kwrd"&gt;="1000"&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="25"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBox&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="2"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ElementName=theSliderX, Path=Value, UpdateSourceTrigger=PropertyChanged}"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="30"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Width:"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="5,0"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="40"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Slider&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="theSliderY"&lt;/span&gt; &lt;span class="attr"&gt;Minimum&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;Maximum&lt;/span&gt;&lt;span class="kwrd"&gt;="1000"&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="25"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBox&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="2"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ElementName=theSliderY, Path=Value, UpdateSourceTrigger=PropertyChanged}"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="30"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;&amp;lt;!-- set the properties of the CustomGrid object --&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;local:CustomGrid&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="2"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="CustomGrid"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;CellHeight&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ElementName=theSliderX, Path=Value}"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;CellWidth&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ElementName=theSliderY, Path=Value}"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;Stroke&lt;/span&gt;&lt;span class="kwrd"&gt;="Brown"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;StrokeThickness&lt;/span&gt;&lt;span class="kwrd"&gt;=".3"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt;&lt;br /&gt;                          &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;&amp;lt;!-- This weird one sets the dashes for the Pen object to use to draw the lines --&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;local:CustomGrid.DashStyle&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DashStyle&lt;/span&gt; &lt;span class="attr"&gt;Dashes&lt;/span&gt;&lt;span class="kwrd"&gt;="20,20"&lt;/span&gt; &lt;span class="attr"&gt;Offset&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;local:CustomGrid.DashStyle&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;local:CustomGrid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.screencast.com/users/CarloDekstop/folders/Jing/media/f666da48-99f1-4a3c-b6be-554f3537ed83" Target="_blank"&gt;THE RESULT&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, this seems a little more complex because I have all those crazy looking &lt;blockquote&gt;DependencyProperties&lt;/blockquote&gt; to make the control a little more flexible, but if your grid will be one size, one color, one dash type, then you don't need all that crap.&lt;br /&gt;&lt;br /&gt;Luckily, when you change the size of the container, it fires the OnRender() event, so you don't have to worry about handling that. However (pay attention here, this is important), I had a really hard time trying to find a way to trigger the OnRender() after modifying a property of the grid (change color, cell height, cell width, dashes, etc.), when I discovered this little method InvalidateVisual().&lt;br /&gt;&lt;br /&gt;The InvalidateVisual() method, as it says, invalidates the visual state of your FrameworkElement derived object, which, fires the OnRender() again, hence, redraws the grid with all the new values (color, height, width, etc.), that is the reason I'm using it in the VisualPropertyChangedCallBack method, any time a visual property of the grid changes, it'll trigger that callback, and it'll redraw it.&lt;br /&gt;&lt;br /&gt;Hope this helps you, I really had a hard time looking for a way to do this, so here I am, trying to save you that pain.&lt;br /&gt;&lt;br /&gt;Thanks for reading! See you next post!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-6442079519176745171?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/6442079519176745171/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/03/drawing-grid.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/6442079519176745171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/6442079519176745171'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/03/drawing-grid.html' title='Drawing the grid'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-5219676961511631951</id><published>2010-03-03T22:39:00.000-08:00</published><updated>2010-04-06T17:29:43.696-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>Drawing stuff</title><content type='html'>Well, tomorrow I have to draw a grid for work... so here I am, almost 11pm, trying to find out how to. I thought I knew, but turns out I didn't. But hey! Now I do! But right now I haven't finalized the code to draw the grid, which is not important because it's just a set of equations, but I might post it later when it's finished. Btw, you can &lt;a href="http://rapidshare.com/files/359151682/DrawingTest.zip.html" target="_blank"&gt;download the project here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Anyway, to the point!&lt;br /&gt;&lt;br /&gt;3 simple steps:&lt;br /&gt;&lt;br /&gt;1. Your class must inherit from FrameworkElement (so WPF knows how to draw it)&lt;br /&gt;2. Your class must have it's own collection of visuals&lt;br /&gt;3. You must override: (a) VisualChildrenCount - To return the count of your collection of visuals, and (b) GetVisualChild(int index) - To get the correct visual from your collection of visuals.&lt;br /&gt;&lt;br /&gt;Easy peasy.&lt;br /&gt;&lt;br /&gt;Now, let's do some code. Here is my class:&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Data;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Documents;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Input;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media.Imaging;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Navigation;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Shapes;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; DrawingTest&lt;br /&gt;{&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// Interaction logic for Window1.xaml&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Window1 : Window&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Window1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MyDrawings : FrameworkElement&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; MyDrawings()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// call the draw method&lt;/span&gt;&lt;br /&gt;            Draw();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Draw()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// create a visual, visuals help you draw&lt;/span&gt;&lt;br /&gt;            DrawingVisual visual = &lt;span class="kwrd"&gt;new&lt;/span&gt; DrawingVisual();&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (DrawingContext context = visual.RenderOpen())&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="rem"&gt;// draw the first line&lt;/span&gt;&lt;br /&gt;                context.DrawLine(&lt;span class="kwrd"&gt;new&lt;/span&gt; Pen(Brushes.Black, 1), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(0, 0), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(10, 100));&lt;br /&gt;                &lt;span class="rem"&gt;// draw the second line&lt;/span&gt;&lt;br /&gt;                context.DrawLine(&lt;span class="kwrd"&gt;new&lt;/span&gt; Pen(Brushes.Red, 1), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(10, 100), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(20, 50));&lt;br /&gt;                &lt;span class="rem"&gt;// draw the third line&lt;/span&gt;&lt;br /&gt;                context.DrawLine(&lt;span class="kwrd"&gt;new&lt;/span&gt; Pen(Brushes.Red, 1), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(20, 50), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(30, 100));&lt;br /&gt;                &lt;span class="rem"&gt;// draw the fourth line&lt;/span&gt;&lt;br /&gt;                context.DrawLine(&lt;span class="kwrd"&gt;new&lt;/span&gt; Pen(Brushes.Black, 1), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(30, 100), &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(40, 0));&lt;br /&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// we'll end up with a weird looking red / black big W&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// add your new visal to the list of visuals, you can go nuts adding stuff here, it'll show up!&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;._visuals.Add(visual);&lt;br /&gt;            &lt;br /&gt;            &lt;span class="rem"&gt;// this is required to stablish the relationship between the visual and your new control&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// (so the visual knows who it's Parent is, before this line visual.Parent will be null)&lt;/span&gt;&lt;br /&gt;            AddVisualChild(visual);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; List&amp;lt;Visual&amp;gt; _visuals = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Visual&amp;gt;();&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// override VisualChildrenCount to...&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; VisualChildrenCount&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="rem"&gt;// ...return the count of your visuals collection, remember?&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; _visuals.Count;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// override GetVisualChild to...&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; Visual GetVisualChild(&lt;span class="kwrd"&gt;int&lt;/span&gt; index)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// you might need an assert here, now an exception, but you get the idea&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (index &amp;lt; 0 || index &amp;gt;= _visuals.Count)&lt;br /&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; IndexOutOfRangeException(&lt;span class="str"&gt;"index"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// ...return the correct child in your collection, you don't want to return an empty visual do you?&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; _visuals[index];&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;XAML is pretty straight forward, just put your new drawing object there and that's it!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="DrawingTest.Window1"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:local&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:DrawingTest"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="Window1"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;local:MyDrawings&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;  &lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Like I said, piece o' cake. Now you can add functionallity to this object (clicks, mouse over, and what not), but that is not in the scope of this post, I will post about that later on. For now, happy drawing!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-5219676961511631951?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/5219676961511631951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/03/drawing-stuff.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/5219676961511631951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/5219676961511631951'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/03/drawing-stuff.html' title='Drawing stuff'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-998563790125187222</id><published>2010-02-19T20:12:00.000-08:00</published><updated>2010-02-20T02:39:51.124-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>ItemContainerGenerator</title><content type='html'>I know I said I was going to talk about MVVM first, but I haven't found a chance to really write about it, and I don't just want to say stuff from the top of my head, so it'll have to wait. In the mean time...&lt;br /&gt;&lt;br /&gt;Have you ever been in the situations where you have a ListBox, ComboBox or any other ItemsControl (TreeView, TabControl), and you need to get the selected item (note: NOT the object bound to it, the actual item: ListBoxItem, TreeViewItem, ComboBoxItem, etc.). I know I have, and just yesterday, after one year, I found the solution:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;ListBox.ItemContainerGenerator.ContainerFromItem(&lt;span class="kwrd"&gt;object&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;or&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;ListBox.ItemContainerGenerator.ContainerFromIndex(&lt;span class="kwrd"&gt;int&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Say you have this situation. A list of Persons bound to a ListBox, and for some reason you need to access the item, not the Person bound to it. Check out the following code:&lt;br /&gt;&lt;br /&gt;C#:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Window1 : Window&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Window1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            &lt;span class="rem"&gt;// this returns a Crowd with a populated array of People objects&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.DataContext = &lt;span class="kwrd"&gt;new&lt;/span&gt; Crowd(&lt;span class="rem"&gt;/* Populate */&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;// gets the data context&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// if it weren't bound through WPF binding, it would return the ListBoxItem&lt;/span&gt;&lt;br /&gt;            Person person = (Person)theListBox.SelectedItem;&lt;br /&gt;            &lt;br /&gt;            &lt;span class="rem"&gt;// gets the ListBoxItem, not the data context&lt;/span&gt;&lt;br /&gt;            ListBoxItem itemFromObject = (ListBoxItem)theListBox.ItemContainerGenerator.ContainerFromItem(person);&lt;br /&gt;            &lt;span class="rem"&gt;// or get it from the index&lt;/span&gt;&lt;br /&gt;            ListBoxItem itemFromIndex = (ListBoxItem)theListBox.ItemContainerGenerator.ContainerFromIndex(theListBox.SelectedIndex);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;XAML:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="ItemContainerGeneratorTest.Window1"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="Window1"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="8"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ListBox&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="theListBox"&lt;/span&gt;&lt;br /&gt;                 &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt;&lt;br /&gt;                 &lt;span class="attr"&gt;ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding People}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="3"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding FirstName}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="3"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding LastName}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ListBox&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Get selected item"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,8,0,0"&lt;/span&gt; &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;="Button_Click"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the ListBox (theListBox) is bound through WPF, and I'm still able to get the ListBoxItem selected by the button in a very simple manner.&lt;br /&gt;&lt;br /&gt;Hope this helps you as it is now helping me. Of course this is a very simplistic example, if you have a listbox with a couple hunders or thousands of items, or a tree with a very deep hierarchy, this will help you a lot.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://rapidshare.com/files/353248227/ItemContainerGeneratorDemo.zip.html"&gt;Download project file&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-998563790125187222?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/998563790125187222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/02/itemcontainergenerator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/998563790125187222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/998563790125187222'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/02/itemcontainergenerator.html' title='ItemContainerGenerator'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6249909800506859886.post-5492654399745580193</id><published>2010-02-03T09:53:00.000-08:00</published><updated>2010-02-03T09:54:48.394-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>First post</title><content type='html'>Ok, this is my second blog attempt. This time I'll be serious about it.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next post will be about the MVVM pattern for WPF. Stay tuned.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6249909800506859886-5492654399745580193?l=wpfdude.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wpfdude.blogspot.com/feeds/5492654399745580193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wpfdude.blogspot.com/2010/02/first-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/5492654399745580193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6249909800506859886/posts/default/5492654399745580193'/><link rel='alternate' type='text/html' href='http://wpfdude.blogspot.com/2010/02/first-post.html' title='First post'/><author><name>Carlo</name><uri>http://www.blogger.com/profile/17430456192917035512</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_V1EbWLB6mo8/S2m0C2GnC-I/AAAAAAAAAAM/rmXxJVr5qFo/s1600-R/photo396.jpg'/></author><thr:total>0</thr:total></entry></feed>
