<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Waseem Sadiq</title><subtitle type="html">Waseem on software development and information technology</subtitle><id>http://bloggingabout.net/blogs/waseem/atom.aspx</id><link rel="alternate" type="text/html" href="http://bloggingabout.net/blogs/waseem/default.aspx" /><link rel="self" type="application/atom+xml" href="http://bloggingabout.net/blogs/waseem/atom.aspx" /><generator uri="http://communityserver.org" version="4.1.40407.4157">Community Server</generator><updated>2005-12-22T10:06:00Z</updated><entry><title>Signing your clickonce application with a certificate created by your own CA root</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2007/04/12/signing-your-clickonce-application-with-a-certificate-created-by-your-own-ca-root.aspx" /><id>/blogs/waseem/archive/2007/04/12/signing-your-clickonce-application-with-a-certificate-created-by-your-own-ca-root.aspx</id><published>2007-04-12T04:43:47Z</published><updated>2007-04-12T04:43:47Z</updated><content type="html">&lt;p&gt;I have been investigating how to sign a clickonce application using a certificate signed by our own corporate w2k3 Certification Services. Easy enough you would think? True... but unfortunatly quite a lot of time passed between the idea and the signed application :-) Most of the samples and documentation assume you will be buying an AuthentiCode certificate from VeriSign or the likes.&lt;/p&gt; &lt;p&gt;The two pieces of the puzzle that made everything click are the following two url's (in order of appearance):&lt;/p&gt; &lt;p&gt;Creating a certificate for code signing&lt;/p&gt; &lt;p&gt;&lt;a title="http://www.leastprivilege.com/W2K3CAAndCodeSigningCertificates.aspx" href="http://www.leastprivilege.com/W2K3CAAndCodeSigningCertificates.aspx"&gt;http://www.leastprivilege.com/W2K3CAAndCodeSigningCertificates.aspx&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Converting the certificate to a .pfx file that can be used by Visual Studio&lt;/p&gt; &lt;p&gt;&lt;a title="http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=78d107d1-3937-4d8d-81d9-73cb6ae18eee" href="http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=78d107d1-3937-4d8d-81d9-73cb6ae18eee"&gt;http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=78d107d1-3937-4d8d-81d9-73cb6ae18eee&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Here are the steps that I took to create a certificate that can be used for signing (based on the information found at the above two links):&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 1: Enable the code signing template&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Before requesting a certificate from your CA service, you first have to enable the code signing template by using the certtmpl.msc MMC snapin. This &lt;a href="http://www.leastprivilege.com/W2K3CAAndCodeSigningCertificates.aspx"&gt;link&lt;/a&gt; describes how to do that.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 2: Request the certificate&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Go to your certificate services website and request the certificate the way you normally would, choose the options for requesting an advanced certificate. The following screen will appear (click the image for a bigger version):&lt;/p&gt; &lt;p&gt;&lt;a href="http://bloggingabout.net/UserFiles/waseem%20sadiq/WindowsLiveWriter/Signingyourclickonceapplicationwithacert_D162/Request-A-Certificate%5B8%5D.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="164" src="http://bloggingabout.net/UserFiles/waseem%20sadiq/WindowsLiveWriter/Signingyourclickonceapplicationwithacert_D162/Request-A-Certificate_thumb%5B6%5D.png" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;There are some things to do before you click the request button though: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Choose C&lt;em&gt;ode signing&lt;/em&gt; under certificate template&lt;/li&gt; &lt;li&gt;Select the M&lt;em&gt;ark keys as exportable&lt;/em&gt; checkbox&lt;/li&gt; &lt;li&gt;Select the E&lt;em&gt;xport keys to file&lt;/em&gt; checkbox that will appear&lt;/li&gt; &lt;li&gt;Enter a path and filename in the &lt;em&gt;Full path name&lt;/em&gt; textbox (for example c:\MyKey.pvk)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Leave all the other settings to their defaults (unless you know what you are doing, which I myself do not) and press the &lt;em&gt;submit&lt;/em&gt; button.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 3: Ignore all the security warnings&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Just click yes to all the browser based whining :-)&lt;/p&gt; &lt;p&gt;The browser will save the file with your private key (the one with the .pvk extension) to the location that you specified in step 2.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 4: Enter password and save certificate&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;In the screen that appears next, enter a password. After you click ok you will be presented with the option to download the certificate file (with a .cer extension). Save this file somewhere on your hard-drive, preferably at the same location as the one that you entered in step 2.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 5: Follow the steps on Brian Noyes's blog&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Brian Noyes has an excellent &lt;a href="http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=78d107d1-3937-4d8d-81d9-73cb6ae18eee"&gt;post&lt;/a&gt; on his blog describing the steps that need to be taken to create a pfx file. In short the steps are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=F9992C94-B129-46BC-B240-414BDFF679A7&amp;amp;displaylang=EN"&gt;Download&lt;/a&gt; and install pvkimprt.exe&lt;/li&gt; &lt;li&gt;Run &lt;em&gt;pvkimprt.exe MyCert.cer MyCert.pvk&lt;/em&gt;&lt;/li&gt; &lt;li&gt;Enter the password that you choose in step 4&lt;/li&gt; &lt;li&gt;Next » Next » Finish » OK&lt;br&gt;&lt;/li&gt; &lt;li&gt;Run certmgr.exe from the VS Command Prompt&lt;/li&gt; &lt;li&gt;Select your imported certificate and&amp;nbsp;click the &lt;em&gt;export&lt;/em&gt; button&lt;/li&gt; &lt;li&gt;Next » (important) choose the &lt;em&gt;yes, export the private key option&lt;/em&gt;&lt;/li&gt; &lt;li&gt;Next » Next » &lt;em&gt;enter password » enter location and filename to save pfx file to&lt;/em&gt;&amp;nbsp;»&lt;em&gt;&amp;nbsp;&lt;/em&gt;Next&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Step 6: Sign your application&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;That's it! You have just created a pfx file that you can use for signing your ClickOnce application. Your CA certificate needs to be trusted as a CA root by your clients and your publisher certificate (the .cer file that you created in step 2) needs to be trusted as a publisher. This can be accomplished by manually importing the certificate on the client machines or pushing the certificate out through your infrastructure tooling.&lt;/p&gt; &lt;p&gt;You can now take the pfx file and apply it on the &lt;em&gt;signing&lt;/em&gt; tab of your project properties.&lt;/p&gt; &lt;p&gt;&lt;a href="http://bloggingabout.net/UserFiles/waseem%20sadiq/WindowsLiveWriter/Signingyourclickonceapplicationwithacert_D162/Sign-ClickOnce-Application%5B1%5D.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="120" src="http://bloggingabout.net/UserFiles/waseem%20sadiq/WindowsLiveWriter/Signingyourclickonceapplicationwithacert_D162/Sign-ClickOnce-Application.png" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Remarks&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Do not forget that the certificate that you created will expire in one year (unless you changed the template in certtpl.msc). There is a&amp;nbsp;&lt;a href="http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=e020da51-7035-48e2-accb-3e84c4f7f8c3"&gt;specific issue&lt;/a&gt; with ClickOnce if you re-issue a certificate with a new public/private key-pair. If you simply renew your certificate this should not be too big of an issue.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Hope this helps,&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Waseem&lt;/p&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=158849" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>Tagged</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2007/01/08/tagges.aspx" /><id>/blogs/waseem/archive/2007/01/08/tagges.aspx</id><published>2007-01-08T10:31:35Z</published><updated>2007-01-08T10:31:35Z</updated><content type="html">&lt;p&gt;&lt;a href="http://blog.edwardsmit.com/"&gt;Edward Smit&lt;/a&gt; was kind enough to think of me by including me in his 5 people to tag list, so I guess it's my turn to tell you 5 things about me that you probably didn't know.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Since all the geek blogs talk about their first computer experience, I might as well keep up that tradition by telling you about my very first &lt;a href="http://www.mercadolibre.com.ve/org-img/items/MLV/062006/5263947_2297.jpg"&gt;Compaq Pressario CDS 524&lt;/a&gt; 486DX2 66 Mhz. You know how all the kids watch the ads for all their favourite toys for hours; knowing that their dad probably wouldn't get them that toy anyway... well I sure got mine :-)&amp;nbsp;&lt;br&gt;&lt;br&gt;The reason I wanted to program was because I wanted to create my own Mario Brothers clone... something that is still on my todo list today.&lt;br&gt;&lt;br&gt;My very first program was written in QBasic (which came for free with MS-DOS 6.11) and was typed over from a book that I borrowed from a local library (altough I can't remember what the program exactly did).&lt;br&gt;&lt;br&gt;My very first &lt;em&gt;real&lt;/em&gt; programming experience&amp;nbsp;was when I created my very own 'strafwerk-generator'&amp;nbsp; (for the dutchies) :-)&lt;br&gt;&lt;/li&gt; &lt;li&gt;My parents are originally from Pakistan, my dad used to be an electrical engineer. I guess that's where my geekiness came from.&lt;br&gt;&lt;/li&gt; &lt;li&gt;I am getting maried May 2nd with the love of my life.&lt;br&gt;&lt;/li&gt; &lt;li&gt;Just like &lt;a href="http://haacked.com/archive/2007/01/02/Five_Things_You_Didnt_Want_To_Know_About_Me.aspx"&gt;Phil Haack&lt;/a&gt; I used to be a breakdancer during high-school. My favourite move also was the dreaded headspin... unfortunatly I never really learnt to master it.&lt;br&gt;&lt;/li&gt; &lt;li&gt;I am compared to a lot of my (ex-)colleagues (except these &lt;a href="http://bloggingabout.net/blogs/olaf/default.aspx"&gt;two&lt;/a&gt; &lt;a href="http://bloggingabout.net/blogs/emile/"&gt;guys&lt;/a&gt;) quite young: 24 as we speak. This kind of makes it hard for me to convince people to believe me when&amp;nbsp;they look at my resumé&amp;nbsp;:-)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Well not really&amp;nbsp;&lt;em&gt;that&lt;/em&gt; interesting now is it? You know what I will do for a change: stop this werid&amp;nbsp;tagging game, right here, right now..! Besides, most of the people that I was going to tag have been tagged allready anyway.&lt;/p&gt; &lt;p&gt;ps. I am getting a few blog posts ready about programming media centre addins... stay tuned&lt;/p&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=91779" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>Hunting for window handles</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/11/23/Hunting-for-window-handles.aspx" /><id>/blogs/waseem/archive/2006/11/23/Hunting-for-window-handles.aspx</id><published>2006-11-23T01:08:52Z</published><updated>2006-11-23T01:08:52Z</updated><content type="html">&lt;p&gt;I am working on a fairy large WinForms project and after a certain build our application suddenly started crashing. Click, click, boem... gone.... no exception, no event log entry, nothing. The annoying part was that this didn't happened while executing&amp;nbsp;&lt;em&gt;inside&lt;/em&gt; the debugger, only when the testers were clicking around inside the application and even &lt;em&gt;then&lt;/em&gt; very undeterministically.&lt;/p&gt; &lt;p&gt;If you get problems like this the first thing to do is to attach a event handler to the Application.ThreadException event to try to figure out who is causing this error:&lt;/p&gt;&lt;pre class="csharpcode"&gt;Application.ThreadException += &lt;span class="kwrd"&gt;new&lt;/span&gt; ThreadExceptionEventHandler(Application_ThreadException);&lt;/pre&gt;
&lt;p&gt;Inside this event handler you can basically do diagnostics to find out what exception is being raised by looking at the ThreadExceptionEventArgs parameter.&lt;/p&gt;
&lt;p&gt;So in this case the exception was "&lt;em&gt;Error Creating Window Handle&lt;/em&gt;"... exactly the kind of exception that scares me. As Julia Lerman writes in a &lt;a href="http://blog.ziffdavis.com/devlife/archive/2006/02/22/40253.aspx"&gt;blog-post&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;”Error Creating Window Handle” is a&amp;nbsp;Win32 error, therefore the first thing I should have been looking at was any code that did anything with unmanaged items.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;And it just so happened to be that one of the changes that we made to the application involved some GDI+ brushes and stuff like that. The first thing I did was making sure every brush and bitmap was disposed after being used by including them in the using pattern. Unfortunatly that alone didn't help much.&lt;/p&gt;
&lt;p&gt;The specific part where we were using GDI+ drawing was inside a renderer for a given tabcontrol from a third party product that we are using in this application. Our application also needs to clear this&amp;nbsp;tabcontrol and&amp;nbsp;re-create all the tabs&amp;nbsp;again quite often (for instance when the user navigates to a new area).&lt;/p&gt;
&lt;p&gt;My huntch was that somehow every time this tabcontrol was refilled again the old tabs were still floating around somehwere in memory and not being garbage collected, it turned out that I was right... after changing the code from simply doing a:&lt;/p&gt;&lt;pre class="csharpcode"&gt;leftTabControl.TabPages.Clear();&lt;/pre&gt;
&lt;p&gt;...to removing and disposing each individual item...&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (TabPage tab &lt;span class="kwrd"&gt;in&lt;/span&gt; leftTabControl.TabPages)
{
    leftTabControl.TabPages.Remove(tab);
    tab.Dispose();
}&lt;/pre&gt;
&lt;p&gt;...the problem went away.&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=54582" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author><category term="thread" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/thread/default.aspx" /><category term="winforms" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/winforms/default.aspx" /><category term="exception" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/exception/default.aspx" /></entry><entry><title>Using generics to easy the pain of (xml) serialization</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/11/22/Using-generics-to-easy-the-pain-of-_2800_xml_2900_-serialization.aspx" /><id>/blogs/waseem/archive/2006/11/22/Using-generics-to-easy-the-pain-of-_2800_xml_2900_-serialization.aspx</id><published>2006-11-22T03:55:00Z</published><updated>2006-11-22T03:55:00Z</updated><content type="html">&lt;p&gt;Sometimes it happens (especially when writing application frameworks) that you need to write a piece of code that needs to perform something as generically as possible. Being the OO guys that we are we tend to work a lot with polymorphism to accomplish this. Unfortunatly, polymorphism and xml serialization don't nescessarilly go hand-in-hand that well.&lt;/p&gt; &lt;p&gt;Say for instance that you have a class called Response which has has a derived class called DerivedResponse1:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Response
{
}&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DerivedResponse1 : Response
{
}&lt;/pre&gt;
&lt;p&gt;Nothing fancy here. The code to serialize this DerivedResponse1 class would be something like the following:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; SerializeResponse(Response response)
{
    &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream ms = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream())
    {
        XmlSerializer ser = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Response));
        ser.Serialize(ms, response);
    }
}&lt;/pre&gt;


&lt;p&gt;Unfortunatly this doesn't work because the XML serializer complains about an error in the XML document (look at the InnerException to find out what the real error message is, which in this case is "&lt;em&gt;The type DerivedResponse1 was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.&lt;/em&gt;")&lt;/p&gt;
&lt;p&gt;To fix this you need to exactly what the error message sais and that is to add the XmlInclude attribute to the base type like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[XmlInclude(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DerivedResponse1))]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Response
{
}&lt;/pre&gt;
&lt;p&gt;Ok, now comes the part where you have&amp;nbsp;70 classes deriving from Response like I did... it would be very annoying to have to attach each and every class using the XmlInclude attribute.&amp;nbsp;This was kind of the problem that I had.&lt;/p&gt;
&lt;p&gt;What I did was create a generic 'helper' class that I used as a container for the Response object. The class looks very simple kind of like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SerializationContainer&amp;lt;T&amp;gt; where T : Response
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; MemoryStream ms = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream();
    
    &lt;span class="kwrd"&gt;public&lt;/span&gt; T Instance;
    
    &lt;span class="kwrd"&gt;public&lt;/span&gt; SerializationContainer(T instance)
    {
        Instance = instance;
    }
    
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Serialize()
    {
        ms.Seek(0, SeekOrigin.Begin);
        
        XmlSerializer ser = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(T));
        ser.Serialize(ms, Instance);
    }
    
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Deserialize()
    {
        ms.Seek(0, SeekOrigin.Begin);

        XmlSerializer ser = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(T));
        Instance = (T)ser.Deserialize(ms);
    }
}&lt;/pre&gt;
&lt;p&gt;The trick here is that this is a generic type and each time the serializer is invoked it creates a new serialization assembly specific to the generic&amp;nbsp;type (T)&amp;nbsp;using which this type is created. This way the Response base-class doesn't need to know about all its descendants in order to be able to serialize itself. There is a performance penalty though, the Xml serializer will create a so-called serialization assembly for each generic type. Fortunatly &lt;a href="http://msdn2.microsoft.com/en-us/library/bk3w6240%28VS.80%29.aspx"&gt;there are ways&lt;/a&gt; to improve the Xml serializer's performance.&lt;/p&gt;
&lt;p&gt;The real power of this approach becomes apparant when doing late instantiation of the generic parameter type (ie; not knowing the exact generic parameter type&amp;nbsp;at compile-time).&lt;/p&gt;
&lt;p&gt;I have created a small sample project to demonstrate this approach. You can download it &lt;a title="download sample code" href="http://waseem.sadiq.nl/downloads/samples/SerializeWithGenerics.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hope this helps somebody.&lt;/p&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=53827" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author><category term="xml" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/xml/default.aspx" /><category term="generics" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/generics/default.aspx" /><category term="serialization" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/serialization/default.aspx" /></entry><entry><title>Firing Atlas UpdatePanels from a Flash movie</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/10/26/Firing-Atlas-UpdatePanels-from-a-Flash-movie.aspx" /><id>/blogs/waseem/archive/2006/10/26/Firing-Atlas-UpdatePanels-from-a-Flash-movie.aspx</id><published>2006-10-26T02:02:26Z</published><updated>2006-10-26T02:02:26Z</updated><content type="html">&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:5b165f80-e6ae-4fbe-9dc0-eb5b84279939" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/Atlas" rel="tag"&gt;Atlas&lt;/a&gt;, &lt;a href="http://technorati.com/tags/ASP.NET%20Ajax" rel="tag"&gt;ASP.NET Ajax&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Flash" rel="tag"&gt;Flash&lt;/a&gt;, &lt;a href="http://technorati.com/tags/UpdatePanel" rel="tag"&gt;UpdatePanel&lt;/a&gt;&lt;/div&gt; &lt;p&gt;A friend of mine asked me about how to solve the following problem:&lt;/p&gt; &lt;p&gt;He has a Flash movie in which he can call javascript but needs to trigger an Atlas (or rather ASP.NET Ajax... sigh) UpdatePanel. In his code-behind he wants to load a different user-control based on the button that was clicked in his Flash movie.&lt;/p&gt; &lt;p&gt;I cooked him up a solution that generates a single line of javascript which he can copy/paste in his Flash movie and use to trigger the UpdatePanel.&lt;/p&gt; &lt;p&gt;The magic happens by implementing the IPostBackEventHandler interface. I created a simple control that implements this interface and exposes an event that gets called so that external observers can be notified when a postback occured:&lt;/p&gt; &lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RaisePostbackProxy : Control, IPostBackEventHandler&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;NewPostBackEventArgs&amp;gt; HandlePostback;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RaisePostBackEvent(&lt;span class="kwrd"&gt;string&lt;/span&gt; eventArgument)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&amp;nbsp;&lt;/div&gt;
&lt;p&gt;I added this control to my aspx page and wired the HandlePostback event, now I can be notified when the user clicks any link or button in the flash movie and load the appropriate usercontrol by looking at the Argument property of the NewPostBackEventArgs parameter.&lt;/p&gt;
&lt;p&gt;I have created a sample solution demonstrating this (very simple) approach. The solution can be downloaded &lt;a title="Sample solution" href="http://waseem.sadiq.nl/downloads/samples/AtlasPostbackTrigger.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hope this helps somebody.&lt;/p&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=39226" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author><category term="atlas" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/atlas/default.aspx" /><category term="flash" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/flash/default.aspx" /><category term="ajax" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/ajax/default.aspx" /><category term="updatepanel" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/updatepanel/default.aspx" /></entry><entry><title>Google code-search</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/10/05/Google-code_2D00_search.aspx" /><id>/blogs/waseem/archive/2006/10/05/Google-code_2D00_search.aspx</id><published>2006-10-04T23:02:25Z</published><updated>2006-10-04T23:02:25Z</updated><content type="html">&lt;p&gt;As developers we often need to look up&amp;nbsp;code-samples or ways to use a certain class. There have been a few offerings in this arena, for example &lt;a href="http://www.krugle.com/"&gt;krugle&lt;/a&gt;, &lt;a href="http://www.koders.com/"&gt;koders&lt;/a&gt;&amp;nbsp;and &lt;a href="http://labs.oreilly.com/code/"&gt;o'reilly code search&lt;/a&gt;&amp;nbsp;(and a few others).&amp;nbsp;Now Google has weight in with their own offering called &lt;a href="http://www.google.com/codesearch"&gt;google code search&lt;/a&gt;. Quite interesting to see Google actually doing this since they undoubtfully have one of&amp;nbsp;the biggest (if not &lt;em&gt;the &lt;/em&gt;biggest) full-text databases out there.&lt;/p&gt; &lt;p&gt;It seems that at present they are only indexing a bunch of open-source projects (from the FAQ):&lt;/p&gt; &lt;p&gt;&lt;em&gt;We're crawling as much publicly accessible source code as we can find, including archives (.tar.gz, .tar.bz2, .tar, and .zip), CVS repositories and Subversion repositories.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The number one use of Google search when wearing the developer hat, in my opinion,&amp;nbsp;seems to be searching for error messages though. I would love to see Google crunching code-related error-messages, or even better, maybe even a dedicated error message search engine? :-)&lt;/p&gt; &lt;p&gt;The product is still in a very early stage of development so keep an eye on it. This might just become my homepage at the office when this product matures.&lt;/p&gt; &lt;p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:7a728816-696a-4974-a986-9f73c7b0ce22" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/google" rel="tag"&gt;google&lt;/a&gt;, &lt;a href="http://technorati.com/tags/code" rel="tag"&gt;code&lt;/a&gt;, &lt;a href="http://technorati.com/tags/search" rel="tag"&gt;search&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=28190" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>The .NET Framework 3.0 is here folks...</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/06/10/12426.aspx" /><id>/blogs/waseem/archive/2006/06/10/12426.aspx</id><published>2006-06-09T14:26:00Z</published><updated>2006-06-09T14:26:00Z</updated><content type="html">Microsoft has always had quite a bad rep with screwing up utterly cool product names (think Avalon and Indigo just to name a few) into very dull and boring names. But this time they have really outdone themselves. Not by thinking up a &lt;span style="font-style: italic;"&gt;bad&lt;/span&gt; name, no sir... by &lt;a href="http://blogs.msdn.com/somasegar/archive/2006/06/09/624300.aspx"&gt;thinking up&lt;/a&gt; a completly &lt;span style="font-style: italic;"&gt;illogical&lt;/span&gt; name.&lt;br /&gt;
&lt;br /&gt;
The wise people at Microsoft have decided to rename all the WinFX technologies to &amp;quot;the .NET Framework &lt;span style="font-weight: bold;"&gt;3.0&lt;/span&gt;&amp;quot;... And to get back to the dull and boring naming conventions, they have decided to rename InfoCard to &amp;quot;Windows CardSpace (WCS)&amp;quot;... that even tops &amp;quot;Windows Communication Foundation&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
So the .NET Framework 3,0 actually contains technology which requires the .NET Framework 2.0 to run... like the CLR 2.0, C# 2.0, Visual Studio 2005.... etc, now isn't that werid? To install the .NET Framework 3.0 you need the ,NET Framework 2.0. &lt;br /&gt;
&lt;br /&gt;
The thing is that having the .NET Framework 3.0 isn't bad per s&amp;eacute; but renaming a product to just that out of nowhere isn't the smartest thing to do. They claim they have done this to reduce confusion amongst customers... I say it will only create &lt;span style="font-style: italic;"&gt;more&lt;/span&gt; confusion...&lt;br /&gt;
&lt;br /&gt;
It will be interesting to see if the next version of C# will skip the 3.0 version and go straight to 4.0 so that they can get their act together on the product versioning schemes. Bad move Microsoft.&lt;br /&gt;
&lt;br /&gt;
Oh well, in the end we will all just adjust and live on.&lt;br /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=12426" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>WinFX runtime beta2 installation fails</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/06/03/12361.aspx" /><id>/blogs/waseem/archive/2006/06/03/12361.aspx</id><published>2006-06-03T07:11:00Z</published><updated>2006-06-03T07:11:00Z</updated><content type="html">I am upgrading my WinFX installation (including the VS tools, the SDK, etc... quite a painful process) to the latest version, which at this time is the beta2 version. But the runtime fails to install and crashes!&lt;br /&gt;
&lt;br /&gt;
When looking at the error message that the installer wants to send to Microsoft you see something about a file not being signed correctly (this message can also be found in the logfile the installer wants to attach). Seems that the WinFX installer wants to install the localized dutch files for the WinFX runtime... but Microsoft is saying they will only support German and Chinese until RTM. Weird stuff.&lt;br /&gt;
&lt;br /&gt;
Anyway, if you run into a failing install, try downloading the full WinFX redistributable (I didn't even knew this one existed). It can be found on the same download page as the regular &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4a96661c-05fd-430c-bb52-2ba86f02f595&amp;amp;DisplayLang=en#Requirements"&gt;internet install&lt;/a&gt;, under the heading &amp;quot;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4a96661c-05fd-430c-bb52-2ba86f02f595&amp;amp;DisplayLang=en#Instructions"&gt;Instructions&lt;/a&gt;&amp;quot; and is called &amp;quot;winfxrc.exe&amp;quot;.&lt;br /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=12361" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>Running XQuery in a OR-Mapper world</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/05/21/12220.aspx" /><id>/blogs/waseem/archive/2006/05/21/12220.aspx</id><published>2006-05-21T07:12:00Z</published><updated>2006-05-21T07:12:00Z</updated><content type="html">I have a SQL2005 database based on more or less a relational model, except for one column which is of type Xml. The problem with most ORMappers is that they are unaware of the SQL2005 specific (or even Oracle-specific for that matter) features for querying and updating Xml-typed data. ORMappers look at every columns as being a property/field of your domain-object. Good enough, that's what they are for.&lt;br /&gt;
&lt;br /&gt;
But if you need to retreive a domain-object where some property should be matched against an XQuery predicate... you kind of have a problem. Here is one solution I found for this problem:&lt;br /&gt;
&lt;br /&gt;
I am using Paul Wilson's excellent &lt;a href="http://www.ormapper.net/"&gt;ORMapper&lt;/a&gt; with out-of-the-box support for .NET 2.0 features (I can't live without generics). This ORMapper has a specific feature called &amp;quot;Interceptors&amp;quot; (I know that NHibernate also has a feature which basicly does the same). By implementing the IInterceptCommand I can create a plugin that gets called before the command gets sent to the database.&lt;br /&gt;
&lt;br /&gt;
Here is my code to rewrite the Sql statement in the form &amp;quot;where PropertyBag = @Something&amp;quot; to &amp;quot;PropertyBag.value(... @Something)&amp;quot;. Keep in mind that this is more or less a sample and won't work for every scenario (especially if you have queries in the form of &amp;quot;FirstName = @Something and PropertyBag = @SomethingElse&amp;quot;). But untill our ORMappers start to get aware of Xml typed data inside the database, this is one way to tackle this problem.&lt;br /&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas; color: blue;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;EntityLoginNameInterceptor&lt;/span&gt; : &lt;span style="color: teal;"&gt;IInterceptCommand&lt;/span&gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; InterceptCommand(&lt;span style="color: teal;"&gt;Guid&lt;/span&gt; transactionId, &lt;span style="color: teal;"&gt;Type&lt;/span&gt; entityType, &lt;span style="color: teal;"&gt;CommandInfo&lt;/span&gt; commandInfo, System.Data.&lt;span style="color: teal;"&gt;IDbCommand&lt;/span&gt; dbCommand)&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style=""&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;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (entityType == &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: teal;"&gt;Entity&lt;/span&gt;))&lt;br /&gt;
&lt;span style=""&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;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: Consolas; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;#region&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt; Validate request parameters&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] queryParts = dbCommand.CommandText.Split(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;[] { &lt;span style="color: maroon;"&gt;&amp;quot;WHERE&amp;quot;&lt;/span&gt; }, &lt;span style="color: teal;"&gt;StringSplitOptions&lt;/span&gt;.None);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (queryParts.Length == 0)&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (queryParts[1].IndexOf(&lt;span style="color: maroon;"&gt;&amp;quot;PropertyBag&amp;quot;&lt;/span&gt;) == -1)&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Consolas; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;#endregion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas; color: blue;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: green;"&gt;// Contains the whereClause of the CommandText&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt; whereClause = queryParts[1];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: green;"&gt;// ToDo: this code will stop working if the where clause has any other&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: green;"&gt;// predicate then just 'PropertyBag = ', could fix this by using regexes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] parts = whereClause.Split(&lt;span style="color: maroon;"&gt;'='&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Consolas; color: blue;"&gt;if&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt; (&lt;span style="color: teal;"&gt;String&lt;/span&gt;.IsNullOrEmpty(parts[1]))&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;throw&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color: maroon;"&gt;&amp;quot;PropertyBag predicate does not have a value!&amp;quot;&lt;/span&gt;);&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: green;"&gt;// Contains the XQuery to query against the PropertyBag XML column&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt; xQuery =&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: teal;"&gt;String&lt;/span&gt;.Format(&lt;span style="color: maroon;"&gt;&amp;quot;PropertyBag.value('(/properties/property[@name=\&amp;quot;NTLoginName\&amp;quot;])[1]', 'nvarchar(30)') = {0}&amp;quot;&lt;/span&gt;, parts[1]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: green;"&gt;// Save new sql statement to the CommandText property of the IDbCommand,&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;span style="color: green;"&gt;// Watch the extra '(', this is required for the query to parse&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;dbCommand.CommandText = &lt;span style="color: teal;"&gt;String&lt;/span&gt;.Format(&lt;span style="color: maroon;"&gt;&amp;quot;{0} where ({1}&amp;quot;&lt;/span&gt;, queryParts[0], xQuery);&lt;br /&gt;
&lt;span style=""&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;/span&gt;}&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br /&gt;
}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;If anybody knows a better way (or a good OR-Mapper that understands this problem), do let me know :-)&lt;span style="font-size: 10pt; font-family: Consolas;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=12220" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>WCF services and type names</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/04/12/11962.aspx" /><id>/blogs/waseem/archive/2006/04/12/11962.aspx</id><published>2006-04-12T05:44:00Z</published><updated>2006-04-12T05:44:00Z</updated><content type="html">If you get the following error message while trying to run a WCF service:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Service '&lt;span style="font-style: italic;"&gt;SomeServiceType&lt;/span&gt;' has zero application (non-infrastructure) endpoints.&amp;nbsp; This might be because no configuration file was found for your application, or because there was a problem with the type in the configuration file, or no endpoints were defined in the configuration file.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You might want to try to change your name attribute of your service (this attribute used to be called the type attribute in the pre-feb ctp's) from the assembly-included name to only the class-name. You need to do the same thing with a contract.&lt;br /&gt;
&lt;br /&gt;
If you had a service called Services.Foo in an assembly called Services.dll and a contract called Services.Contracts.IFoo in an assembly called Services.Contracts.dll you will get the following service configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;service name=&amp;quot;Services.Foo&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; address=&amp;quot;http://localhost:8000/FooService&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; binding=&amp;quot;wsHttpBinding&amp;quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; contract=&amp;quot;Services.Contracts.IFoo&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/service&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, the assembly names aren't mentioned. IMHO this is the right thing to do but is not quite evident becase a lot of the documentation if still pre feb-ctp. I found the solution for this problem &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=302953&amp;amp;SiteID=1"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Another one of those things that kept me going for a while :-)&lt;br /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=11962" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>Flags enumeration sample</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/04/04/11899.aspx" /><id>/blogs/waseem/archive/2006/04/04/11899.aspx</id><published>2006-04-04T06:42:00Z</published><updated>2006-04-04T06:42:00Z</updated><content type="html">I had to wrestle a bit to get an enumeration with the FlagsAttribute working correctly today so I though I'd just share my working code as a sample for some Google juice. If you want to download the code, you can do so &lt;a href="http://waseem.sadiq.nl/downloads/samples/FlagsTestApplications.cs"&gt;here&lt;/a&gt;. Hope this helps.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: teal;"&gt;Flags&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;enum&lt;/span&gt; &lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NotifyOpeningTags = 1,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NotifyClosingTags = 2,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NotifyText = 4,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NotifyEmptyText = 8,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NotifyComments = 16,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; All = NotifyOpeningTags | NotifyClosingTags | NotifyText | NotifyEmptyText | NotifyComments&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;Program&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt; options = &lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.NotifyText;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Program&lt;/span&gt; p = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;Program&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; p.Run();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: maroon;"&gt;&amp;quot;Press ENTER to exit&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.ReadLine();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Run()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.NotifyOpeningTags));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.NotifyClosingTags));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.NotifyText));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.NotifyEmptyText));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.NotifyComments));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt;.All));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; IsOptionSet(&lt;span style="color: teal;"&gt;HtmlParserOptions&lt;/span&gt; singleOption)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; (options &amp;amp; singleOption) == singleOption;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;45&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=11899" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>Creating a simple auto-completion control with WPF</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/03/30/11866.aspx" /><id>/blogs/waseem/archive/2006/03/30/11866.aspx</id><published>2006-03-30T03:13:00Z</published><updated>2006-03-30T03:13:00Z</updated><content type="html">&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;The (WPF) project I am currently working on at &lt;a target="_blank" href="http://www.macaw.nl"&gt;Macaw&lt;/a&gt; requires a textbox with auto-completion support. Perhaps I am a bit blind but I simply don't seem to be able to find this feature on the TextBox control that is provided with the WPF framework, this reminds me of a bit of &lt;/span&gt;&lt;a target="_blank" href="http://www.charlespetzold.com/blog/2006/03/030335.html"&gt;&lt;span style=""&gt;criticism&lt;/span&gt;&lt;/a&gt;&lt;span style=""&gt; that has been popping up here and there lately.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;The thing is that somehow I have the feeling that such a feature might actually be inside the WPF framework but it isn&amp;rsquo;t really clear where one could find it, especially when you are used to wearing the WinForms hat and are expecting to see a specific feature at a specific location.&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;Although the default auto completion behaviour wouldn&amp;rsquo;t have suited my needs anyway, if anybody knows how to pull off a standard auto completion TextBox in WPF, &lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;please do let me know. &lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;The reason why the default auto-completion behaviour isn&amp;rsquo;t what I&amp;rsquo;m looking for is because I am building a textbox in which users can add tags separated by a comma and I need auto completion &lt;i&gt;per tag&lt;/i&gt;. If you are familiar with the textbox that delicious uses for its tagging you will probably be able to envision what I am trying to create. For those that haven&amp;rsquo;t seen this feature, here is a screenshot of the auto completion textbox in action.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;img width="274" height="156" src="/UserFiles/Waseem Sadiq/Image/AutoCompletionTextBoxScreen.jpg" alt="Screenshot" /&gt;&lt;br /&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;The first step we take is to create a simple project with a user control and a window to test our user control. Here is the xaml code for custom control. You can find the link to the download at the bottom of this article.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;"&gt;UserControl&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;x:Class&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;WPFAutoComplete.AutoCompletionTextBox&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;xmlns:x&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;"&gt;Canvas&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;"&gt;TextBox&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;TagsTextBox&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;Canvas.Left&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;0&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;Canvas.Top&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;0&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;Width&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;100&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;LostFocus&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;TagsTextBox_LostFocus&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;KeyUp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;TagsTextBox_KeyUp&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;"&gt;ListBox&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;br /&gt;
&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;TagsAutoCompletionListBox&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;Visibility&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;Hidden&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;span style=""&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; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;FontSize&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;quot;&lt;span style="color: blue;"&gt;14&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SelectionChanged&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;TagsAutoCompletionListBox_SelectionChanged&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;"&gt;Canvas&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;"&gt;UserControl&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;As you can see we are using a TextBox control and a ListBox control which is hidden by default. You can probably imagine what we need both of these for :-) The second thing to note is that we have a few events hooked up, we need to have these in our code-behind file as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;First of all we need three helper methods to help us to decide:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;What is the tag we want to get      the auto-completion for. We do this by splitting the Text property of the      TagsTextBox control with a comma;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;When the user selects a tag      from the TagsAutoCompletionListBox list we want this to reflect in the      TagsTextBox&amp;rsquo;s Text property;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;A helper method to move to the      end of the text that has been entered in the TagsTextBox and subsequently      set focus to the TagsTextBox so that the user might continue entering more      tags.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;The final helper-thingie we      want is a feature that can restore the user&amp;rsquo;s entered text when the user      isn&amp;rsquo;t satisfied with the suggestions provided by the auto completion      features by hitting the &amp;ldquo;escape&amp;rdquo; button.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;These features are implemented in the methods that you see in the first half of the code-behind file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;Ok now that we have that out of the way let&amp;rsquo;s describe how we want our textbox to behave:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;When the use is typing a tag      longer then 1 character we want the auto completion features to kick in;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;When the user presses the down      arrow we want to select the next suggestion from the auto completion list      and replace the tag the user was typing with the one from the list;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;When the user presses the up      arrow we want to do the opposite of the above mentioned feature;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;When the user presses the &amp;ldquo;enter&amp;rdquo;      key we want to select the active item and close the list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;&lt;span style=""&gt;When the user presses the &amp;ldquo;escape&amp;rdquo;      key we want to restore anything that we might have replaced to the      previous version (sort of a undo feasture).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;The real magic happens in the following piece of code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;// Get auto-completion list for text user is typing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: teal;"&gt;AutoCompletionProvider&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; provider = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;AutoCompletionProvider&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: teal;"&gt;List&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&amp;gt; suggestedTags = provider.GetTagsForAutoCompletion(currentTag);&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;if&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; (suggestedTags.Count &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;TagsAutoCompletionListBox.ItemsSource = suggestedTags;&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;TagsAutoCompletionListBox.Visibility = &lt;span style="color: teal;"&gt;Visibility&lt;/span&gt;.Visible;&lt;o:p&gt; &lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green;"&gt;// Get x-coordinate of TagTextBox.Text minus suggestedTags&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;int&lt;/span&gt; count = TagsTextBox.Text.Length - GetCurrentTag().Length;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;double&lt;/span&gt; x = TagsTextBox.GetRectFromCharacterIndex(count).X;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: teal;"&gt;Canvas&lt;/span&gt;.SetTop(TagsAutoCompletionListBox, TagsTextBox.ActualHeight);&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: teal;"&gt;Canvas&lt;/span&gt;.SetLeft(TagsAutoCompletionListBox, x);&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green;"&gt;// Save state before opening list so we can restore this when use hits escape.&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;previousText = TagsTextBox.Text;&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;{&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green;"&gt;// No items to suggest, hide suggestion list&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;TagsAutoCompletionListBox.Visibility = &lt;span style="color: teal;"&gt;Visibility&lt;/span&gt;.Hidden;&lt;br /&gt;
}&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;I have created a bogus provider for returning a couple of tags to play around a bit, this should be your call to a webservice, a database or anything else you want to use as a source.&lt;o:p&gt; &lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;There is a bit of interesting code that gets the location at the x-coordinate where we want the auto completion ListBox to appear:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;// Get x-coordinate of TagTextBox.Text minus suggestedTags&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;int&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; count = TagsTextBox.Text.Length - GetCurrentTag().Length;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;double&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; x = TagsTextBox.GetRectFromCharacterIndex(count).X;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;The rest is kind of straight-forward. You can download the code and check it our yourself. It isn&amp;rsquo;t really hard to do and might need some polish here and there (look for any ToDo&amp;rsquo;s) but it can serve as a nice starting point for rolling your own auto completion features in WPF.&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;Hope anybody finds it useful in some way. The source-code can be downloaded &lt;a href="http://waseem.sadiq.nl/downloads/samples/WPFAutoComplete.zip"&gt;here&lt;/a&gt; and is meant to be compiled on the March CTP, it should work just fine on any subsequent version though.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;br /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=11866" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry><entry><title>WPF - local animations (animations in code)</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/02/28/11183.aspx" /><id>/blogs/waseem/archive/2006/02/28/11183.aspx</id><published>2006-02-28T06:57:00Z</published><updated>2006-02-28T06:57:00Z</updated><content type="html">&lt;p&gt;When trying to animate a WPF object in code (this is called a local animation) you sometimes need to be careful about which property you need to feed to which class. At the current (Februari) CTP timeframe the documentation isn't really clear on this but I am sure this will be fixed by the time WPF goes gold.&lt;/p&gt;
&lt;p&gt;In my situation I had a rectangle inside a canvas whose location I wanted to animate. The caveat is that the location isn't a property of a rectangle itself but instead an attached property on the canvas containing the rectangle.&lt;/p&gt;
&lt;p&gt;The proper way to do a local animation is to create a storyboard object and animate the properties by using the &lt;em&gt;TypeAnimation&lt;/em&gt; objects like this:&lt;/p&gt;
&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;Storyboard&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#000000" size="2"&gt; sb = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;Storyboard&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;();&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;
Duration&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt; duration = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;Duration&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#008080" size="2"&gt;TimeSpan&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;.FromSeconds(0.2));&lt;/font&gt;&lt;br /&gt;
&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;br /&gt;
&lt;font face="Courier New"&gt;DoubleAnimation&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt; da1 = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;DoubleAnimation&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;(x, duration);&lt;br /&gt;
&lt;/font&gt;&lt;font color="#008080" size="2"&gt;DoubleAnimation&lt;/font&gt;&lt;font size="2"&gt; da2 = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;DoubleAnimation&lt;/font&gt;&lt;font size="2"&gt;(y, duration);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt;
&lt;p&gt;&lt;font size="2"&gt;The next step is to specifiy the target of your animation. This needs to be our rectangle, since that's the object that will be the target of our animation (even if the actual properties being animated are attached by the canvas!):&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;font color="#008080" size="2"&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;Storyboard&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;.SetTargetName(da1, rectangle.Name);&lt;br /&gt;
&lt;/font&gt;&lt;font color="#008080" size="2"&gt;Storyboard&lt;/font&gt;&lt;font size="2"&gt;.SetTargetName(da2, rectangle.Name);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;Do make sure that when creating the rectangle it has a valid name, this is required to do local animations.&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;The next step is where it gets tricky (well not really tricky, but it did require some experimenting). I said before that the left and top property are not really on the rectangle but rather attached through the canvas, so we need to tell the storyboard about this:&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;font color="#008080" size="2"&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;Storyboard&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;.SetTargetProperty(da1, &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PropertyPath&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font size="2"&gt;Canvas&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;.LeftProperty));&lt;br /&gt;
&lt;/font&gt;&lt;font color="#008080" size="2"&gt;Storyboard&lt;/font&gt;&lt;font size="2"&gt;.SetTargetProperty(da2, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;PropertyPath&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#008080" size="2"&gt;Canvas&lt;/font&gt;&lt;font size="2"&gt;.TopProperty));&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font size="2"&gt;The very last thing to do is to add the two doubleanimation objects to the storyboard and signal it to start.&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;sb.Children.Add(da1);&lt;br /&gt;
sb.Children.Add(da2);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;sb.Begin(canvas);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;I hope this made since.&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=11183" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author><category term="WPF" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/WPF/default.aspx" /></entry><entry><title>WPF - custom types and polymorphism</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2006/02/28/11182.aspx" /><id>/blogs/waseem/archive/2006/02/28/11182.aspx</id><published>2006-02-28T06:32:00Z</published><updated>2006-02-28T06:32:00Z</updated><content type="html">&lt;p&gt;I was working on a WPF application and needed to do a complex rectangle-like UI element. Hey custom styles is what WPF is good at right? To be quite exact I needed a custom control template, since I couldn't style a rectangle the way I wanted to. &lt;br /&gt;
&lt;br /&gt;
I decided to use a System.Windows.Control (which isn't sealed, a rectangle is) and inherit from this in order to add some custom behavior. I created a custom template by creating a control template element inside my Window.Resources section like this:&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000" size="2"&gt;ControlTemplate&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;x:Key&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font color="#000000" size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;ControlTemplate&lt;/font&gt;&lt;font color="#000000" size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;TargetType&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font color="#000000" size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;{x:Type &lt;strong&gt;Control&lt;/strong&gt;}&lt;/font&gt;&lt;font color="#000000" size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;...&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#800000" size="2"&gt;ControlTemplate&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;This works just fine as long as long as your custom class &lt;em&gt;acts like&lt;/em&gt; a control. The moment you try to bind to a custom dependancy property like this (in which Title is our custom dependancy property):&lt;/p&gt;
&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;&amp;lt;&lt;font color="#800000" size="2"&gt;TextBlock&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;Text&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;{TemplateBinding Property=Title}&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; /&amp;gt;&lt;/font&gt;&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;You get the error message &lt;strong&gt;&amp;quot;Cannot convert the string 'Title' into an object of type 'System.Windows.DependencyProperty'. The result is 'null', which is not an allowable value..&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This actually is completely logical since you &lt;em&gt;told&lt;/em&gt; the control template that you would be feeding it a System.Windows.Control but instead you are feeding it your own custom type which inherits from System.Windows.Control.&lt;/p&gt;
&lt;p&gt;The right way to do this is to reference your type using the clr-namspace mapping syntax and changing your control template decleration like the following:&lt;/p&gt;
&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;&amp;lt;&lt;font color="#800000" size="2"&gt;ControlTemplate&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;x:Key&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;ControlTemplate&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;TargetType&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;{x:Type &lt;strong&gt;YourCustomControl&lt;/strong&gt;}&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;gt;&lt;/font&gt;&lt;font size="2"&gt;...&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#800000" size="2"&gt;ControlTemplate&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;gt;&lt;/font&gt;&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000" size="2"&gt;Although this sounds logical it did keep me busy a while. Perhaps the WPF folks want to do some less-cryptic error message on this one.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Hope this helps out somebody.&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=11182" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author><category term="WPF" scheme="http://bloggingabout.net/blogs/waseem/archive/tags/WPF/default.aspx" /></entry><entry><title>The Atlas December CTP is coming</title><link rel="alternate" type="text/html" href="/blogs/waseem/archive/2005/12/22/10656.aspx" /><id>/blogs/waseem/archive/2005/12/22/10656.aspx</id><published>2005-12-21T23:06:00Z</published><updated>2005-12-21T23:06:00Z</updated><content type="html">According to &lt;a href="http://www.nikhilk.net/Entry.aspx?id=100"&gt;Nikhil&lt;/a&gt; we should be able to download the Atlas december CTP from the &lt;a href="http://atlas.asp.net/"&gt;Atlas community website&lt;/a&gt; in a &lt;span style="font-style: italic;"&gt;few hours&lt;/span&gt;. Although I read the words a 'few hours' last night... I suppose, since as we all &lt;span style="font-style: italic;"&gt;are&lt;/span&gt; developers, we can quite understand the concept of 'releasing in a few hours' :-)&lt;br /&gt;
&lt;br /&gt;
I have been waiting a while for this one. The current build from october is very difficult to work with, the documentation is also very rigid and hard to follow. I am very pleased to learn that they have killed some of the unusable pesky Atlas controls that were in the previous build, quoting Nikhil:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&amp;quot;You may wonder what about all those atlas server controls we had in our PDC release. Wasn't that our integration with ASP.NET pages? Well, in short, they're gone. These controls were really of out of place. They essentially enabled you to generate XML script using server controls. So in order to use them, you first had to learn XML script, and then you had to map those constructs into server control tags. And despite being server controls, you weren't able to use familiar server-side code and programming models to work against them. For this release, we put in a new set of server controls that have been developed with a different perspective.&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;br /&gt;
After reading Nikhil's post I am quite delighted to see that they are doing their best to give us the programming model we are allready familiar with, which is ASP.NET serverside code. Just have a look at the new incremental updates and partial refreshes, very powerful. Interesting sidenote though... this is exactly the approach the guys from &lt;a href="http://www.magicajax.net/"&gt;MagicAjax&lt;/a&gt; have been working on for a while now.&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=10656" width="1" height="1"&gt;</content><author><name>Waseem Sadiq</name><uri>http://bloggingabout.net/members/Waseem-Sadiq/default.aspx</uri></author></entry></feed>