<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://live.mscommunity.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Weblog :: Boris Ševo</title><link>http://live.mscommunity.net/blogs/borissevo/default.aspx</link><description>Sporadic posts about my interests, e.g. software development (mostly .NET), technology in general and some occasional rant.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>Checking ISO7064 MOD 11,10 or OIB validity</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/12/03/chacking-iso7064-mod-11-10-or-oib-validity.aspx</link><pubDate>Thu, 03 Dec 2009 14:00:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:45181</guid><dc:creator>boris.sevo</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=45181</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/12/03/chacking-iso7064-mod-11-10-or-oib-validity.aspx#comments</comments><description>&lt;p&gt;As you can see &lt;a href="http://www.eurocode.org/guides/checkdig/english/purpose.html"&gt;here&lt;/a&gt; a check digit according to check digit procedure ISO7064 MOD 11,10 has to be attached to blood bag numbers prior to delivery as haemotherapeutic drug. In Croatia the same check digit is used as a personal identification number (also known as &lt;a href="http://www.oib.hr/oib10stvari.aspx"&gt;OIB&lt;/a&gt;). Some hybrid systems based on the same standard are also used in banks and probably on many other places for various purposes.&lt;/p&gt;

&lt;p&gt;There is nothing special in this algorithm, but today I found a &lt;a href="http://www.dizzy.hr/oib/"&gt;blog post by Domagoj Pavlešić&lt;/a&gt; where he has provided OIB check validity algorithm written is several programming languages (he even wrote a &lt;a href="http://www.dizzy.hr/oib/oib.asmx"&gt;web service&lt;/a&gt; which can be used for free). Although there is nothing wrong with his algorithms, I decided to write my own version of the algorithm because I didn&amp;#39;t like his C# version (it&amp;#39;s is too long) and because F# version was missing (I love F#) :)&lt;/p&gt;

&lt;p&gt;First the C# version which is shorter because &lt;a href="http://msdn.microsoft.com/en-us/library/bb549218.aspx"&gt;Enumerable.Aggregate&lt;/a&gt; method is used instead of for loop: &lt;/p&gt;

&lt;pre&gt;private static bool CheckOib(string oib)&lt;br /&gt;{&lt;br /&gt;    if (oib.Length != 11) return false;&lt;br /&gt;            &lt;br /&gt;    long oibL;&lt;br /&gt;    int[] digits;&lt;br /&gt;    if (long.TryParse(oib, out oibL)) &lt;br /&gt;        digits = Array.ConvertAll(oib.ToCharArray(), c =&amp;gt; Int32.Parse(c.ToString()));&lt;br /&gt;    else return false;&lt;br /&gt;&lt;br /&gt;    return digits[10] == &lt;br /&gt;        11 - digits.Take(10)&lt;br /&gt;                   .Aggregate(10, (x1, x2) =&amp;gt; ((x1 + x2) % 10 == 0 ? 10 : (x1 + x2) % 10) * 2 % 11);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;And then the F# version:&lt;/p&gt;

&lt;pre&gt;&lt;span class="cskeyword"&gt;open&lt;/span&gt; System&lt;br /&gt;&lt;br /&gt;&lt;span class="cskeyword"&gt;let&lt;/span&gt; modulo10 x1 x2 = &lt;span class="cskeyword"&gt;if&lt;/span&gt; (x1 + x2) % 10 = 0 &lt;span class="cskeyword"&gt;then&lt;/span&gt; 10 &lt;span class="cskeyword"&gt;else&lt;/span&gt; (x1 + x2) % 10&lt;br /&gt;&lt;span class="cskeyword"&gt;let&lt;/span&gt; digits s = s |&amp;gt; Seq.map(string &amp;gt;&amp;gt; int) |&amp;gt; Seq.to_list |&amp;gt; List.rev&lt;br /&gt;&lt;span class="cskeyword"&gt;let&lt;/span&gt; CheckOib (x:String) =&lt;br /&gt;  &lt;span class="cskeyword"&gt;if&lt;/span&gt; x.Length &amp;lt;&amp;gt; 11 &lt;span class="cskeyword"&gt;then&lt;/span&gt; &lt;span class="cskeyword"&gt;false&lt;/span&gt;&lt;br /&gt;  &lt;span class="cskeyword"&gt;else&lt;/span&gt;  &lt;br /&gt;    &lt;span class="cskeyword"&gt;let&lt;/span&gt; succ, value = Int64.TryParse(x)&lt;br /&gt;    &lt;span class="cskeyword"&gt;if&lt;/span&gt; succ &lt;span class="cskeyword"&gt;then&lt;/span&gt;&lt;br /&gt;      &lt;span class="cskeyword"&gt;let&lt;/span&gt; l = digits x&lt;br /&gt;      l.Head = 11 - (l.Tail |&amp;gt; List.fold(&lt;span class="cskeyword"&gt;fun&lt;/span&gt; x1 x2 &lt;span class="cskeyword"&gt;-&amp;gt;&lt;/span&gt; (modulo10 x1 x2) * 2 % 11) 10)&lt;br /&gt;    &lt;span class="cskeyword"&gt;else&lt;/span&gt;&lt;br /&gt;      &lt;span class="cskeyword"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Console.WriteLine(CheckOib &amp;quot;your_oib&amp;quot;)&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=45181" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/Functional+programming/default.aspx">Functional programming</category><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/F_2300_/default.aspx">F#</category></item><item><title>Asynchronous programming in F# - Simple FriendFeed client</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/06/13/asynchronous-programming-in-f-simple-friendfeed-client.aspx</link><pubDate>Sat, 13 Jun 2009 19:21:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:36983</guid><dc:creator>boris.sevo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=36983</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/06/13/asynchronous-programming-in-f-simple-friendfeed-client.aspx#comments</comments><description>&lt;p&gt;The
asynchronous programming in .NET is supported through a use of BeginXXX and EndXXX methods. Operations are started by calling the BeginXXX which begins
the operation and then returns. The programmer must also call the EndXXX method to be notified that the asynchronous operation has ended. Nevertheless, most programmers prefer to use synchronous over asynchronous programming. In my opinion there are two reasons for that. First is that there are many .NET classes which only have support for synchronous programming and the second is that synchronous programming is generally speaking simpler then asynchronous programming. The catch is in a fact that simpler isn&amp;#39;t always the better, because in many case the asynchronous
programming model can produce more responsive and more scalable applications.&lt;/p&gt;

&lt;p&gt;There is an interesting MSDN article by Jeffery Richter about &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163467.aspx"&gt;implementing the CLR asynchronous programming model&lt;/a&gt;, but if you take a look at the code you will see that it&amp;#39;s pretty complicated and hardly understandable on the first look. Luckily Microsoft has provided us with F# programming language which has some cool and powerful features. One of them are &lt;b&gt;asynchronous expressions&lt;/b&gt;. To demonstrate how they are used, I wrote a simple &lt;a href="http://friendfeed.com/"&gt;FriendFeed&lt;/a&gt; client for fetching and displaying user&amp;#39;s home feed.&lt;/p&gt;

&lt;pre&gt;[&amp;lt;AutoOpen&amp;gt;]&lt;br /&gt;&lt;span class="cskeyword"&gt;module&lt;/span&gt; WebRequestExtensions =&lt;br /&gt;  &lt;span class="cskeyword"&gt;type&lt;/span&gt; System.Net.WebRequest &lt;span class="cskeyword"&gt;with&lt;/span&gt;&lt;br /&gt;    &lt;span class="cskeyword"&gt;member&lt;/span&gt; x.AsyncGetRetResponse() = Async.BuildPrimitive(x.BeginGetResponse, 
                                                          x.EndGetResponse)&lt;br /&gt;&lt;br /&gt;&lt;span class="cskeyword"&gt;let&lt;/span&gt; (!!) : string &lt;span class="cskeyword"&gt;-&amp;gt;&lt;/span&gt; XName = XName.op_Implicit&lt;br /&gt;&lt;br /&gt;type FriendFeedStatus = { Title : string; User : string; Service : string }&lt;br /&gt;    &lt;br /&gt;&lt;span class="cskeyword"&gt;let&lt;/span&gt; printTimeline nickName password (url:string) =&lt;br /&gt;  async { &lt;span class="cskeyword"&gt;let&lt;/span&gt; request = WebRequest.Create url :?&amp;gt; HttpWebRequest&lt;br /&gt;          &lt;span class="cskeyword"&gt;do&lt;/span&gt; request.Credentials &amp;lt;- &lt;span class="cskeyword"&gt;new&lt;/span&gt; NetworkCredential(nickName, password)&lt;br /&gt;          &lt;span class="cskeyword"&gt;use!&lt;/span&gt; reqResponse = request.AsyncGetRetResponse()&lt;br /&gt;          &lt;span class="cskeyword"&gt;use&lt;/span&gt; streamReader = &lt;span class="cskeyword"&gt;new&lt;/span&gt; StreamReader(reqResponse.GetResponseStream())&lt;br /&gt;          &lt;span class="cskeyword"&gt;let!&lt;/span&gt; xml = streamReader.AsyncReadToEnd()&lt;br /&gt;          &lt;span class="cskeyword"&gt;let&lt;/span&gt; xmlDocument = XDocument.Parse xml&lt;br /&gt;          &lt;span class="cskeyword"&gt;let&lt;/span&gt; entries = xmlDocument.Root.Elements(!! &lt;span class="csstring"&gt;&amp;quot;entry&amp;quot;&lt;/span&gt;)&lt;br /&gt;          &lt;br /&gt;          &lt;span class="cskeyword"&gt;for&lt;/span&gt; entry &lt;span class="cskeyword"&gt;in&lt;/span&gt; entries &lt;span class="cskeyword"&gt;do&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span class="csstring"&gt;&amp;quot;{0} via {1}: {2}&amp;quot;&lt;/span&gt;, &lt;br /&gt;                              entry.Element(!! &lt;span class="csstring"&gt;&amp;quot;user&amp;quot;&lt;/span&gt;).Element(!! &lt;span class="csstring"&gt;&amp;quot;nickname&amp;quot;&lt;/span&gt;).Value,&lt;br /&gt;                              entry.Element(!! &lt;span class="csstring"&gt;&amp;quot;service&amp;quot;&lt;/span&gt;).Element(!! &lt;span class="csstring"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;).Value,&lt;br /&gt;                              entry.Element(!! &lt;span class="csstring"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;).Value)}&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;br /&gt;We can see that the code is concise and quickly understandable if we are familiar with the basic F# concepts. We can call the defined function with the following code snippet:&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;Async.Start (printTimeline &amp;quot;your_nickname&amp;quot; &lt;br /&gt;                           &amp;quot;your_remotekey&amp;quot; &lt;br /&gt;                           &amp;quot;http://friendfeed.com/api/feed/home?format=xml&amp;quot;)&lt;/pre&gt;
&lt;p&gt;which will &lt;b&gt;start the asynchronous computation in the thread pool and will not wait its result&lt;/b&gt;. Beside the asynchronous expressions it&amp;#39;s used one more interesting feature. That&amp;#39;s the LINQ to XML and &lt;a href="http://codebetter.com/blogs/matthew.podwysocki/"&gt;Matthew Podwysocki&amp;#39;s&lt;/a&gt; &lt;b&gt;&amp;quot;!!&amp;quot; operator&lt;/b&gt; which he calls &amp;quot;&lt;b&gt;Convert Dammit&lt;/b&gt;&amp;quot; operator. This operator is used to implicitly convert a string to a XName (note that there is no need to write this operator in C#).&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=36983" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/F_2300_/default.aspx">F#</category></item><item><title>Differences between WPF and Silverlight</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/06/10/differences-between-wpf-and-silverlight.aspx</link><pubDate>Wed, 10 Jun 2009 20:24:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:36913</guid><dc:creator>boris.sevo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=36913</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/06/10/differences-between-wpf-and-silverlight.aspx#comments</comments><description>
&lt;p&gt;Wintellect published 69 page whitepaper about &lt;a href="http://wpfslguidance.codeplex.com/"&gt;programmatic differences between Silverlight and WPF&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;I scanned it quickly and I didn&amp;#39;t quite read it in details, but it definitely looks like a material worth studying if you are developing WPF and/or Silverlight applications. As a special bonus, at the whitepaper&amp;#39;s end, there is a topic about code reuse strategies which looks really interesting knowing that Silverlight is generally considered to be a subset of WPF and that Microsoft is committed to bringing Silverlight and WPF closer together
with the each release.&lt;/p&gt;&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=36913" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Page Speed - Firefox/Firebig add-on for evaluating web pages performance</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/06/05/page-speed-firefox-firebig-add-on-for-evaluating-web-pages-performance.aspx</link><pubDate>Fri, 05 Jun 2009 08:28:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:36772</guid><dc:creator>boris.sevo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=36772</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/06/05/page-speed-firefox-firebig-add-on-for-evaluating-web-pages-performance.aspx#comments</comments><description>
&lt;p&gt;Google has realesed new Firefox/Firebug add-on called &lt;a href="http://code.google.com/intl/hr-HR/speed/page-speed/"&gt;Page Speed&lt;/a&gt; for evaluating web pages performance and to get suggestions on how to improve them. Several tests, based on a &lt;a href="http://code.google.com/intl/hr-HR/speed/page-speed/docs/rules_intro.html"&gt;web performance best practices&lt;/a&gt;, are performed on a front-end code and on a server&amp;#39;s configuration&lt;a href="http://code.google.com/intl/hr-HR/speed/page-speed/docs/rules_intro.html"&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://blogs.mscommunity.net/blogs/borissevo/blog-images/page-speed.jpg" alt="page-speed-screenshot" width="456" height="355" /&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s an interesting add-on which combined with YSlow can really help developers in developing optimized, fast loading web pages.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=36772" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/Firefox/default.aspx">Firefox</category></item><item><title>NHibernate.LazyInitializationException - failed to lazily initialize a collection, no session or session was closed</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/03/31/nhibernate-lazyinitializationexception-failed-to-lazily-initialize-a-collection-no-session-or-session-was-closed.aspx</link><pubDate>Tue, 31 Mar 2009 13:05:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:33638</guid><dc:creator>boris.sevo</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=33638</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/03/31/nhibernate-lazyinitializationexception-failed-to-lazily-initialize-a-collection-no-session-or-session-was-closed.aspx#comments</comments><description>&lt;p&gt;While I was working on some project my goal was to separate all presentation logic from my database access logic and &lt;a href="http://www.hibernate.org/343.html"&gt;NHibernate&lt;/a&gt; API calls so I created facade for creating and disposing NHibernate sessions and querying the database. Everything works fine until I didn&amp;#39;t need to display collection of objects in some ListBox control. Suddenly NHibernate&amp;#39;s LazyInitializationExceptions started to pop up because my NHibernate session was closed and collection&amp;#39;s objects weren&amp;#39;t initialized. Because lazy loading is default way of loading collections in NHibernate (which perfectly makes sense because you shouldn&amp;#39;t load entities which you don&amp;#39;t need) you have 2 ways to prevent above exception&amp;#39;s messages to pop up:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;prevent lazy loading in your mapping&lt;/li&gt;

&lt;li&gt;force NHibernate to initialize collection&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How can you prevent lazy loading in your mapping depends on the way your mapping is realized. I was using &lt;a href="http://code.google.com/p/fluent-nhibernate/"&gt;Fluent NHibernate&lt;/a&gt; so I did something similar to following code snippet:&lt;/p&gt;

&lt;pre&gt;public class WorkListMap : ClassMap&lt;br /&gt;{&lt;br /&gt;    public WorkListMap()&lt;br /&gt;    {&lt;br /&gt;        ...&lt;br /&gt;        HasMany(x =&amp;gt; x.Services).Inverse().&lt;b&gt;Not.LazyLoad&lt;/b&gt;();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;If you wan&amp;#39;t to force NHibernate to initialize collection you can call &lt;b&gt;&lt;i&gt;NHibernateUtil.Initialize&lt;/i&gt;&lt;/b&gt; method.&lt;/p&gt;

&lt;p&gt;That&amp;#39;s all. I hope this can save you few minutes if you ran into the same problem as I was. &lt;br /&gt;&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=33638" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/NHibernate/default.aspx">NHibernate</category></item><item><title>WPF trick #4 - Binding and Validation</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/02/05/wpf-trick-4-binding-and-validation.aspx</link><pubDate>Thu, 05 Feb 2009 21:35:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:16726</guid><dc:creator>boris.sevo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=16726</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/02/05/wpf-trick-4-binding-and-validation.aspx#comments</comments><description>
&lt;p&gt;Validation can also happen while binding is made. This is very useful if the bound objects have built in logic. For example if you have a &lt;i&gt;Product&lt;/i&gt; object which has &lt;i&gt;Price&lt;/i&gt; property which must be some number bigger the zero you will probably have code similar to this one:&lt;/p&gt;

&lt;pre&gt;&lt;span class="cskeyword"&gt;class&lt;/span&gt; &lt;span class="csclass"&gt;Product&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="cskeyword"&gt;private decimal&lt;/span&gt; _price;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="cskeyword"&gt;public decimal&lt;/span&gt; Price&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="cskeyword"&gt;get&lt;/span&gt; { &lt;span class="cskeyword"&gt;return&lt;/span&gt; _price; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="cskeyword"&gt;set&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&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; &lt;span class="cskeyword"&gt;if&lt;/span&gt; (&lt;span class="cskeyword"&gt;value&lt;/span&gt; &amp;lt;= 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="cskeyword"&gt;throw new&lt;/span&gt; &lt;span class="csclass"&gt;Exception&lt;/span&gt;(&lt;span class="csstring"&gt;&amp;quot;Exception from Price setter&amp;quot;&lt;/span&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; _price = &lt;span class="cskeyword"&gt;value&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;/pre&gt;
&lt;p&gt;If you need to mark invalid input inside some &lt;i&gt;TextBox&lt;/i&gt; you can then write something like this:&lt;/p&gt;

&lt;pre&gt;    &amp;lt;&lt;span class="csstring"&gt;Window.Resources&lt;/span&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;span class="csstring"&gt;code:Product&lt;/span&gt; &lt;span class="wpfAttr"&gt;x&lt;/span&gt;&lt;span class="cskeyword"&gt;:&lt;/span&gt;&lt;span class="wpfAttr"&gt;Key&lt;/span&gt;&lt;span class="cskeyword"&gt;=&amp;quot;dsProduct&amp;quot;&lt;/span&gt;/&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;span class="csstring"&gt;Window.Resources&lt;/span&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;span class="csstring"&gt;StackPanel&lt;/span&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;span class="csstring"&gt;WrapPanel&lt;/span&gt;&amp;gt;&lt;br /&gt;            &amp;lt;&lt;span class="csstring"&gt;TextBox&lt;/span&gt; &lt;span class="wpfAttr"&gt;Width&lt;/span&gt;&lt;span class="cskeyword"&gt;=&amp;quot;200&amp;quot;&lt;/span&gt; &lt;span class="wpfAttr"&gt;Text&lt;/span&gt;&lt;span class="cskeyword"&gt;=&amp;quot;{&lt;/span&gt;&lt;span class="csstring"&gt;Binding&lt;/span&gt; &lt;br /&gt;                        &lt;span class="wpfAttr"&gt;Source&lt;/span&gt;&lt;span class="cskeyword"&gt;={&lt;/span&gt;&lt;span class="csstring"&gt;StaticResource&lt;/span&gt; &lt;span class="wpfAttr"&gt;dsProduct&lt;/span&gt;&lt;span class="cskeyword"&gt;}&lt;/span&gt;, &lt;br /&gt;                        &lt;span class="wpfAttr"&gt;Path&lt;/span&gt;&lt;span class="cskeyword"&gt;=Price&lt;/span&gt;, &lt;br /&gt;                        &lt;span class="wpfAttr"&gt;UpdateSourceTrigger&lt;/span&gt;&lt;span class="cskeyword"&gt;=PropertyChanged,&lt;/span&gt;&lt;br /&gt;                        &lt;b&gt;&lt;span class="wpfAttr"&gt;ValidatesOnDataErrors&lt;/span&gt;&lt;span class="cskeyword"&gt;=True&lt;/span&gt;&lt;/b&gt;, &lt;br /&gt;                        &lt;b&gt;&lt;span class="wpfAttr"&gt;ValidatesOnExceptions&lt;/span&gt;&lt;span class="cskeyword"&gt;=True&lt;/span&gt;&lt;/b&gt;&lt;span class="cskeyword"&gt;}&amp;quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;            &amp;lt;/&lt;span class="csstring"&gt;TextBox&lt;/span&gt;&amp;gt;&lt;br /&gt;        &amp;lt;/&lt;span class="csstring"&gt;WrapPanel&lt;/span&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;span class="csstring"&gt;StackPanel&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=16726" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/WPF/default.aspx">WPF</category></item><item><title>WPF trick #3 - MultiBinding and StringFormat</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/01/20/wpf-trick-3-multibinding-and-stringformat.aspx</link><pubDate>Tue, 20 Jan 2009 13:17:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:16419</guid><dc:creator>boris.sevo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=16419</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/01/20/wpf-trick-3-multibinding-and-stringformat.aspx#comments</comments><description>
&lt;p&gt;One of the new features in .NET Framework 3.5 SP1 is &lt;i&gt;StringFormat&lt;/i&gt; support within {{Binding}} expressions to enable easy formatting to bound values.&lt;br /&gt;So, if some &lt;i&gt;TextBlock&lt;/i&gt; control need to be bound to some object&amp;#39;s properties (let&amp;#39;s call them &lt;i&gt;Max&lt;/i&gt; and &lt;i&gt;Min&lt;/i&gt;) and the value of the TextBlock&amp;#39;s &lt;i&gt;Text&lt;/i&gt; property need to be in &lt;i&gt;[Min - Max]&lt;/i&gt; format you can then write something like this:&lt;/p&gt;

&lt;pre&gt;    &amp;lt;TextBlock&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;     &amp;lt;TextBlock.Text&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;     &amp;lt;MultiBinding StringFormat=&amp;quot;[{0} - {1}]&amp;quot;&amp;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;lt;Binding Path=&amp;quot;Min&amp;quot;&amp;gt;&amp;lt;/Binding&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Binding Path=&amp;quot;Max&amp;quot;&amp;gt;&amp;lt;/Binding&amp;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;lt;/MultiBinding&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;lt;/TextBlock.Text&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/TextBlock&amp;gt; &lt;br /&gt;&lt;/pre&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=16419" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/WPF/default.aspx">WPF</category></item><item><title>jQuery 1.3 released</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/01/14/jquery-1-3-released.aspx</link><pubDate>Wed, 14 Jan 2009 20:36:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:15931</guid><dc:creator>boris.sevo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=15931</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/01/14/jquery-1-3-released.aspx#comments</comments><description>
&lt;p&gt;New version of jQuery is released today! It includes new (and faster!) selector engine, new way for binding events, new way for browser detection (or should I say feature detection?) and much more.&lt;br /&gt;
Read more about it &lt;a href="http://docs.jquery.com/Release:jQuery_1.3"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;(Google is allready hosting it at &lt;a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js&lt;/a&gt;)&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=15931" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/jQuery/default.aspx">jQuery</category></item><item><title>Multiple versions of Firefox on the same computer</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2009/01/10/multiple-versions-of-firefox-on-the-same-computer.aspx</link><pubDate>Sat, 10 Jan 2009 12:17:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:15670</guid><dc:creator>boris.sevo</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=15670</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2009/01/10/multiple-versions-of-firefox-on-the-same-computer.aspx#comments</comments><description>&lt;p&gt;Every good web developer has two responsibilities: check the web application&amp;#39;s behavior in multiple browsers and submit found browser&amp;#39;s bugs and incompatibilities to the browser&amp;#39;s vendor. Having so much browser versions even from a single browser vendor complicates developer&amp;#39;s life. Luckily there is a simple way to test your web application in various Firefox versions. If you already have some Firefox version installed on your computer all you have to do is to download a new Firefox version (the newest version from trunk can be found &lt;a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/"&gt;here&lt;/a&gt;) extract it in some folder and run it using &lt;i&gt;ProfileManager&lt;/i&gt; option (after you have closed all Firefox instances go to command prompt and do something like this: D:\firefoxes\3.2a1pre&amp;gt;firefox.exe -ProfileManager).&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=15670" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/Firefox/default.aspx">Firefox</category></item><item><title>Anchor is not clickable in Firefox and Safari when it's inside of the div tag which has image as background</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2008/12/11/anchor-is-not-clickable-in-firefox-and-safari-when-it-s-placed-inside-div-tag-with-image-as-background.aspx</link><pubDate>Thu, 11 Dec 2008 15:05:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:14641</guid><dc:creator>boris.sevo</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=14641</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2008/12/11/anchor-is-not-clickable-in-firefox-and-safari-when-it-s-placed-inside-div-tag-with-image-as-background.aspx#comments</comments><description>&lt;p&gt;That&amp;#39;s one of mine older issues which I was facing few months ago and today, while I was browsing through my pending blog posts, I decided to post few words about it hoping that it will save you few minutes of work if you ran into the same problem as I was.&lt;/p&gt;

&lt;p&gt;So, let&amp;#39;s imagine that you want to put some link (anchor tag) inside a div tag which has some image as a background and that your link need to positioned somewhere inside of the image (div&amp;#39;s background). Your HTML code will then be something like this:&lt;/p&gt;

&lt;pre&gt;&amp;lt;div class=&amp;quot;divsCSSClass&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;a href=&amp;quot;Default.aspx&amp;quot; style=&amp;quot;left: 133px; position:relative; top: 7px;&amp;quot;&amp;gt;&lt;br /&gt;            some_text&lt;br /&gt;     &amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;and your CSS will then be something like this:&lt;/p&gt;

&lt;pre&gt;.divsCSSClass {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; background: url(&amp;#39;image_name.png&amp;#39;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width:392px;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height:45px;&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;Above code will work in IE and Opera, but in Firefox and Safari link (anchor) will not be clickable. The solution is extremely simple. All you need to do is to add &lt;i&gt;position:relative;&lt;/i&gt; to div&amp;#39;s CSS class. CSS will then be something like this:&lt;/p&gt;

&lt;pre&gt;&amp;nbsp;.divsCSSClass {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; background: url(&amp;#39;image_name.png&amp;#39;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width:392px;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height:45px;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;&lt;b&gt;position: relative;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=14641" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/CSS/default.aspx">CSS</category><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/Firefox/default.aspx">Firefox</category></item><item><title>Using jQuery to prevent form submit when enter is pressed</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2008/12/11/using-jquery-to-prevent-form-submit-when-enter-is-pressed.aspx</link><pubDate>Thu, 11 Dec 2008 10:51:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:14632</guid><dc:creator>boris.sevo</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=14632</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2008/12/11/using-jquery-to-prevent-form-submit-when-enter-is-pressed.aspx#comments</comments><description>&lt;p&gt;I was recently working on a ASP.NET RIA which has a web form with the input field in which users can type some search term and press the search button or hit enter key. Search is invoked by an asynchronous call and done on the server. The text field is placed inside of &lt;i&gt;form&lt;/i&gt; tag and because of that, when someone hits the enter key, instead of the desired behavior (asynchronous call), the whole form is submitted to the server. There is more then one possible solution for this kind of problem, but because I was already using jQuery for building the whole application&amp;#39;s UI, I fixed the problem with the following elegant jQuery&amp;#39;s cross-browser code snippet:&lt;/p&gt;

&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;$(&amp;quot;form&amp;quot;).bind(&amp;quot;keypress&amp;quot;, function(e) {&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; if (e.keyCode == 13) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;search($(&amp;quot;#searchTerm&amp;quot;).attr(&amp;#39;value&amp;#39;));&lt;b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&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; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &lt;/pre&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=14632" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/jQuery/default.aspx">jQuery</category></item><item><title>Testing tool for multithreaded applications from Microsoft Research</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2008/11/22/testing-tool-for-multithreaded-applications-from-microsoft-research.aspx</link><pubDate>Sat, 22 Nov 2008 09:34:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:14385</guid><dc:creator>boris.sevo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=14385</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2008/11/22/testing-tool-for-multithreaded-applications-from-microsoft-research.aspx#comments</comments><description>
&lt;p&gt;Microsoft Research has released &lt;a href="http://research.microsoft.com/projects/CHESS/"&gt;CHESS&lt;/a&gt;,
an automated tool for finding errors like data-races, deadlocks, and hangs in multithreaded applications by systematically exploring thread schedules (it has even discovered bug in PLINQ). Once error is located, CHESS provides a fully repeatable execution
of the program leading to the error. Win32 version can be downloaded &lt;a href="http://research.microsoft.com/research/downloads/details/b23f8dc3-bb73-498f-bd85-1de121672e69/details.aspx"&gt;here&lt;/a&gt; (at this time license is only for academic use) and commercial version will hopefully be available soon.&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=14385" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/concurrent+programming/default.aspx">concurrent programming</category></item><item><title>Hotfix for WPF designer</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2008/11/19/hotfix-for-wpf-designer.aspx</link><pubDate>Wed, 19 Nov 2008 11:46:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:14368</guid><dc:creator>boris.sevo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=14368</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2008/11/19/hotfix-for-wpf-designer.aspx#comments</comments><description>&lt;p&gt;If you are working with WPF you should consider downloading the hotfix which can be found &lt;a href="http://code.msdn.microsoft.com/KB958017"&gt;here&lt;/a&gt;. If you have Silverlight Tools for VS 2008 SP1 you shouldn&amp;#39;t install this hotfix because it already includes it.&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=14368" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/WPF/default.aspx">WPF</category></item><item><title>WPF trick #2 - Alternate background colors for ListView rows</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2008/10/21/wpf-trick-1-alternate-background-colors-for-listview-rows.aspx</link><pubDate>Tue, 21 Oct 2008 14:22:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:13799</guid><dc:creator>boris.sevo</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=13799</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2008/10/21/wpf-trick-1-alternate-background-colors-for-listview-rows.aspx#comments</comments><description>&lt;p&gt;Prior the .NET Framework 3.5 SP1 was released, if you want to set alternate background colors for ListView rows you needed to write some kind Converter which returnes some kind of Brush. IF you have SP1 installed accomplishing the same functionality is rather trivial job. Here are the code snippets:&lt;/p&gt;

&lt;p&gt;(defining the style)&lt;/p&gt;

&lt;pre&gt;    &amp;lt;Style x:Key=&amp;quot;&lt;b&gt;CustomListViewItemStyle&lt;/b&gt;&amp;quot; TargetType=&amp;quot;{x:Type ListViewItem}&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;Style.Triggers&amp;gt;&lt;br /&gt;            &amp;lt;Trigger Property=&amp;quot;ItemsControl.AlternationIndex&amp;quot; Value=&amp;quot;&lt;b&gt;0&lt;/b&gt;&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;Setter Property=&amp;quot;Background&amp;quot; Value=&amp;quot;#2C2C2C&amp;quot;&amp;gt;&amp;lt;/Setter&amp;gt;&lt;br /&gt;            &amp;lt;/Trigger&amp;gt;&lt;br /&gt;            &amp;lt;Trigger Property=&amp;quot;ItemsControl.AlternationIndex&amp;quot; Value=&amp;quot;&lt;b&gt;1&lt;/b&gt;&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;Setter Property=&amp;quot;Background&amp;quot; Value=&amp;quot;#262626&amp;quot;&amp;gt;&amp;lt;/Setter&amp;gt;&lt;br /&gt;            &amp;lt;/Trigger&amp;gt;&lt;br /&gt;        &amp;lt;/Style.Triggers&amp;gt;&lt;br /&gt;    &amp;lt;/Style&amp;gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;(using the defined style)&lt;/p&gt;
&lt;pre&gt;    &amp;lt;ListView ItemContainerStyle=&amp;quot;{DynamicResource &lt;b&gt;CustomListViewItemStyle&lt;/b&gt;}&amp;quot;&lt;br /&gt;             &lt;b&gt; AlternationCount=&amp;quot;2&amp;quot;&lt;/b&gt;&amp;gt;&lt;br /&gt;        ...&lt;br /&gt;    &amp;lt;/ListView&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=13799" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/WPF/default.aspx">WPF</category></item><item><title>WPF trick #1 - Hyperlink control</title><link>http://live.mscommunity.net/blogs/borissevo/archive/2008/10/21/wpf-trick-1-hyperlink-control.aspx</link><pubDate>Tue, 21 Oct 2008 08:13:00 GMT</pubDate><guid isPermaLink="false">4a43ed64-1a24-4d7d-9bcd-c9f8b8acacd0:13759</guid><dc:creator>boris.sevo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://live.mscommunity.net/blogs/borissevo/rsscomments.aspx?PostID=13759</wfw:commentRss><comments>http://live.mscommunity.net/blogs/borissevo/archive/2008/10/21/wpf-trick-1-hyperlink-control.aspx#comments</comments><description>
&lt;p&gt;Today I needed to create a simple grid which will hold some text information about some products and a few Hyperlink controls which when clicked need to display detailed information about particular product. On my big surprise WPF doesn&amp;#39;t have Hyperlink control. This is really weird, but the solution is very simple. All you need to do is to use &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.documents.hyperlink.aspx"&gt;System.Windows.Documents.Hyperlink&lt;/a&gt; in a combination with &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.aspx"&gt;TextBlock&lt;/a&gt; control.&lt;/p&gt;

&lt;p&gt;XAML code for creating Hyperlink &amp;#39;control&amp;#39; is then something like this:&lt;/p&gt;

&lt;pre&gt;    
    &amp;lt;TextBlock&amp;gt;
        &amp;lt;Hyperlink&amp;gt;
            &amp;lt;TextBlock Text=&amp;quot;Some text&amp;quot;&amp;gt;
        &amp;lt;/Hyperlink&amp;gt;
    &amp;lt;/TextBlock&amp;gt;
&lt;/pre&gt;
&lt;img src="http://live.mscommunity.net/aggbug.aspx?PostID=13759" width="1" height="1"&gt;</description><category domain="http://live.mscommunity.net/blogs/borissevo/archive/tags/WPF/default.aspx">WPF</category></item></channel></rss>