<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://new.vbcity.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"><channel><title>vbCity</title><link>http://new.vbcity.com/blogs/</link><description>Migrating to the new kind of Visual Basic Developer Community</description><dc:language>en-US</dc:language><generator>CommunityServer 2008 (Build: 30417.1769)</generator><item><title>test</title><link>http://new.vbcity.com/blogs/canoz/archive/2009/04/14/test.aspx</link><pubDate>Tue, 14 Apr 2009 21:41:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674684</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;test&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674684" width="1" height="1"&gt;</description></item><item><title>test</title><link>http://new.vbcity.com/blogs/wwjd/archive/2009/04/14/test.aspx</link><pubDate>Tue, 14 Apr 2009 21:34:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674664</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;test&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674664" width="1" height="1"&gt;</description></item><item><title>test</title><link>http://new.vbcity.com/blogs/xtab/archive/2009/04/14/test.aspx</link><pubDate>Tue, 14 Apr 2009 21:15:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674637</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;test&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674637" width="1" height="1"&gt;</description></item><item><title>test</title><link>http://new.vbcity.com/blogs/djjeavons/archive/2009/04/14/test.aspx</link><pubDate>Tue, 14 Apr 2009 21:08:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674622</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;test&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674622" width="1" height="1"&gt;</description></item><item><title>test</title><link>http://new.vbcity.com/blogs/edward/archive/2009/04/14/test.aspx</link><pubDate>Tue, 14 Apr 2009 21:03:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674614</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;test&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674614" width="1" height="1"&gt;</description></item><item><title>test</title><link>http://new.vbcity.com/blogs/skullcrusher/archive/2009/04/14/test.aspx</link><pubDate>Tue, 14 Apr 2009 20:22:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674587</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;test&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674587" width="1" height="1"&gt;</description></item><item><title>Creating Video Demos With Camtasia Studio</title><link>http://new.vbcity.com/blogs/xtab/archive/2009/01/23/creating-video-demos-with-camtasia-studio.aspx</link><pubDate>Fri, 23 Jan 2009 17:28:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674638</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="Verdana"&gt;
&lt;p&gt;&amp;nbsp;&lt;font size="2"&gt;&amp;nbsp;I&amp;#39;ve been meaning to blog about the tools I use regularly and find useful and I&amp;#39;ve managed to get a couple written this month. I&amp;#39;m always a bit concerned that blogs like this might end up looking like some kind of infomercial. But I eventually came to the conclusion that I&amp;#39;ve always thought that personal recommendation was the best kind of recommendation, so if I like a tool I should tell the world. Whether the world sets any store by my opinion is a matter for the world to decide!&lt;/font&gt; &lt;font face="Wingdings" size="3"&gt;J&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Camtasia1.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font size="2"&gt; I have been using Camtasia Studio on and off for a couple of years now. When I first got hold of a copy, I needed it to create some demo videos. What I really liked about it was that, with no previous experience of screen recording, I was able to make the recording successfully after only a couple of tries. OK, so when I look back at that effort now, maybe &amp;quot;successfully&amp;quot; is an extravagant claim, but it was good enough for what I wanted to do at the time.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp; Although there are still some (many!) features that I haven&amp;#39;t yet got round to using, it has still been a really useful tool for me. When I first got it, I was more interested in grabbing the screen action and recording some audio narration. More recently, I needed to improve the narration side and so was looking for a way to record the voice independently and (often) edit parts of it without having to re-record the whole thing for the umpteenth time.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/CamtasiaAudio.jpg" alt="" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp; Camtasia Studio comes with a subset of handy little apps, one of which is their Audio Editor. This has been really useful, as it enabled me to make those voice recordings and edit them easily. I also found myself doing a lot of &amp;quot;Inserting Silence&amp;quot; to replace the intakes of breath and the occasional unwanted clunk when I&amp;#39;m waving my hands around and hit the boom mike.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;a href="http://www.techsmith.com/learn/camtasia/getting-started/"&gt;&lt;font size="2"&gt;The tutorials&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; are excellent and there is a lively set of &lt;/font&gt;&lt;a href="http://forums.techsmith.com/"&gt;&lt;font size="2"&gt;User forums&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;a href="http://techsmith.custhelp.com/cgi-bin/techsmith.cfg/php/enduser/std_alp.php"&gt;&lt;font size="2"&gt;FAQs&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; are available to help you with those tricky things that should go right but somehow don&amp;#39;t. &lt;br /&gt;&lt;br /&gt;The work area is as easy to use as you could reasonably hope for with an application that seems to have so many options. As you can see from the screenshot, the timeline allows for more than one audio track. &lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/CamtasiaWorkArea.jpg" alt="" /&gt; &lt;br /&gt;&lt;br /&gt;Version 6 of Camtasia comes with even more presets to help you create the best screen size, resolution and (often important for web distribution or viewing) file size. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp; I&amp;#39;m currently working on creating some courses, all of which contain video demos. As I get more used to using it, I am of course finding that I can get from starting idea to finished production much quicker. When I&amp;#39;ve finished my current project, as a long term plan, I hope to be able to create a set of short videos to be made available for free here on VBCity.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp; All in all, I&amp;#39;m really pleased with it and many a time I&amp;#39;ve silently thanked the friend who first put me on to it. You can download a free 30 Day trial version from the TechSmith site &lt;/font&gt;&lt;a href="http://www.techsmith.com/download/trials.asp"&gt;&lt;font size="2"&gt;here.&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9262.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674638" width="1" height="1"&gt;</description></item><item><title>The Best WPF Developer Books</title><link>http://new.vbcity.com/blogs/xtab/archive/2009/01/18/the-best-wpf-developer-books.aspx</link><pubDate>Sun, 18 Jan 2009 20:10:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674639</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="Verdana" size="2"&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I now have several WPF books. I&amp;#39;ve written reviews on some of them and often mentioned them in answers to Forum questions from members who want to start out in WPF.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;When I wrote those articles and answers, my opinion was mostly based on my experience as a general reader who was interested in seeing what WPF had to offer and dabbling with it at a fairly elementary level. For the past three months though, I&amp;#39;ve been involved with WPF on a daily basis in a training capacity. During this time, it&amp;#39;s become clear that I turn to some of the books much more regularly than others - and to some of them only when fairly desperate). &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;With the very clear understanding up front that this is my personal experience, opinion and preference - which may be completely different from anyone else&amp;#39;s - here is my view on the various books.&lt;/p&gt;
&lt;p&gt;The book I first turn to is : &lt;br /&gt;Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5 &lt;br /&gt;by Matthew MacDonald. &lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFBooks/WPF_MMc_VB.jpg" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Comprehensive, detailed, clearly written, understandable code snippets, and downloadable code samples that work.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;It&amp;#39;s almost impossible to fault this book. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;And of course, as the title says, the code behind samples are all in VB.NET - the only book I know of so far that is aimed specifically at VB developers. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;However, if you are a C# developer then that won&amp;#39;t impress you much. For you, Apress and Matthew MacDonald have produced the equivalent C# title - Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.0. The key differences obviously being the absence of &amp;quot;VB.NET&amp;quot; in the title and the slightly earlier Framework. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I do have this version too and find it very useful when I want to try and understand the C# approach to a concept that I understand in VB.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The next book I reach out for is usually&lt;br /&gt;Windows Presentation Foundation Unleashed &lt;br /&gt;by Adam Nathan. &lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFBooks/NathanBook.jpg" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The key value of this book is that it is packed with little hints, tips, Gotchas and information that will help you fight your way through the minefield that you encounter when first starting with WPF. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;One negative for me is that the code samples are in C#. There are however many useful XAML samples. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The book is in full color. This makes it slightly more attractive, but isn&amp;#39;t a key issue for me. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Compared to most other WPF books, it appears to be relatively slim. In spite of this, I have still found it to be a gold mine of really useful WPF nuggets.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Third in line is: &lt;br /&gt;Programming WPF &lt;br /&gt;by Chris Sells and Ian Griffiths. &lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFBooks//Sells.jpg" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Another C# book, but again contains a lot of XAML. Ian Griffiths was one of the first writer/speaker/presenter/trainers on WPF in general and XAML in particular, so there are some useful insights to be had here.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;On the negative side, my impression is that the authors prefer to use code behind sometimes where I would have liked to see the XAML alternative.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Make sure you get the Second Edition if you decide to go for this book. The First Edition is inevitably way out of date now.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Surprisingly (to me anyway, considering I spent a lot of time converting the code in the next book from C# to VB) the Petzold book only comes fourth in my list of most used books. This is:&lt;br /&gt;Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation &lt;br /&gt;by Charles Petzold. &lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFBooks/Petzold.jpg" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;If you want intricate details and almost philosophical insight into the structure of WPF, then this would be the book for you. As with all Petzold books, it painstakingly works its way through the minutiae of the subject.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;If I have a criticism, it would be that sometimes the sackcloth and ashes approach to developing (such as manually creating everything yourself, even if it is available for free) doesn&amp;#39;t always work for me. I understand the purity of the approach, but this means that it can sometimes be difficult to just dip into this book for a quick answer to a particular question.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;However, if you really - really - want to get at the nuts and bolts of WPF, then you will probably not find one that has more detail.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The fifth book in my WPF stable (for now, anyway!) is: &lt;br /&gt;Professional WPF Programming: .NET Development with the Windows Presentation Foundation &lt;br /&gt;by Chris Andrade and others. &lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFBooks/Wrox.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;When there were very few other books available, this one had some benefits. The authors had each looked at specific areas and came up with some guidance. Some parts were clearly better than others, but overall it was an easier read than MSDN at the time, but basically rather shallow coverage. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;It rarely gets opened these days.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I have the greatest respect for anyone who takes the time, trouble and effort to write or co-write a book. Knowing how long it takes me to write a short article or a training package, I wouldn&amp;#39;t dream of criticising someone who will have spent many long, hard months writing (and no doubt re-writing) a book. So, as I said at the start, the opinions in this blog item only reflect my personal experience of using this collection of books; other readers with other backgrounds and author style preferences may well have different opinions. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;As WPF picks up speed and interest grows, I&amp;#39;m sure there will be many other WPF books published in the coming months. There are already several that were published at the end of 2008 that I haven&amp;#39;t read. &amp;nbsp; No doubt the temptation to pick up another title or two will become irresistible as 2009 progresses and, if so, I will post up my thoughts on those too in the hope that it might help you decide the best way of spending your hard-earned cash. &lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9243.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674639" width="1" height="1"&gt;</description></item><item><title>WPF Commands and PerformClick</title><link>http://new.vbcity.com/blogs/xtab/archive/2009/01/18/wpf-commands-and-performclick.aspx</link><pubDate>Sun, 18 Jan 2009 18:04:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674640</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="Verdana" size="2"&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Some weeks ago I wrote &lt;a href="http://blogs.vbcity.com/xtab/archive/2008/11/15/9202.aspx"&gt;a blog item&lt;/a&gt; about how to get the functionality of PerformClick in WPF. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I remember thinking at the time that it was a fairly clunky workaround and wondered why PerformClick hadn&amp;#39;t been included in WPF. Of course there may be lots of reasons, beginning with &amp;#39;No-one thought of it&amp;#39; and ending with &amp;#39;It was just too difficult&amp;#39;. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;But while looking at an apparently unrelated problem this week, it occurred to me that maybe there is a more elegant solution staring me in the face - WPF&amp;#39;s &lt;b&gt;Commands&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;In many cases where PerformClick is required, the situation is that whatever action is wired up to the Button&amp;#39;s Click event is often also of interest to other controls - perhaps a menu item, a keyboard shortcut or a user instigated selection of some kind or other elsewhere. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;WPF Commands, if this is a new area for you, is a variation on the theme of Events. Whereas events are generally locked in to a specific action, a Command on the other hand is more along the lines of a loosely-coupled task that can be subscribed to from several places.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Of course,you may be sat there thinking that it doesn&amp;#39;t take a coding genius to create code for events that can be re-used and accessed from several different points. The point is though that Commands are specifically designed for this purpose and they have a feature that I think makes them almost unique. &lt;font color="#408080"&gt;(Can you be &amp;#39;almost&amp;#39; unique, the literary critic part of my brain asks? Never mind, you know what I mean!)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Commands have the ability to turn themselves off in situations where it wouldn&amp;#39;t be appropriate for them to be available - and back on again when it is. A common example is the Paste Command, where it doesn&amp;#39;t make sense to have it available unless there is some data in the Clipboard.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Similarly, you might build in a test where the Exit command isn&amp;#39;t allowed to function unless the user has taken some action, such as saving data. There are lots of similar examples.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;WPF comes with a bundle of pre-built Commands for common tasks, including Copy, Cut, Paste, Find, Save, Close, Play, Zoom, Align and many more. Naturally, the designers of WPF don&amp;#39;t know the exact actions you will want to link to each of the commands in every circumstance, so there is still some work for you to do. Commands are clever - but they&amp;#39;re not magic!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Apart from the built in Commands, and on the basis that there are never enough of these kind of things, you can create Commands of your own relatively easily. You can set the bindings and the rules that decide when it may be able to execute and when not (as per the Paste example earlier).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;All of which brings me back to my original thought. If you can create a Command that both a Button and (in the case of the Forum question that got me thinking about this) a Menu Item can bind to, then that really removes the need to worry about PerformClick. Command would be a neater and more sophisticated way of achieving the same effect.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;If you want more info on Commands, here is a useful link to an &lt;a href="http://msdn.microsoft.com/en-us/library/ms752308.aspx"&gt;MSDN&lt;/a&gt; Introduction to Commands article. &lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9240.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674640" width="1" height="1"&gt;</description></item><item><title>New Blog</title><link>http://new.vbcity.com/blogs/skullcrusher/archive/2008/12/18/new-blog.aspx</link><pubDate>Thu, 18 Dec 2008 18:19:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674588</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>Just to let anyone who might be interested know that my Blog has now moved to &lt;a href="http://cs.vbcity.com/blogs/skullcrusher/default.aspx"&gt;http://cs.vbcity.com/blogs/skullcrusher/default.aspx&lt;/a&gt;&lt;img src="http://blogs2.vbcity.com/skullcrusher/aggbug/9224.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674588" width="1" height="1"&gt;</description></item><item><title>WPF Text Tricks - MultiLine Text and Multiple Spaces</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/12/12/wpf-text-tricks-multiline-text-and-multiple-spaces.aspx</link><pubDate>Sat, 13 Dec 2008 00:51:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674641</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="Verdana" size="2"&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;When it comes to text handling in WPF, you have a massive range of tools available, some of which can offer you a level of granularity that was previously unachievable. I plan to write about some of these text tools, such as Spans, Runs and Glyphs in future blogs, but for today I want to look at something a little less deep. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Recently I needed to insert a carriage return in a block of text. The text was being created in the XAML markup, and I didn&amp;#39;t particularly want to resort to code-behind for what is essentially a UI feature. So I had to do a bit of digging to find how I could create, for instance, this result:- &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Text1.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;where, if I don&amp;#39;t override it, the two words would be placed one after the other on one line because there is more than enough width for them both.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;As you might expect, there are several ways of achieving this, but I think the easiest one is to use a LineBreak element. This snippet shows the key part of the code that creates and formats the Button&amp;#39;s Content, which in this example is of course text only. &lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;12,45&amp;quot; &amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt; Click &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;LineBreak&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt; Me!&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; You might think it a bit strange when you see that XML type item stuck into the middle of a block of text, but this is perfectly valid syntax. Because the Content isn&amp;#39;t a single block of text, it&amp;#39;s necessary to use the TextBlock to house the text and the LineBreak instruction. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Actually, what I really wanted to do wasn&amp;#39;t quite as plain as the above screenshot. It was more along these lines:-&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Text2.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The markup for this is still not particularly complex. It just requires more properties to be set specifically:&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt; &lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;12,45&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;LightSkyBlue&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button.Content&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:red;"&gt; TextAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; FontSize&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;16&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; FontFamily&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Calibra&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:red;"&gt; FontWeight&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Foreground&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Navy&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; FontStyle&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Italic&amp;quot; &amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Click &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;LineBreak&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt; Me!&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button.Content&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I did mention that there are several ways and these include using a StackPanel containing multiple TextBlocks or setting the Padding property on a single TextBlock. An alternative you might consider is to preserve the whitespace. This effectively means that however you enter the text layout in your XAML will be faithfully reproduced in the WPF display.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The following markup:&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt; &lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;12,40&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:red;"&gt; FontSize&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;14&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:red;"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; xml&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:red;"&gt;space&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;preserve&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Click&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;Me!&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;will achieve a similar result:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Text3.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;However, I really don&amp;#39;t think the way the Markup sits in the XAML markup window is particularly neat. If you&amp;#39;re interested in experimenting, try moving the word &amp;quot;Me!&amp;quot; so that it is more neatly aligned. Or Start the word &amp;quot;Click&amp;quot; on a new line of its own, maybe aligned with the markup above it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The results are unlikely to be what you wanted to achieve and this is because the preservation is absolute. A XAML twist on WYSIWYG! &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;However, I included it here because the space preserve approach will be very useful to you in those cases where you want more than a single space between words or characters. Simply type out the text with the exact spacing that you require, set the XML Space attribute to Preserve and your requirements will be honored.&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt; &lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;12,40&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:red;"&gt; FontSize&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;14&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="COLOR:red;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt; &lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="COLOR:red;"&gt; xml&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:red;"&gt;space&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;preserve&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Name:&amp;nbsp; &amp;nbsp; Ged&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Text4.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font face="Verdana" size="2"&gt; So there are a couple of tips for dealing with text in WPF.&amp;nbsp; There&amp;#39;s more to come!&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9215.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674641" width="1" height="1"&gt;</description></item><item><title>Formatting XAML Code Samples for a Blog</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/12/11/formatting-xaml-code-samples-for-a-blog.aspx</link><pubDate>Thu, 11 Dec 2008 17:18:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674642</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;span style="FONT-SIZE:x-small;FONT-FAMILY:Verdana;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;For several years, whenever I&amp;#39;ve needed to include code snippets in my blogs and articles, I&amp;#39;ve used a neat little application that VBCity member HotDog wrote. This has stood me in good stead until the day that XAML arrived on the scene. Unfortunately, XAML kinda confuses HotDog&amp;#39;s AutoFormatter tool and I end up with missing angle brackets. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;A bit of searching led me to a tool called CopySourceAsHTML. Although I had seen this used with Visual Studio 2005, there was a minor problem using it with 2008 for a while, but this was easily fixed with a minor tweak. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Now though there is an official Visual Studio 2008 version. The extra good news about this is that it will also copy XAML to HTML.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;One thing to watch out for if you have used the tool before and usually right click on a code snippet to copy is as HTML: &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/CSAH1.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; you will expect to see the &lt;i&gt;Copy As HTML&lt;/i&gt; option in the menu. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;However, this doesn&amp;#39;t appear in the context menu if you right click on the markup in the XAML Markup Pane. But it is available and all you have to do is go to the IDE main menu, select &lt;i&gt;Edit &lt;/i&gt;and the &lt;i&gt;Copy As HTML&lt;/i&gt; menu item will be available for you there. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;This great little utility is written (and updated) by Colin Coller of J T Leigh and Associates. You can download it &lt;a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/"&gt;from here&lt;/a&gt;.&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9214.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674642" width="1" height="1"&gt;</description></item><item><title>WPF Gotchas: What's the WPF Equivalent of the Text Property?</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/12/11/wpf-gotchas-what-s-the-wpf-equivalent-of-the-text-property.aspx</link><pubDate>Thu, 11 Dec 2008 17:13:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674643</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;span style="FONT-SIZE:x-small;FONT-FAMILY:Verdana;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;One of the things that often pulls me up in mid flow when I&amp;#39;m putting WPF UIs together in a Window is that some of the core properties seem to have disappeared. Now, some of these are so fundamental that I know they have to be there, but obviously hiding under a different name. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;Just recently, this happened to me twice in a row and I ended up scrolling through the Properties in the Object Browser, getting dizzy with the whizzing list of choices until I finally found them. All I was looking for was a very simple thing in both cases. I just wanted to apply some text to a control. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;The first one was the good old CheckBox. In Windows Forms this has a Text property, of course, and it&amp;#39;s whatever textual information you want to place at the side of the little square check area. The WPF CheckBox will allow you to do a zillion clever things to change its look - add Borders, TextBlocks, Images, Panels, whatever you like - and at times I&amp;#39;m really happy about that. But as it happened this time I just wanted to plonk a couple of words of description at the side.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;You&amp;#39;ll have gathered that there isn&amp;#39;t a Text property for the WPF CheckBox and after a bit of a search, I did find its replacement - the &lt;b&gt;Content&lt;/b&gt; property. If you assign plain text to this property, WPF&amp;nbsp;will honor your choice. So this:&lt;/font&gt; &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;CheckBox1&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;Click Here&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;will do the job nicely.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;Subsequently I discovered that the Content property is in fact the default property of a CheckBox, so this too will work: &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;CheckBox1&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Click Here&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font face="Verdana" size="2"&gt;Of course if you do want something more exotic, then you still use the Content property - you just add whatever multiple layers of content you desire.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;The other control for which I had to search for the same kind of thing was the Expander. Again I only wanted a property that would just tack some plain text to the side of the Expander&amp;#39;s little arrow. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;This time the answer is to use the Expander&amp;#39;s &lt;b&gt;Header&lt;/b&gt; property.&lt;/font&gt; &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Header&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;See More Choices&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;You can assign plain text to this property, but again you have the option to, well, &lt;i&gt;expand&lt;/i&gt; the Expander&amp;#39;s Header to make it a little more graphically interesting.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Expander.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font face="Verdana" size="2"&gt;using this XAML:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander.Header&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Border&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; BorderBrush&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;Navy&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; BorderThickness&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; CornerRadius&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;6&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;10,2,10,2&amp;quot;&lt;/span&gt; &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#ff0000;"&gt;Foreground&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;Navy&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;What do you want to do?&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Border&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander.Header&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font face="Verdana" size="2"&gt;Although Content is the default property, don&amp;#39;t fall into the trap of trying to use it as:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt; Click to view choices &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font face="Verdana" size="2"&gt;because that inserts the text as the first (and in this case, only) item in the area that you get to see when the Expander arrow is clicked. It will be the only item because Content isn&amp;#39;t a container and you need to use something like a StackPanel if you have more than one child that you want to include in the expanded area. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;Something like this:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander.Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt; &amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;2,4&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot; Do This&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;2,4&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot; Do That&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;2,4&amp;quot; &amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox.Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Orientation&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;Horizontal&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Image&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;16&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Source&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;DCP_1997.jpg&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Image&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot; View Profile&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox.Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;CheckBox&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="COLOR:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;3,30,0,0&amp;quot;&lt;/span&gt; &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;=&amp;quot;Select a task from the list above.&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Expander.Content&lt;/span&gt;&lt;span style="COLOR:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font face="Verdana" size="2"&gt;to produce this result:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/Expander1.jpg" alt="" /&gt;&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9213.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674643" width="1" height="1"&gt;</description></item><item><title>My Blogs Are Moving to New Site</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/12/08/my-blogs-are-moving-to-new-site.aspx</link><pubDate>Tue, 09 Dec 2008 00:13:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674644</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;font face="Verdana"&gt;&amp;nbsp; VBCity will be looking very different&amp;nbsp;soon, as we change to the new Community Server based model.&amp;nbsp;&amp;nbsp; In advance of that change, our blogs are moving to a new area.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana"&gt;&amp;nbsp;From now on, you can view my latest blogs both here and&amp;nbsp;at the new site &lt;/font&gt;&lt;a href="http://cs.vbcity.com/blogs/xtab/default.aspx"&gt;&lt;font face="Verdana"&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;.&amp;nbsp; Once the new site is fully up and running, all new blog items will be posted on the new area only.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana"&gt;&amp;nbsp;All previous blogs from VBCity Bloggers will still be available and hopefully will continue to rank highly in search engine results.&amp;nbsp; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9212.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674644" width="1" height="1"&gt;</description></item><item><title>How To Get the Icon from an Application</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/11/27/how-to-get-the-icon-from-an-application.aspx</link><pubDate>Fri, 28 Nov 2008 02:00:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674645</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="Verdana" size="2"&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;This question comes up every so often in the forums and it&amp;#39;s one of those things that you&amp;#39;d think should be easy, but actually isn&amp;#39;t. Well, it isn&amp;#39;t until you know how - like most things in developer land. The question is usually something along the lines of &lt;i&gt;&amp;quot;How can I grab the icon from an MS Word file?&amp;quot;&lt;/i&gt; The application may not necessarily be MS Word, but the that&amp;#39;s the general thrust of it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;The only approach I have successfully used in this kind of scenario is the SHGetFileInfo API*. This API will grab the icon from an application. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Here&amp;#39;s the way I do it: First, Import Runtime.InteropServices into your Windows Form. &lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#e0e0e0;"&gt;&lt;font color="#0000ff"&gt;Imports&lt;/font&gt; System.Runtime.InteropServices&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Next, the API code, which goes at the top of the form, outside of any procedures:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#e0e0e0;"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt;&lt;font color="#0000ff"&gt; Structure&lt;/font&gt; SHFILEINFO&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt; hIcon&lt;font color="#0000ff"&gt; As&lt;/font&gt; IntPtr&lt;font color="#008000"&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt; iIcon&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Integer&lt;/font&gt;&lt;font color="#008000"&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt; dwAttributes&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Integer&lt;/font&gt;&lt;font color="#008000"&gt;&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)&amp;gt; _&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt; szDisplayName&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)&amp;gt; _&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt; szTypeName&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Structure&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt;&lt;font color="#0000ff"&gt; Declare&lt;/font&gt;&lt;font color="#0000ff"&gt; Auto&lt;/font&gt;&lt;font color="#0000ff"&gt; Function&lt;/font&gt; SHGetFileInfo&lt;font color="#0000ff"&gt; Lib&lt;/font&gt;&lt;font color="#a31515"&gt; &amp;quot;shell32.dll&amp;quot;&lt;/font&gt; _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; pszPath&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;, _&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&lt;/font&gt; dwFileAttributes&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Integer&lt;/font&gt;, _&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByRef&lt;/font&gt; psfi&lt;font color="#0000ff"&gt; As&lt;/font&gt; SHFILEINFO, _&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&lt;/font&gt; cbFileInfo&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Integer&lt;/font&gt;, _&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&lt;/font&gt; uFlags&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Integer&lt;/font&gt;)&lt;font color="#0000ff"&gt; As&lt;/font&gt; IntPtr&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/font&gt; hImgSmall&lt;font color="#0000ff"&gt; As&lt;/font&gt; IntPtr&lt;font color="#008000"&gt; &amp;#39;The handle to the system image list.&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt;&lt;font color="#0000ff"&gt; Const&lt;/font&gt; SHGFI_ICON&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Long&lt;/font&gt; = &amp;amp;H100&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt;&lt;font color="#0000ff"&gt; Const&lt;/font&gt; SHGFI_SMALLICON&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Long&lt;/font&gt; = &amp;amp;H1&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Note the two Constants at the end there being declared as Long. You&amp;#39;ll usually find you have to tweak old API code to fix these kind of lines if you have Option Strict On.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;To demonstrate this API in action, here is how I&amp;#39;ve structured it: 
&lt;ul&gt;
&lt;li&gt;I have added a button (btnSelectFile) to the Form.&lt;br /&gt;
&lt;li&gt;When this button is clicked, an OpenFileDialog is created to allow the user to select a file.&lt;br /&gt;
&lt;li&gt;Once a file has been selected, the file name is passed to a function that will dig out the icon for that file type and pass it back. &lt;br /&gt;
&lt;li&gt;For demo purposes, the Form&amp;#39;s default icon will be replaced with this selected one. &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Here is the code in the function that grabs the icon:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#e0e0e0;"&gt;&lt;font color="#0000ff"&gt;Function&lt;/font&gt; GetIcon(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; filename&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;)&lt;font color="#0000ff"&gt; As&lt;/font&gt; Icon&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/font&gt; shinfo&lt;font color="#0000ff"&gt; As&lt;/font&gt; SHFILEINFO&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;shinfo =&lt;font color="#0000ff"&gt; New&lt;/font&gt; SHFILEINFO&lt;br /&gt;&lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Get the small icon.&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hImgSmall = SHGetFileInfo(filename, 0, shinfo, _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Marshal.SizeOf(shinfo), _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SHGFI_ICON&lt;font color="#0000ff"&gt; Or&lt;/font&gt; SHGFI_SMALLICON)&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&lt;/font&gt; System.Drawing.Icon.FromHandle(shinfo.hIcon)&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Function&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;And here is that function being called from a Button Click, the icon then being shown as the Form&amp;#39;s icon:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#e0e0e0;"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt;&lt;font color="#0000ff"&gt; Sub&lt;/font&gt; btnSelectFile_Click(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; sender&lt;font color="#0000ff"&gt; As&lt;/font&gt; System.Object,&lt;font color="#0000ff"&gt; ByVal&lt;/font&gt; e&lt;font color="#0000ff"&gt; As&lt;/font&gt; System.EventArgs)&lt;font color="#0000ff"&gt; Handles&lt;/font&gt; btnSelectFile.Click&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/font&gt; ofd&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; OpenFileDialog&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&lt;/font&gt; ofd.ShowDialog = Windows.Forms.DialogResult.OK&lt;font color="#0000ff"&gt; Then&lt;/font&gt;&lt;font color="#0000ff"&gt; Me&lt;/font&gt;.Icon = GetIcon(ofd.FileName)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Sub&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;That&amp;#39;s pretty much all there is to it, if you are happy to plonk the icon on the form like that. But in most cases you&amp;#39;ll probably want something a bit more reusable. One easy way to store the grabbed icon is to put it in an ImageList.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Assuming that you are only going to deal with one icon at a time, you can do something like this:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#e0e0e0;"&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; myIcons&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; ImageList&lt;br /&gt;myIcons.Images.Add(System.Drawing.Icon.FromHandle(shinfo.hIcon))&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Now that you have that icon safely stored in the ImageList, you can access the ImageList in the usual way if you want to place the icon image elsewhere. And of course you can change the above code slightly to allow for more than one icon to be added to the ImageList and used as required.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Finally, if you need to switch the icon into Bitmap format you can use the handy ToBitmap method:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#e0e0e0;"&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; bmp&lt;font color="#0000ff"&gt; As&lt;/font&gt; Bitmap = System.Drawing.Icon.FromHandle(shinfo.hIcon).ToBitmap&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;It is possible then to save the Bitmap by using the Bitmap&amp;#39;s Save method. However, I have found this to be a bit hit-and-miss, with it sometimes throwing a generic GDI+ error when I tried to recall it for use by means of the Image.FromFile method. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I hope that if you need to grab an image from an application that you find this article useful.&lt;/p&gt;---------------------------------------------------------------------- 
&lt;p&gt;&amp;nbsp;&amp;nbsp;* There is the much more hopeful sounding ExtractIcon API which I have used to extract the icon of a currently running VB application, but haven&amp;#39;t managed to port the logic over to the kind of file selection scenario described here.&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9208.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674645" width="1" height="1"&gt;</description></item><item><title>WPF Missing In Action - The Button PerformClick Method</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/11/15/wpf-missing-in-action-the-button-performclick-method.aspx</link><pubDate>Sat, 15 Nov 2008 23:59:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674646</guid><dc:creator>Admin</dc:creator><slash:comments>4</slash:comments><description>&lt;font face="Verdana"&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font size="2"&gt;PerformClick is one of the many casualties of a move from Windows Forms to WPF. Of course, it&amp;#39;s probably not something you would need to use often, but just in case you do then there is a way.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;It&amp;#39;s not a very intuitive way and - had it not been that I spotted the C# version of this trick in Adam Nathan&amp;#39;s WPF book - I wouldn&amp;#39;t be sat here writing this now. I&amp;#39;d still be searching endlessly to try and find the answer.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp; In order to achieve this in VB, you need to do the following: &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Add a Reference to &lt;font color="#000080"&gt;UIAutomationProvider&lt;/font&gt; in your Project.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Add an Imports statement:&lt;/font&gt; &lt;br /&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;Imports System.Windows.Automation.Peers &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;Add another Imports statement: &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;Imports System.Windows.Automation.Provider &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;Use the following code snippet: &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#000080"&gt;&lt;font size="3"&gt;Dim buttonPeer As New ButtonAutomationPeer(Button1) &lt;br /&gt;Dim invokeProv As IInvokeProvider = TryCast(buttonPeer.GetPattern(PatternInterface.Invoke), IInvokeProvider) &lt;br /&gt;invokeProv.Invoke() &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font size="2"&gt; The above code to be placed wherever you want to simulate the Button&amp;#39;s Click. (Change the Button name as needed). &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;It did occur to me that this task might be a good candidate for a custom Command, using WPF&amp;#39;s quite versatile Command abilities. However, I haven&amp;#39;t got past the &amp;quot;wonder if that&amp;#39;s a good idea?&amp;quot; stage. And to be honest, probably won&amp;#39;t any time soon. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;Whether&amp;nbsp;you feel that it&amp;#39;s necessary to go to the trouble of the Automation or the Command approach is of course entirely up to you. I have to admit to being tempted simply to move the action code out of the Button Click event and into a separate method that can be called from both the Button Click and other events.&amp;nbsp; But then, I&amp;#39;ve never been much or a purist about these things.&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9202.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674646" width="1" height="1"&gt;</description></item><item><title>WPF project for Background Colours</title><link>http://new.vbcity.com/blogs/canoz/archive/2008/10/25/wpf-project-for-background-colours.aspx</link><pubDate>Sun, 26 Oct 2008 05:49:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674685</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;It is a little longer than I expected to get the the project that goes along with &lt;a href="http://blogs.vbcity.com/canoz/archive/2008/07/16/9136.aspx" target="blank"&gt;this post&lt;/a&gt; about background colours in WPF but as they say better late ....&lt;/p&gt;
&lt;p&gt;The project can be downloaded from &lt;a href="http://www.neilknobbe.com/projects/BackgroundColours.zip" target="blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/canoz/aggbug/9195.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674685" width="1" height="1"&gt;</description></item><item><title>The Ampersand and XAML</title><link>http://new.vbcity.com/blogs/canoz/archive/2008/10/25/the-ampersand-and-xaml.aspx</link><pubDate>Sun, 26 Oct 2008 05:11:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674686</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I got caught the other day with a &amp;quot;what the heck&amp;quot; moment.&lt;/p&gt;
&lt;p&gt;I was trying to display &amp;quot;Mr &amp;amp; Mrs&amp;quot; as an Item in a ComboBox but it just was not happening.&lt;/p&gt;
&lt;p&gt;I suppose that this would not have come to light if my computer was not slowing down when I opened the ItemCollection window in Visual Studio.&amp;nbsp; It was so slow that I would type something then have to wait for a couple of seconds to show what I had typed.&amp;nbsp; If I made a mistake I had to change it which would take more time, so I decided to just add the five combobox items in the XMAL itself.&lt;/p&gt;
&lt;p&gt;As soon as I typed the item in, I got the squiggly blue line and the following error.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/001ampersand.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which really threw me.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Being an old HTML boy from years past it finally hit me.&amp;nbsp; XAML is a markup language and most, if not all, markup languages use the ampersand (&amp;amp;) for defining special characters and XML (which XAML is based on) is no different.&lt;/p&gt;
&lt;p&gt;XAML has the same &lt;a href="http://msdn.microsoft.com/en-us/library/ms748250.aspx" target="_blank"&gt;character entities&lt;/a&gt;&amp;nbsp;as XML and one of these is for using the ampersand in markup.&lt;/p&gt;
&lt;p&gt;Having refreshed my memory getting the desired result was an easy fix.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/02ampersand.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which, when run, shows correctly in the ComboBox.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/03ampersand.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/canoz/aggbug/9193.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674686" width="1" height="1"&gt;</description></item><item><title>WPF MIA - Anchor, Alignments,Canvas and Margins</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/10/25/wpf-mia-anchor-alignments-canvas-and-margins.aspx</link><pubDate>Sat, 25 Oct 2008 21:07:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674651</guid><dc:creator>Admin</dc:creator><slash:comments>1</slash:comments><description>&lt;font face="Verdana" size="2"&gt;
&lt;p&gt;&amp;nbsp;Continuing my look at features that seem to be Missing in Action (MIA) from Windows Forms, vbCity colleague Matt pointed out to me that the Anchor property seems to have disappeared. &lt;/p&gt;
&lt;p&gt;&amp;nbsp; I&amp;#39;m really pleased that this came up, because it gives me an opportunity to highlight just some of the massive flexibility you have in WPF Windows when it comes to layout. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;So what does WPF have to offer that will work as well as Anchors do? Umm, that should probably read &amp;#39;better than Anchors do&amp;#39;, because let&amp;#39;s face it, WinForms Anchoring doesn&amp;#39;t always offer you the precise flexibility you want. But the short answer to the original question is: Lots! &lt;/p&gt;
&lt;p&gt;&amp;nbsp;I&amp;#39;m only going to cover a few examples here and then invite you to play with the ideas I have suggested. Using these, you can ensure that every control (or element, as we should properly call them in WPF) sits exactly where you tell it to, and stays anchored or not as the Window resizes, according to your wishes. &lt;/p&gt;
&lt;p&gt;&lt;u&gt;HorizontalAlignment, VerticalAlignment and Margins&lt;/u&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; These two properties are reasonably close to the Anchor properties in WinForms. HorizontalAlignment gives you the choice of aligning (read: Anchoring) to Left or Right. So you can see how they relate to Anchor Left and Anchor Right. However, WPF never does layout by halves, so you also have two more choices - Center and Stretch. I won&amp;#39;t insult your intelligence by telling you what those additional settings do. &lt;/p&gt;&amp;nbsp;Here&amp;#39;s an example that will anchor a button to the top right hand corner of a Grid. 
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt; &lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;0,5,5,0&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Right&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="COLOR:red;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt; &lt;span style="COLOR:blue;"&gt; &amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;The result you will get is:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFMIA_Anchor/Align%20and%20Margin.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Notice that there is a 5 unit gap to the top and right of the button. I carefully used the word &amp;quot;unit&amp;quot; there because old habits always want me to say &amp;#39;pixel&amp;#39;. It isn&amp;#39;t necessarily 5 pixels gap; WPF thinks in terms of &amp;#39;device independent units&amp;#39;, but in many common scenarios you can still think pixels.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;The two gaps are set by the Margin property. &amp;quot;0,5,5,0&amp;quot; translated to: 
&lt;ul&gt;
&lt;li&gt;0 for the Left Margin 
&lt;li&gt;5 for the Top Margin 
&lt;li&gt;5 for the Right Margin 
&lt;li&gt;0 for the Bottom Margin &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Go ahead and tweak those settings to see how changes affect the position. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;If you try this markup, run the project and then resize the Window, that button will stick like glue to its position at the top right.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Obviously, if you don&amp;#39;t want any gaps then you can dispense with the Margin settings. This version uses the Left and Bottom settings only.&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:red;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Bottom&amp;quot; &amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFMIA_Anchor/Align%20Only.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Margins Only&lt;/u&gt;&lt;br /&gt;&amp;nbsp; If you want an element to expand (and reduce) as the containing Window or other container resizes then you can achieve this just by setting the Margin properties. &lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Black&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp;  &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;20,50&amp;quot;&lt;/span&gt; &lt;span style="COLOR:blue;"&gt; &amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFMIA_Anchor/Margins%20Only(Before).png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFMIA_Anchor/Margins%20Only(After).png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Alignment and Width&lt;/u&gt;&lt;br /&gt;&amp;nbsp; Another combination you can try is to use one of the alignments, together with hard coding the Width or Height of a control. Usually you won&amp;#39;t want or need to fix a height or width, but there may be cases where this works for you. Try something like this:&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Black&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:red;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Bottom&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Width&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;90&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFMIA_Anchor/Alignment%20and%20Width.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;And in case you were wondering - yes, you can also add settings for the Margins too, so that you can position it, for example, a set distance from the Bottom edge.&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Black&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:red;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Bottom&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Width&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;90&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;0,0,0,15&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I hope that by now you&amp;#39;re starting to get the idea that WPF layout isn&amp;#39;t going to miss the Anchor property any day soon! Combine the techniques shown above and you have a wide range of options.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Canvas&lt;/u&gt;&lt;br /&gt;&amp;nbsp;But we&amp;#39;re not done here yet. If you want to contain an element inside a panel and be able to fix its relative position, you could use a Canvas. Check out this markup:&lt;/p&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Black&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Canvas&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Margin&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;50,35&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Yellow&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Canvas.Left&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;12&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Canvas.Top&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;3&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Canvas&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This will net you the following, rather garish, result:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.xtabvbcity.plus.com/Blogs/WPFMIA_Anchor/Canvas.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;That button will remain 12 units from the left and 3 units from the top of that Canvas, no matter what else happens by way of resizing the Canvas, the Grid or even the Window. &lt;/p&gt;
&lt;p&gt;I think that even these simple, single examples show a great deal of power and flexibility for positioning elements. Bear in mind that you can build up layers of containers and panels and elements inside each other - and control the placement of each of them individually in relation to its container. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;While the familiar Anchor may be missing, I somehow think that once you become used to using these new techniques you won&amp;#39;t actually miss it at all. &lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9192.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674651" width="1" height="1"&gt;</description></item><item><title>WPF MIA: BackColor, Background, Colors and Brushes</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/10/23/wpf-mia-backcolor-background-colors-and-brushes.aspx</link><pubDate>Fri, 24 Oct 2008 03:56:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674653</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="Verdana" size="2"&gt;
&lt;p&gt;&amp;nbsp; One of the things that first caught me out in WPF was the simple topic of colors. For example, let&amp;#39;s say you want to reset the BackColor of a Form in Windows Forms. &lt;br /&gt;&lt;br /&gt;Easy enough. This will do the job:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Me&lt;/font&gt;.BackColor = Color.CadetBlue&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;When it comes to WPF, you&amp;#39;ll know that we are dealing with a Window, instead of a Form and have probably already picked up that &lt;b&gt;BackColor&lt;/b&gt; is now &lt;b&gt;Background&lt;/b&gt;. &amp;nbsp;You can however, still use &amp;quot;Me&amp;quot; to reference the Window.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;But if you were to try something like:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Me&lt;/font&gt;.Background = Color.CadetBlue&lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; or even&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;Me&lt;/font&gt;.Background = Colors.CadetBlue&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;you would be disappointed. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;You would however get some help from Intellisense (at least with the second version). The error message tells you that a Color cannot be converted to a Brush. And there&amp;#39;s the answer to the problem. &lt;br /&gt;&lt;br /&gt;The Background property doesn&amp;#39;t take a Color - it takes a Brush, which of course can, and usually does, have a color assigned to it. Don&amp;#39;t forget though that you are not limited to a single solid color; there are many gradient, tile and image based options that you can choose when it comes to brushes in WPF. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;So this code will work fine in WPF:&lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;Me&lt;/font&gt;.Background =&lt;font color="#0000ff"&gt; New&lt;/font&gt; SolidColorBrush((Colors.CadetBlue))&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&amp;nbsp;Ah yes, I hear you say, but what about the theory that you should use XAML for the look and code-behind for the behaviour? Well, I can&amp;#39;t disagree with you there and personally I would use:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Window&lt;/span&gt;&lt;span style="COLOR:red;"&gt; x&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:red;"&gt;Class&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Window1&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;  &lt;span style="COLOR:red;"&gt; xmlns&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;  &lt;span style="COLOR:red;"&gt; xmlns&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:red;"&gt;x&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;  &lt;span style="COLOR:red;"&gt; Title&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;Window1&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Height&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;300&amp;quot;&lt;/span&gt;&lt;span style="COLOR:red;"&gt; Width&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;300&amp;quot;&lt;/span&gt; &lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:red;"&gt;Background&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;CadetBlue&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&amp;nbsp;where the Background property for the Window is set there in the XAML. However, there may well be times when you want the user to have a say in color choices and in those cases it can be easier to take the user&amp;#39;s input and deal with it in the code-behind. &lt;/p&gt;
&lt;p&gt;&amp;nbsp; For example, if the user was empowered to enter values for the ARGB components then you might use an approach like the following: &lt;/p&gt;
&lt;p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/font&gt; col&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; System.Windows.Media.Color&lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;&amp;nbsp;&amp;nbsp;In reality the values below could be&lt;/font&gt;&lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; selected by the user and passed in&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;col = Color.FromArgb(214, 122, 52, 24)&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/font&gt; br&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; SolidColorBrush(col)&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me&lt;/font&gt;.Background = br&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; It would also be quite easy to create a display in WPF where you bind, for example, sliders to the Brush that is used for the background. But I won&amp;#39;t go any deeper into that just now, as this sub-set of blog items is meant only to help identify those missing WinForms favorites and repatriate them as WPF troops. &lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9191.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674653" width="1" height="1"&gt;</description></item><item><title>WPF: How To Hide the Minimize and Maximize Buttons</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/10/22/wpf-how-to-hide-the-minimize-and-maximize-buttons.aspx</link><pubDate>Wed, 22 Oct 2008 16:17:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674654</guid><dc:creator>Admin</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;For some time now, I&amp;#39;ve been promising myself that one day I will create a&amp;nbsp;&amp;nbsp;list of what I like&amp;nbsp;to&amp;nbsp;think of as &amp;quot;WPF MIA&amp;quot; - those basic elements&amp;nbsp;that I am totally familiar with in WindowsForms, but which somehow seem to have disappeared into thin air in WPF.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;In many cases of course the tools are still there; it&amp;#39;s just that the name has changed.&amp;nbsp;&amp;nbsp; Here&amp;#39;s an example:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;In Windows Forms, you can hide the Minimize and Maximize buttons by setting the MinimizeBox or MaximizeBox to False&amp;nbsp; I guess that this is most people&amp;#39;s favourite way of doing this.&amp;nbsp;If you dig deeper into the Properties Window though, there is also the &amp;nbsp;FormBorderStyle property.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp; I used to think that this property was only good for things like changing&amp;nbsp;the border style, say, from 3D to single line.&amp;nbsp; But actually if you choose FixedToolWindow or SizableToolWindow then you automatically get a Form that only has the close button - no Min or Max.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp; So what about WPF then? Does it have the same properties available?&amp;nbsp;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp;&amp;nbsp;If you&amp;#39;ve spent any time on WPF, you&amp;#39;ll know that that&amp;#39;s really a rhetorical question because you can almost guarantee that things will have changed.&amp;nbsp;Now though&amp;nbsp;you have a WindowStyle property which you can use to set the Window&amp;#39;s border style, including showing or hiding the Max and Min buttons.&amp;nbsp; To have those buttons hidden, you need to choose the &lt;strong&gt;ToolWindow&lt;/strong&gt; option.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&amp;nbsp; As far as&amp;nbsp;I know, there isn&amp;#39;t a property setting that will hide the individual buttons&amp;nbsp;in in WPF.&amp;nbsp; At first I found this a bit surprising.&amp;nbsp;&amp;nbsp; However,&amp;nbsp; as I&amp;#39;ve become more familiar with WPF and its ability to morph its Windows into almost any conceivable style and shape, I can see that creating your own Window style is so easy that maybe those properties would have been almost redundant anyway.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9189.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674654" width="1" height="1"&gt;</description></item><item><title>Printing a Windows Foundation Presentation FlowDocument</title><link>http://new.vbcity.com/blogs/canoz/archive/2008/10/18/printing-a-windows-foundation-presentation-flowdocument.aspx</link><pubDate>Sat, 18 Oct 2008 08:05:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674687</guid><dc:creator>Admin</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I have just discovered the most compelling reason to port over any projects I have to Windows Presentation Foundataion (WPF) as well as only starting new projects as a WPF project.&lt;/p&gt;
&lt;p&gt;The reason you ask?&amp;nbsp; Well the answer is one word.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="5"&gt;Printing&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Being a File I/O guy, printing has almost always needed to be a part of most projects that I have written so this is a really big thing for me.&amp;nbsp; Looking back printing with Visual Basic.NET was painful for me at times especially if the document spanned several pages and I don&amp;#39;t even want to get into printing with pre .NET Visual Basic.&lt;br /&gt;That, however, is the past and today we take a look at the present and future.&lt;/p&gt;
&lt;p&gt;After creating a &lt;a href="http://blogs.vbcity.com/canoz/archive/2008/10/08/9182.aspx" target="blank"&gt;table in a flowdocument&lt;/a&gt; I got to thinking about being ability to print out the flowdocument.&lt;/p&gt;
&lt;p&gt;The WPF PrintDialog class has two methods for printing.&amp;nbsp; The two methods are PrintVisual and PrintDocument.&lt;br /&gt;&lt;br /&gt;This post will deal with the PrintDocument method.&lt;/p&gt;
&lt;p&gt;When you use PrintDocument you don&amp;#8217;t actually pass the flowdocument that you want to print as a parameter, you use a DocumentPaginator object.&lt;/p&gt;
&lt;p&gt;What the documentpaginator does is take the content of the flowdocument and breaks it up into multiple pages (if required) then passes the page(s) to the printer to be printed out.&lt;/p&gt;
&lt;p&gt;After importing the necessary namespaces and declaring two Form level variables&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/001wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I started out with the code to create a flowdocument that goes over more than one page I used the following code.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:#c8c8c8;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;&amp;#39; Create the parent FlowDocument...&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; flowDoc = &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; FlowDocument()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;Dim&lt;/span&gt; table2 &lt;span style="COLOR:blue;"&gt;As&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Table()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; flowDoc.Blocks.Add(table2)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.Columns.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableColumn)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.Columns.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableColumn)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.Columns.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableColumn)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.Columns.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableColumn)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Create and add an empty TableRowGroup to hold the table&amp;#39;s Rows.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRowGroup())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Add the first (title) row.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups(0).Rows.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Alias the current working row for easy reference.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;Dim&lt;/span&gt; currentRow2 &lt;span style="COLOR:blue;"&gt;As&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2 = table2.RowGroups(0).Rows(0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;Dim&lt;/span&gt; v &lt;span style="COLOR:blue;"&gt;As&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Image&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; v.Source = &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; BitmapImage(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Uri(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;dice.jpg&amp;quot;&lt;/span&gt;, UriKind.Relative))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; v.Height = 80&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; v.Width = 80&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Add cells with content to the second row.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Loan Report&amp;quot;&lt;/span&gt;))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells(0).ColumnSpan = 3&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.FontSize = 50&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Foreground = Brushes.RosyBrown&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells(0).TextAlignment = TextAlignment.Center&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; BlockUIContainer(v)))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups(0).Rows.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2 = table2.RowGroups(0).Rows(1)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot; For: Neil Knobbe, &amp;quot;&lt;/span&gt; &amp;amp; Now.Date.ToLongDateString))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells(0).TextAlignment = TextAlignment.Center&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells(0).ColumnSpan = 4&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups(0).Rows.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2 = table2.RowGroups(0).Rows(2)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Ammount Borrowed: Borrowed Variable&amp;quot;&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Monthly Payment: Payment Variable&amp;quot;&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Interest: Interest Variable&amp;quot;&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Duration: Duration Variable&amp;quot;&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Reason For Loan: Reason Varaible&amp;quot;&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Lender: Lender Variable&amp;quot;&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Loan Number: LoanNum Variable&amp;quot;&lt;/span&gt;))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells(0).ColumnSpan = 2&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow2.Cells(0).Padding = &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Thickness(10)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Create and add an empty TableRowGroup to hold the table&amp;#39;s Rows.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRowGroup())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Add the first (title) row.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups(1).Rows.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Alias the current working row for easy reference.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;Dim&lt;/span&gt; currentRow &lt;span style="COLOR:blue;"&gt;As&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow = table2.RowGroups(1).Rows(0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;&amp;#39; Add the header row with content, &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Date&amp;quot;&lt;/span&gt;))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Balance&amp;quot;&lt;/span&gt;))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Payment&amp;quot;&lt;/span&gt;))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Interest&amp;quot;&lt;/span&gt;))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(0).Foreground = Brushes.RosyBrown&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(0).TextAlignment = TextAlignment.Left&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(1).Foreground = Brushes.RosyBrown&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(1).TextAlignment = TextAlignment.Left&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(2).Foreground = Brushes.RosyBrown&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(2).TextAlignment = TextAlignment.Left&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(3).Foreground = Brushes.RosyBrown&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(3).TextAlignment = TextAlignment.Left&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups(1).Rows.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow = table2.RowGroups(1).Rows(1)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(0).ColumnSpan = 4&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(0).BorderThickness = &lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Thickness(0, 5, 0, 0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells(0).BorderBrush = Brushes.RosyBrown&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;Dim&lt;/span&gt; i &lt;span style="COLOR:blue;"&gt;As&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;Integer&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;For&lt;/span&gt; i = 2 &lt;span style="COLOR:blue;"&gt;To&lt;/span&gt; 25&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; table2.RowGroups(1).Rows.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableRow())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow = table2.RowGroups(1).Rows(i)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Column &amp;quot;&lt;/span&gt; &amp;amp; i - 1 &amp;amp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot; Entry - &amp;quot;&lt;/span&gt; &amp;amp; i.ToString))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Column &amp;quot;&lt;/span&gt; &amp;amp; i - 1 &amp;amp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot; Entry - &amp;quot;&lt;/span&gt; &amp;amp; i.ToString))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Column &amp;quot;&lt;/span&gt; &amp;amp; i - 1 &amp;amp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot; Entry - &amp;quot;&lt;/span&gt; &amp;amp; i.ToString))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentRow.Cells.Add(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; TableCell(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Paragraph(&lt;span style="COLOR:blue;"&gt;New&lt;/span&gt; Run(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Column &amp;quot;&lt;/span&gt; &amp;amp; i - 1 &amp;amp; &lt;span style="COLOR:#a31515;"&gt;&amp;quot; Entry - &amp;quot;&lt;/span&gt; &amp;amp; i.ToString))))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;Next&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ScrollView1.Document = flowDoc&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which, once I applied the table to a flowdocument and set the flowdocument to be the document of my FlowDocumentScrollViewer,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/01wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;gave me a table with 50 entries, shown in three columns, which I wanted to print.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/02wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now that the flowdocument was ready to print all that was left to do was create instance of a WPF PrintDialog and enter the one line of code needed to print the document.&lt;/p&gt;
&lt;p&gt;Yes you heard right, one line of code* to print a WPF flowdocument.&amp;nbsp; How much easier can it get?&amp;nbsp; (And I thought I was happy when the people at MS made reading the entire contents of a file into a single line of code for Visual Studio 2005.&amp;nbsp; I am simple ecstatic about this change to printing!)&lt;/p&gt;
&lt;p&gt;(* &lt;strong&gt;Note&lt;/strong&gt; &amp;#8211; Although you can accomplish printing with just this one line, there are a few gotchas that you will need to be aware of.&amp;nbsp; I will touch on some of these in a bit.)&lt;/p&gt;
&lt;p&gt;So, the magic line of code is:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/03wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Ok, I hear all you out there going &amp;quot;Ummm.... Neil that looks like 5 lines of code to me not one like you said.&amp;quot;&amp;nbsp; Which would be a valid statement and it is true there is a couple more lines of code.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Basically what I have done is put the print code in an If...End If statement which gives displays the printdialog to the user where they can choose their printer and print the document or cancel the print job all together. &lt;br /&gt;&amp;nbsp;&lt;br /&gt;All in all six lines of code to print out a single or multiple page document is nothing.&lt;/p&gt;
&lt;p&gt;What is the code doing then? &lt;/p&gt;
&lt;p&gt;As I mentioned earlier a new instance of a printdialog is created.&amp;nbsp; The printdialog is the window that is shown where you can select which printer you want to print with and other printing options.&lt;/p&gt;
&lt;p&gt;The printdialog is shown as a dialog window and if the user clicks the &amp;quot;OK&amp;quot; button, the flowdocument is cast as a DocumentPaginator object which is used as the first parameter of the printdialog&amp;#8217;s PrintDocument.&amp;nbsp; The second parameter of the printdocument is the name of the document being printed.&amp;nbsp; This name is what is displayed in the print queue of the printer so you can uniquely identify what documents are lined up to be printed.&lt;/p&gt;
&lt;p&gt;The Else portion of the If...End If statement handles if the user clicks the &amp;quot;Cancel&amp;quot; button.&amp;nbsp; A simple message box is displayed letting the user know that the print job has been cancelled.&lt;/p&gt;
&lt;p&gt;That in a nutshell is all that you need to do to print a flowdocument in a WPF application.&lt;/p&gt;
&lt;p&gt;Now for the gotchas that caught me while I tried to print.&lt;/p&gt;
&lt;p&gt;#1)&amp;nbsp; Multiple columns.&amp;nbsp; Let me tell you I this one really got me.&amp;nbsp; When I first tried to print the flowdocument in the image above, I expected the print out to look like the window.&amp;nbsp; Such was not the case.&amp;nbsp; What I ended up with was the entire table printed out on two columns per page over the three pages* the printed document covered.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/04wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This was not quite what I was expecting, but is apparently the default behaviour without having set any properties of the document to match the printer.&amp;nbsp; What I wanted was to have the table fill the entire width of the page.&lt;/p&gt;
&lt;p&gt;(* &lt;strong&gt;Note&lt;/strong&gt; - As a rather interesting side note here this is not what I got the first time I tried to print this flowdocument.&amp;nbsp; My first results were rather disappointing and I was very disillusioned with what I thought was going to be a much simplified printing process.&amp;nbsp; The image below is my first attempt at printing.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/05wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you can see it ended up quite the mess.&amp;nbsp; What happened was that all three pages of the flowdocument got printed in two columns on one page.&amp;nbsp; (If you look real close at the left column you can see the header of the table in the background then the first 8 lines have been printed twice.)&amp;nbsp; &lt;/p&gt;
&lt;p&gt;I can happily report that the fault with this lies with the printer and not how the WPF printdialog sent the document to the printer.&amp;nbsp; I have since tested several other printers and they all print as the multiple columns image.)&lt;/p&gt;
&lt;p&gt;Getting back on track and printing the document on only one column.&lt;/p&gt;
&lt;p&gt;The way to get around having multiple columns is to set the column width of the document to be printed prior to casting it as a documentpaginator object.&amp;nbsp; This is a simple process and requires only one line of code.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/06wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What this code does is sets the width of document in the scrollviewer to be the entire printable width of the page.&amp;nbsp; Now when the document is printed the table will span the width of the page.&lt;/p&gt;
&lt;p&gt;#2) Page size.&amp;nbsp; While perhaps not quite as important as multiple columns is getting the proper page size and margins for your printed output.&lt;/p&gt;
&lt;p&gt;You can set the bounds of your document to be printed by setting three properties of the document.&amp;nbsp; The three properties are the PrintableAreaHeight, PrintableAreaWidth and the Thickness.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;The PrintableAreaHeight and PrintableAreaWidth properties are pretty self explanatory.&amp;nbsp; The Thickness is what is used for the margin.&amp;nbsp; The thickness can be set with a universal value which will be applied to all sides, or you can set pass different parameters for the margin on each side.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/07wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;While it is not essential to set these three properties for printing it does ensure that your document fits the page or pages.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So, with adding in the few lines of code from the two gotchas, I finally was able to print out the report and have it look as I wanted it to.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/08wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The entire print code I used was:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/09wpfprinting.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There you have it a quick overview of printing in a WPF application.&amp;nbsp; As I said it is much easier and I have my doubts if I will ever look at starting another WinForms application.&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/canoz/aggbug/9184.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674687" width="1" height="1"&gt;</description></item><item><title>Tables in a Windows Presentation Foundation FlowDocument</title><link>http://new.vbcity.com/blogs/canoz/archive/2008/10/08/tables-in-a-windows-presentation-foundation-flowdocument.aspx</link><pubDate>Wed, 08 Oct 2008 07:24:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674689</guid><dc:creator>Admin</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;vbCity Leader (and Microsoft MVP) &lt;a href="http://blogs.vbcity.com/xtab/" target="blank"&gt;Ged Mead&lt;/a&gt; showed how to create a FlowDocument in &lt;a href="http://www.devcity.net/Articles/351/1/article.aspx" target="blank"&gt;his article&lt;/a&gt;&amp;nbsp;published on devCity.com.&lt;/p&gt;
&lt;p&gt;I got the challenge recently to display a data inserted in a table in a flowdocument.&amp;nbsp; So I embarked on my quest.&lt;/p&gt;
&lt;p&gt;I knew that what I wanted could be done because some quick testing with XAML I was easily able to add a table to my flowdocument.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/001WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Which gives an output like the following.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/01WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;My challenge, however, was that I needed to be able to do this with Visual Basic.NET code behind as the data that was to be displayed in the table was going to be read from a file.&lt;/p&gt;
&lt;p&gt;I made my first mistake almost immediately.&amp;nbsp; (Now that is probably not the best thing for me to admit when I am trying to convince everyone that I actually know what I am talking about, but hey, I am big enough to admit my mistakes.)&lt;/p&gt;
&lt;p&gt;The mistake I made was trying to use the wrong table.&amp;nbsp; I was able to create and insert the data from the file into the table I created with VB code, but when I tried to add the table to the flowdocument I couldn&amp;#8217;t.&amp;nbsp; No matter what I tried, I was just unable to add the table and after a couple of days, I finally gave up and asked for help.&amp;nbsp; Microsoft MVP Jay Harlow&amp;nbsp;quickly pointed me in the right direction.&lt;/p&gt;
&lt;p&gt;What the problem was is that there are more than one table that is accessible for use in the .NET Framework.&amp;nbsp; I was trying to use the table in the &lt;strong&gt;System.Web&lt;/strong&gt; Namespace, but in fact I needed to be using the table from the &lt;strong&gt;System.Windows.Documents&lt;/strong&gt; Namespace.&lt;/p&gt;
&lt;p&gt;Once I was referencing the correct table, the whole project came together quite nicely.&lt;/p&gt;
&lt;p&gt;(While the project I was doing required reading data from a file that will be outside the scope of this blog post.&amp;nbsp; In this post I will just be showing how to hardcode data into a table in a flowdocument.)&lt;/p&gt;
&lt;p&gt;The first thing that is needed is to Import the Namespace to give us access to use a table.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/02WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Next declare two form level variables.&amp;nbsp; One variable is declared as a flowdocument and the other is declared as a table.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/03WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In the event you want to create the table in, I used the Initialized event of the form for this example, set the two variables to a new instance of a flowdocument and table respectively.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/04WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now that there is a flowdocument and a table the table needs colums, rows and content for the table.&lt;/p&gt;
&lt;p&gt;The columns are the first things to be added to the table.&amp;nbsp; Columns are added to the collection, or array, of columns of the table.&amp;nbsp; For this example I am going to add four columns to the table.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/05WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;With the columns added, Rows can now be added to the table.&amp;nbsp; Like columns, rows are also held in an array of rows.&amp;nbsp; Where rows differ from columns is rows are actually part of RowGroups.&amp;nbsp; You can have several rows in a rowgroup and more than one rowgroup in a table. 
&lt;p&gt;So to start a new rowgroup must be added to the rowgroups of the table.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/06WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;and into that rowgroup a new row is added.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/07WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Although you still can&amp;#8217;t see it if you were to look at the form itself, the table now has four columns and one row.&amp;nbsp; Into the row Cells need to be added.&lt;/p&gt;
&lt;p&gt;At this point there is a great deal of possibilities to how what the table is going to look like.&amp;nbsp; While you can set some formatting for the table with changing the properties of the table and rows, you have much greater control over the look of the table by manipulating the properties of the cells.&lt;/p&gt;
&lt;p&gt;For this table I want to have a header that stretches across the entire top of the table, so while I can have four cells in the row (I can do this because I added four columns to the table earlier) only one is going to be added to the row.&amp;nbsp; The cell will then be made to stretch over the entire width of the table.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/08WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;There is quite a bit going on in the above line of code.&amp;nbsp; A new TableCell is added to the collection of cells of the row and to add content to the cell a new Paragraph is used as a parameter of the tablecell and a new Run of text is passed as a parameter of the paragraph.&lt;/p&gt;
&lt;p&gt;After adding what is going to be the title of the table, some formatting can be assigned.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/09WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;The first line of code above tells the cell to span the entire width of the four columns of the table.&amp;nbsp; (If you have worked with tables in Microsoft Word think of this process to be like merging cells in a table.) 
&lt;p&gt;The second line sets the size of the font to make the text stand out as a title and the third line centers the text in the cell.&amp;nbsp; (By default the text alignment of a table, row or cell is left.)&lt;/p&gt;The fourth line of code makes the font bold. 
&lt;p&gt;The fifth line of code sets the colour of the text in the cell and the sixth line gives the cell a colour for the background.&lt;/p&gt;If we add two more lines of code the table can be shown in the FlowDocumentReader. 
&lt;p&gt;The table is first added to the Blocks of the flowdocument that was declared at the beginning of our code then the flowdocument is assigned as the document of the FlowDocumentReader of the form.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/10WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;(&lt;strong&gt;Note&lt;/strong&gt;:&amp;nbsp; Interestingly enough it does not seem to matter where you place the code to add the table into the flowdocument and make the document of the reader to be your flowdocument.&amp;nbsp; The code can be added just after the declaration of the flowdocument and table or anywhere in the middle of the code that formats and populates the table.&amp;nbsp; Personally I put these two lines at the very end prior to displaying the flowdocument.)&lt;/p&gt;
&lt;p&gt;Now when the project is run, you can see the table starting to take shape.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/11WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Putting Headers for each column are next to be added to the table.&lt;/p&gt;
&lt;p&gt;A new row is added to the rowgroup of the table then four cells are added to the row with content also being added to each cell.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/12WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;You can see by the Index number of the rows that the new cells have been added to the second row.&amp;nbsp; Like all .NET arrays the rows array of a rowgroup, as is the rowgroup itself, are zero based so if you need to remember that the actual row number is one higher than the index number. 
&lt;p&gt;Running the project shows that the columns now have headers.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/13WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The table is really starting to look like a table now.&lt;/p&gt;
&lt;p&gt;A line under the column headers keeps the data in the columns separated from the headers.&amp;nbsp; To accomplish this, a new row is added under the row of headers.&amp;nbsp; One cell is added to the row and it will span the four columns like the title cell does.&amp;nbsp; To make the line, the border property of the cell is going to be used.&amp;nbsp; The top border of the cell will be made larger and given a colour.&lt;/p&gt;
&lt;p&gt;To make the border thicker a New Thickness is applied to the cell.&amp;nbsp; Thickness can either be set by passing a single parameter to the new thickness, which would give the same thickness to all sides of the cell, or you can pass four parameters and assign separate thicknesses to each side.&amp;nbsp; While it does not make any difference to what I am demonstrating here, I have only assigned a thickness to the top border of the cell.&amp;nbsp; I could have just as easily assigned a uniform thickness to the cell.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/14WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now the contents of the table will be separated from the column headers by a red line.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/15WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;With the formatting of the table set out, it is time to add some content into the table itself.&lt;/p&gt;
&lt;p&gt;For this example I am going to use a For&amp;#8230;Next Loop to populate the table.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/16WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Two Integer variables are declared.&amp;nbsp; The first is used to keep track of the index of the row in the rowgroup.&amp;nbsp; The variable is declared with a value of 3 because the first line that will be added in the loop will be the fourth element of the array of rows.&amp;nbsp; The second variable is just used for adding content to each of the cells as they are added to the row.&lt;/p&gt;
&lt;p&gt;In the loop the first line of code adds a new row to the table then the next four lines add the cells to the row and put some content in the cell.&amp;nbsp; In this example the content of the cells in the row will just have the text &amp;quot;Number: 0&amp;quot; to &amp;quot;Number: 97&amp;quot;.&lt;/p&gt;
&lt;p&gt;In the last line the value of the variable j is incremented by 1 so the content number of the next row will be one higher than the last.&lt;/p&gt;
&lt;p&gt;Now when the project is run the table is complete.&amp;nbsp; The table starts with:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/17WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;and six pages later going to:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/18WPFFlowDocumentTable.jpg" alt="" /&gt;&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/canoz/aggbug/9182.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674689" width="1" height="1"&gt;</description></item><item><title>Windows Presentation Foundation ToolTip</title><link>http://new.vbcity.com/blogs/canoz/archive/2008/10/07/windows-presentation-foundation-tooltip.aspx</link><pubDate>Wed, 08 Oct 2008 06:39:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674692</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Once again it seems that I had what I thought was a great idea only to find out that someone else had it before I did.&lt;/p&gt;
&lt;p&gt;I don&amp;#8217;t even know how I got to thinking about ToolTips and how boring they look, but I did and that got me to wondering what could be accomplished with Windows Presentation Foundation (WPF).&lt;/p&gt;
&lt;p&gt;What I eventually ended up with was using a Border which I would create custom messages in and display when the mouse was hovered over the object that the ToolTip was for.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/01WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;All in all I was fairly pleased with how it all looked and worked though it was kind of fiddly to implement.&amp;nbsp; I wasn&amp;#8217;t really sure, however, how to incorporate this tooltip idea into an application I did want to use it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That was, however, before I found out about the versatility of a WPF tooltip.&lt;/p&gt;
&lt;p&gt;In WPF, the tooltip is actually just a container like a panel or grid and pretty much anything that you can put into a container you can now use in a tooltip.&amp;nbsp; This expanded capability leads to endless possibilities for how a tooltip looks and how the user can now interact with it.&lt;/p&gt;
&lt;p&gt;We all know how boring tooltips look in a WinForms application.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/02WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;With just a few lines of code, this plain tooltip can be transformed into something a little more visually exciting.&lt;/p&gt;
&lt;p&gt;The tooltip in the next image was formatted with just six lines of code.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/03WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The code for this was pretty straight forward.&lt;/p&gt;
&lt;p&gt;A gradient was applied to the background of the tooltip.&amp;nbsp; Creating a &lt;a href="http://blogs.vbcity.com/canoz/archive/2008/07/16/9136.aspx" target="blank"&gt;gradient colour&lt;/a&gt; is the same process as creating a gradient for anything in a WPF application.&amp;nbsp; You can have as few as two colours up to a virtually endless number of colours.&amp;nbsp; A gradient is also applied to the border of the tooltip as well.&lt;/p&gt;
&lt;p&gt;The thickness of the border was increased so the colouring is more noticeable.&lt;/p&gt;
&lt;p&gt;The content is filled with what we wanted to have the tooltip say and added a drop shadow effect to give the tooltip a little bit of a 3D effect.&lt;/p&gt;
&lt;p&gt;The last property that is set is the Placement property.&amp;nbsp; The placement property allows you to set where the tooltip is displayed in relation to the control that it is for.&amp;nbsp; Some of the positions that you can place the tooltip are Top, Left, Right and Bottom.&amp;nbsp; You can also set an Absolute or Relative position for the tooltip.&lt;br /&gt;The last thing to do is set the tooltip that has just been defined as the tooltip of the control it is to be displayed for.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/04WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In addition to being able to customize the tooptip itself I mentioned earlier that you can place WPF content into the tooltip itself.&amp;nbsp; One drawback to putting WPF content into a tooptip you do still will see the thin border of the tooltip behind the WPF content.&amp;nbsp; I&amp;#8217;m sure that there must be a way to get rid of the border, and with Vista it is not as noticeable, I just have not found the way to do it yet.&lt;/p&gt;
&lt;p&gt;So with this in mind we will forge ahead with making an even more visual tooltip.&lt;/p&gt;
&lt;p&gt;The first component required for creating a tooltip for WPF content would be some sort of container.&amp;nbsp; In this example I am going to start with a StackPanel.&lt;/p&gt;
&lt;p&gt;In the stackpanel there is going to be some text and an image so the code is going to start with declarations for the three objects.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/05WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Add some formatting to the stackpanel.&amp;nbsp; In this case there are only two changes which are going to be applied to the stackpanel.&amp;nbsp; A LinearGradientBrush is going to be applied to the background and the Orientation of the stackpanel is also set.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/06WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;For the Image there are just three properties that are going to be set.&amp;nbsp; The source, height and width of the image are defined.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/07WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;For the textblock the content is set as well as some text formatting and the text is also centered in the textblock.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/08WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;All that is left now is to add the image and textblock to the stackpanel then apply the stackpanel to be the tooltip of the textbox on the Form.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/09WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;All this work now gives a much&amp;nbsp;more fancy&amp;nbsp;tooltip, looking like the following image.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.neilknobbe.com/blogimages/10WPFToolTip.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;So you can see that the boring old tooltip is now a thing of the past.&lt;/p&gt;This post has only scratched the surface of what can be done with a tooltip in a WPF application.&amp;nbsp; I plan on investigating this tool much more to see just what can be done with it.
&lt;p&gt;You will need to keep in mind that you can&amp;#8217;t put content into the tooltip that can have user interaction because the tooltip can&amp;#8217;t get focus.&amp;nbsp; If you put something like a button in a tooltip, which you can do with WPF, the click would just go through the button and click onto the control on the form.&lt;/p&gt;&lt;img src="http://blogs2.vbcity.com/canoz/aggbug/9180.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674692" width="1" height="1"&gt;</description></item><item><title>Object Initializers - A New Perspective</title><link>http://new.vbcity.com/blogs/xtab/archive/2008/08/28/object-initializers-a-new-perspective.aspx</link><pubDate>Thu, 28 Aug 2008 14:09:00 GMT</pubDate><guid isPermaLink="false">60071eb8-32bf-4b0e-b676-4ec5b931cdb5:674657</guid><dc:creator>Admin</dc:creator><slash:comments>0</slash:comments><description>&lt;font face="verdana"&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;There&amp;#39;s something that&amp;#39;s always bothered me a little bit about creating classes. We go to the trouble of creating backing Private fields and Public properties in order to implement data hiding - right?&amp;nbsp;&amp;nbsp; And when we want to include data validation, we usually use properties for that task, don&amp;#39;t we? &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; But then what do we do? We go and create a parameterized constructor that lets client code push invalid data straight into a field. At least that&amp;#39;s what I see in most of the class building examples I&amp;#39;ve&amp;nbsp;come across&amp;nbsp;- both in books as well as in real world code. It&amp;#39;s quite rare to see values passed into properties in a parameterized constructor; fields seem to be the most popular recipients of initialization data.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I&amp;#39;m surprised at how many times I&amp;#39;ve seen this done. Of course it&amp;#39;s possible to include validation in the constructor too (but the examples I&amp;#39;ve seen that use fields rarely seem to do&amp;nbsp;this; leaving the door to bad data wide open) &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Luckily, we now have a very easy solution - Object Initializers.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;In fact, you could claim that with the arrival of Object Initializers the parameterized constructor has just about become redundant. &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Parameterized constructors were devised to make it easy to pass arguments in to a constructor and to avoid having to add several lines of code for property values when initializing a new object. You know the sort of thing:-&lt;/p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; sr&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; SalesRecord&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sr.CustomerName =&lt;font color="#a31515"&gt; &amp;quot;Joe Soap&amp;quot;&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sr.Total = 2399.65&lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;&amp;nbsp;&amp;nbsp;etc&amp;nbsp;&amp;nbsp;etc&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;which was short-circuited with :-&lt;/p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; sr&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; SalesRecord(&lt;font color="#a31515"&gt;&amp;quot;Joe Soap&amp;quot;&lt;/font&gt;, 2399.65)&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;However, as I said, in most cases people code this so that it assigns the CustomerName and Total values directly to the fields.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Object Initializers step round this issue while still enabling client code to be fairly concise. How it works is that when you initialize an instance of a class object you are allowed to use the &amp;#39;With&amp;#39; keyword as a way of assigning values to properties, all in one line of code. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Let&amp;#39;s knock up a quick class to demo this.&lt;/p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Public&lt;/font&gt;&lt;font color="#0000ff"&gt; Class&lt;/font&gt; Product&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt; _itemcode&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt;&lt;font color="#0000ff"&gt; Property&lt;/font&gt; ItemCode()&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Get&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&lt;/font&gt; _itemcode&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Get&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/font&gt;(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; value&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_itemcode = value&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Set&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Property&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt; _cost&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Decimal&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt;&lt;font color="#0000ff"&gt; Property&lt;/font&gt; Cost()&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Decimal&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Get&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&lt;/font&gt; _cost&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Get&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/font&gt;(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; value&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; Decimal&lt;/font&gt;)&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&lt;/font&gt; value &amp;gt; 0&lt;font color="#0000ff"&gt; Then&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_cost = value&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_cost = 0&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; If&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Set&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Property&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/font&gt; _itemname&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&lt;/font&gt;&lt;font color="#0000ff"&gt; Property&lt;/font&gt; ItemName()&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Get&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&lt;/font&gt; _itemname&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Get&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/font&gt;(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; value&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_itemname = value&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Set&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Property&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Class&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;So, three fields, three properties (one of which includes some validation) and just the default constructor. To create a new instance of the Product class and assign values to any of the properties that interest us, this is what we can now do:&lt;/p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; P1&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; Product&lt;font color="#0000ff"&gt; With&lt;/font&gt; {.ItemName =&lt;font color="#a31515"&gt; &amp;quot;Widget&amp;quot;&lt;/font&gt;, .Cost = 0.99}&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;That&amp;#39;s it! &amp;nbsp;&amp;nbsp; A Product instance with those values for the ItemName and Cost properties now exists. And of course the validation is applied effectively at the time of instantiation to avoid any unacceptable values being passed. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;Note that the property assignments are contained inside curly braces and not standard parentheses.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;There are several advantages to this approach. Not only does it get around the validation problem I mentioned at the start, but it also allows you to pick&amp;#39;n&amp;#39;mix the properties you want to assign values to when you instantiate the object. As you saw in my example above, I chose only to assign values to two of the properties. &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; And if that&amp;#39;s not enough to get you interested, there&amp;#39;s more. You even have the&amp;nbsp;further advantage that you can pass the values in any order you like (unlike the standard parameter arguments which have to be passed in a strict order). &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; Finally, if there is a parameterized constructor available that contains some, but not all, the arguments you want to pass in, then you can simply combine the two approaches and use the constructor&amp;#39;s parameters, as well as the object initializers, all in one chunk of initialization code. &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;So if you had this parameterized constructor in the class:- &lt;/p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;Sub&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt;(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; code&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; String&lt;/font&gt;)&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me&lt;/font&gt;.ItemCode = code&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;End&lt;/font&gt;&lt;font color="#0000ff"&gt; Sub&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;you could use the following code to assign values to all three properties:-&lt;/p&gt;
&lt;div style="MARGIN-LEFT:10pt;MARGIN-RIGHT:2pt;"&gt;
&lt;div style="FONT-SIZE:10pt;"&gt;&lt;b&gt;Code &lt;/b&gt;&lt;a&gt;Copy &lt;/a&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:15px;OVERFLOW:auto;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;BACKGROUND-COLOR:#d1eecc;"&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; P2&lt;font color="#0000ff"&gt; As&lt;/font&gt;&lt;font color="#0000ff"&gt; New&lt;/font&gt; Product(&lt;font color="#a31515"&gt;&amp;quot;TOOL12&amp;quot;&lt;/font&gt;)&lt;font color="#0000ff"&gt; With&lt;/font&gt; {.ItemName =&lt;font color="#a31515"&gt; &amp;quot;Spade&amp;quot;&lt;/font&gt;, _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Cost =&lt;font color="#a31515"&gt; &amp;quot;12.99&amp;quot;&lt;/font&gt;}&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; How cool is that? &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; To be honest, I&amp;#39;m not sure how often I&amp;#39;d want to do that - given that I can do the same thing using three object initializers - but it&amp;#39;s an option to consider. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;So there it is. A new feature that you may have heard about but weren&amp;#39;t sure if it was going to be of use to you. Personally, I think it&amp;#39;s great and plan on implementing this approach whenever I can from now on.&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs2.vbcity.com/xtab/aggbug/9166.aspx" width="1" height="1" alt="" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://new.vbcity.com/aggbug.aspx?PostID=674657" width="1" height="1"&gt;</description></item></channel></rss>