<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;C0MDRH44eSp7ImA9WhRVGUs.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505</id><updated>2012-01-19T09:24:35.031+01:00</updated><category term="vs" /><category term="Vista" /><category term="Internet" /><category term="SQL" /><category term="silverlight" /><category term="Office" /><category term="F#" /><category term="Windows" /><category term="Security" /><category term="IIS" /><category term="ASP.NET MVC" /><category term="Programming" /><category term="ASP.NET" /><category term="Mathematica" /><category term="Testing" /><category term="C++" /><category term="visual studio" /><category term="C#" /><category term="Database" /><category term="Visual Basic" /><category term="NHibernate" /><category term="JavaScript" /><category term="WPF" /><category term="Education" /><category term="OpenGL" /><category term="Excel" /><title>Techie things</title><subtitle type="html">A blog about .NET development and software architecture.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://techiethings.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>83</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/techiethings" /><feedburner:info uri="techiethings" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" /><logo>http://creativecommons.org/images/public/somerights20.gif</logo><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Ftechiethings" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Ftechiethings" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Ftechiethings" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/techiethings" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Ftechiethings" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Ftechiethings" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Ftechiethings" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><entry gd:etag="W/&quot;C0MDRH44fip7ImA9WhRVGUs.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-2546709197945951837</id><published>2012-01-19T09:24:00.001+01:00</published><updated>2012-01-19T09:24:35.036+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-19T09:24:35.036+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>jQuery div vs native doc fragment</title><content type="html">&lt;p&gt;I assumed creating a div with jQuery takes more time compared to native document fragment creation. Surprise, I was wrong. I’ve created a test page on JSPerf at &lt;a title="http://jsperf.com/jquery-vs-documentfragment" href="http://jsperf.com/jquery-vs-documentfragment"&gt;http://jsperf.com/jquery-vs-documentfragment&lt;/a&gt;. Simply put, the speed depends on the browser.&lt;/p&gt; &lt;p&gt;&lt;a title="jQuery div vs native document fragment performance" href="http://i63.photobucket.com/albums/h134/artur02/Blog/69c8d554.png" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" border="0" src="http://i63.photobucket.com/albums/h134/artur02/Blog/69c8d554.png" width="615" height="310"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Verdict&lt;/strong&gt;: Use document fragment in all browsers except Internet Explorer. In general, use document fragment:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;document.createDocumentFragment();&lt;/code&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-2546709197945951837?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=iUHox2iA91k:HfdZw1AEmCI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=iUHox2iA91k:HfdZw1AEmCI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=iUHox2iA91k:HfdZw1AEmCI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=iUHox2iA91k:HfdZw1AEmCI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=iUHox2iA91k:HfdZw1AEmCI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=iUHox2iA91k:HfdZw1AEmCI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/2546709197945951837/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2012/01/jquery-div-vs-native-doc-fragment.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2546709197945951837?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2546709197945951837?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/iUHox2iA91k/jquery-div-vs-native-doc-fragment.html" title="jQuery div vs native doc fragment" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_69c8d554.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2012/01/jquery-div-vs-native-doc-fragment.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEAEQ3Y8eip7ImA9WhRSEko.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-3277649784828831891</id><published>2011-11-14T13:11:00.001+01:00</published><updated>2011-11-14T13:11:42.872+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-14T13:11:42.872+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="Internet" /><title>Less CSS and IIS 7</title><content type="html">&lt;p&gt;In case you are using &lt;a href="http://lesscss.org/"&gt;Less CSS&lt;/a&gt; to generate CSS markups, IIS won’t find your &lt;strong&gt;.less&lt;/strong&gt; files by default. You will get a &lt;strong&gt;404 Not Found&lt;/strong&gt; error. The problem is the missing MIME type.&lt;/p&gt;  &lt;p&gt;The solution is simple, just register the MIME type for .less in web.config:&lt;/p&gt;  &lt;pre&gt;&amp;lt;system.webServer&amp;gt;&lt;br /&gt;  &amp;lt;staticContent&amp;gt;&lt;br /&gt;    &amp;lt;mimeMap fileExtension=&amp;quot;.less&amp;quot; mimeType=&amp;quot;text/css&amp;quot;/&amp;gt;&lt;br /&gt;  &amp;lt;/staticContent&amp;gt;&lt;br /&gt;&amp;lt;/system.webServer&amp;gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-3277649784828831891?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=wqT8j1Gj7Hk:YXQc66A7OPw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=wqT8j1Gj7Hk:YXQc66A7OPw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=wqT8j1Gj7Hk:YXQc66A7OPw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=wqT8j1Gj7Hk:YXQc66A7OPw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=wqT8j1Gj7Hk:YXQc66A7OPw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=wqT8j1Gj7Hk:YXQc66A7OPw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/3277649784828831891/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2011/11/less-css-and-iis-7.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/3277649784828831891?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/3277649784828831891?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/wqT8j1Gj7Hk/less-css-and-iis-7.html" title="Less CSS and IIS 7" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2011/11/less-css-and-iis-7.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMBR3w-cSp7ImA9WhdVFEg.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-5063986328175351888</id><published>2011-09-18T20:47:00.001+02:00</published><updated>2011-09-19T18:40:56.259+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-19T18:40:56.259+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><title>ASP.NET MVC Internals 3: Controller structure</title><content type="html">Controllers implement the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.icontroller.aspx" target="_blank"&gt;&lt;strong&gt;IController&lt;/strong&gt;&lt;/a&gt; interface:&lt;br /&gt;
&lt;pre class="brush: csharp; gutter: false; toolbar: false;"&gt;public interface IController 
{
    void Execute(RequestContext requestContext);
}&lt;/pre&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.aspx" target="_blank"&gt;&lt;strong&gt;ControllerBase&lt;/strong&gt;&lt;/a&gt; abstract class implements the &lt;em&gt;IController&lt;/em&gt; interface:&lt;br /&gt;
&lt;pre class="brush: csharp; gutter: false; toolbar: false; collapse: true;"&gt;public abstract class ControllerBase : MarshalByRefObject, IController 
{

    private TempDataDictionary _tempDataDictionary;
    private bool _validateRequest = true;
    private IDictionary&amp;lt;string, ValueProviderResult&amp;gt; _valueProvider;
    private ViewDataDictionary _viewDataDictionary;

    public ControllerContext ControllerContext {
        get;
        set;
    }

    public TempDataDictionary TempData {
        get {
            if (_tempDataDictionary == null) {
                _tempDataDictionary = new TempDataDictionary();
            }
            return _tempDataDictionary;
        }
        set {
            _tempDataDictionary = value;
        }
    }

    public bool ValidateRequest {
        get {
            return _validateRequest;
        }
        set {
            _validateRequest = value;
        }
    }

    public IDictionary&amp;lt;string, ValueProviderResult&amp;gt; ValueProvider {
        get {
            if (_valueProvider == null) {
                _valueProvider = new ValueProviderDictionary(ControllerContext);
            }
            return _valueProvider;
        }
        set {
            _valueProvider = value;
        }
    }

    public ViewDataDictionary ViewData {
        get {
            if (_viewDataDictionary == null) {
                _viewDataDictionary = new ViewDataDictionary();
            }
            return _viewDataDictionary;
        }
        set {
            _viewDataDictionary = value;
        }
    }

    protected virtual void Execute(RequestContext requestContext) {
        if (requestContext == null) {
            throw new ArgumentNullException("requestContext");
        }

        Initialize(requestContext);
        ExecuteCore();
    }

    protected abstract void ExecuteCore();

    protected virtual void Initialize(RequestContext requestContext) {
        ControllerContext = new ControllerContext(requestContext, this);
    }
    
    [...]
}&lt;/pre&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
The &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.aspx" target="_blank"&gt;&lt;strong&gt;Controller&lt;/strong&gt;&lt;/a&gt; class derives from &lt;em&gt;ControllerBase&lt;/em&gt; abstract class:&lt;br /&gt;
&lt;pre class="brush: csharp; gutter: false; toolbar: false; collapse: true; highlight: [121];"&gt;public abstract class Controller : ControllerBase, IActionFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, IResultFilter {

    private IActionInvoker _actionInvoker;
    private ModelBinderDictionary _binders;
    private RouteCollection _routeCollection;
    private ITempDataProvider _tempDataProvider;

    public IActionInvoker ActionInvoker {
        get {
            if (_actionInvoker == null) {
                _actionInvoker = new ControllerActionInvoker();
            }
            return _actionInvoker;
        }
        set {
            _actionInvoker = value;
        }
    }

    protected internal ModelBinderDictionary Binders {
        get {
            if (_binders == null) {
                _binders = ModelBinders.Binders;
            }
            return _binders;
        }
        set {
            _binders = value;
        }
    }

    public HttpContextBase HttpContext {
        get {
            return ControllerContext == null ? null : ControllerContext.HttpContext;
        }
    }

    public ModelStateDictionary ModelState {
        get {
            return ViewData.ModelState;
        }
    }

    public HttpRequestBase Request {
        get {
            return HttpContext == null ? null : HttpContext.Request;
        }
    }

    public HttpResponseBase Response {
        get {
            return HttpContext == null ? null : HttpContext.Response;
        }
    }

    internal RouteCollection RouteCollection {
        get {
            if (_routeCollection == null) {
                _routeCollection = RouteTable.Routes;
            }
            return _routeCollection;
        }
        set {
            _routeCollection = value;
        }
    }

    public RouteData RouteData {
        get {
            return ControllerContext == null ? null : ControllerContext.RouteData;
        }
    }

    public HttpServerUtilityBase Server {
        get {
            return HttpContext == null ? null : HttpContext.Server;
        }
    }

    public HttpSessionStateBase Session {
        get {
            return HttpContext == null ? null : HttpContext.Session;
        }
    }

    public ITempDataProvider TempDataProvider {
        get {
            if (_tempDataProvider == null) {
                _tempDataProvider = new SessionStateTempDataProvider();
            }
            return _tempDataProvider;
        }
        set {
            _tempDataProvider = value;
        }
    }

    public UrlHelper Url {
        get;
        set;
    }

    public IPrincipal User {
        get {
            return HttpContext == null ? null : HttpContext.User;
        }
    }

    [...]

    protected internal virtual ContentResult Content(string content, string contentType, Encoding contentEncoding) {
        return new ContentResult {
            Content = content,
            ContentType = contentType,
            ContentEncoding = contentEncoding
        };
    }

    [...]

    protected override void ExecuteCore() {
        TempData.Load(ControllerContext, TempDataProvider);

        try {
            string actionName = RouteData.GetRequiredString("action");
            if (!ActionInvoker.InvokeAction(ControllerContext, actionName)) {
                HandleUnknownAction(actionName);
            }
        }
        finally {
            TempData.Save(ControllerContext, TempDataProvider);
        }
    }

    [...]

    protected internal virtual FilePathResult File(string fileName, string contentType, string fileDownloadName) {
        return new FilePathResult(fileName, contentType) { FileDownloadName = fileDownloadName };
    }

    protected virtual void HandleUnknownAction(string actionName) {
        throw new HttpException(404, String.Format(CultureInfo.CurrentUICulture,
            MvcResources.Controller_UnknownAction, actionName, GetType().FullName));
    }

    protected internal virtual JavaScriptResult JavaScript(string script) {
        return new JavaScriptResult { Script = script };
    }

    [...]

    protected internal virtual JsonResult Json(object data, string contentType, Encoding contentEncoding) {
        return new JsonResult {
            Data = data,
            ContentType = contentType,
            ContentEncoding = contentEncoding
        };
    }

    protected override void Initialize(RequestContext requestContext) {
        base.Initialize(requestContext);
        Url = new UrlHelper(requestContext);
    }

    protected virtual void OnActionExecuting(ActionExecutingContext filterContext) {
    }

    protected virtual void OnActionExecuted(ActionExecutedContext filterContext) {
    }

    protected virtual void OnAuthorization(AuthorizationContext filterContext) {
    }

    protected virtual void OnException(ExceptionContext filterContext) {
    }

    protected virtual void OnResultExecuted(ResultExecutedContext filterContext) {
    }

    protected virtual void OnResultExecuting(ResultExecutingContext filterContext) {
    }

    [...]

    protected internal PartialViewResult PartialView(string viewName) {
        return PartialView(viewName, null /* model */);
    }

    protected internal virtual PartialViewResult PartialView(string viewName, object model) {
        if (model != null) {
            ViewData.Model = model;
        }

        return new PartialViewResult {
            ViewName = viewName,
            ViewData = ViewData,
            TempData = TempData
        };
    }

    protected internal virtual RedirectResult Redirect(string url) {
        [...]
        return new RedirectResult(url);
    }

    protected internal RedirectToRouteResult RedirectToAction(string actionName) {
        return RedirectToAction(actionName, (RouteValueDictionary)null);
    }

    [...]

    protected internal virtual RedirectToRouteResult RedirectToAction(string actionName, string controllerName, RouteValueDictionary routeValues) {
        RouteValueDictionary mergedRouteValues;

        if (RouteData == null) {
            mergedRouteValues = RouteValuesHelpers.MergeRouteValues(actionName, controllerName, null, routeValues, true /* includeImplicitMvcValues */);
        }
        else {
            mergedRouteValues = RouteValuesHelpers.MergeRouteValues(actionName, controllerName, RouteData.Values, routeValues, true /* includeImplicitMvcValues */);
        }

        return new RedirectToRouteResult(mergedRouteValues);
    }

    [...]

    protected internal RedirectToRouteResult RedirectToRoute(string routeName) {
        return RedirectToRoute(routeName, (RouteValueDictionary)null);
    }

    [...]

    protected internal bool TryUpdateModel&amp;lt;TModel&amp;gt;(TModel model) where TModel : class {
        return TryUpdateModel(model, null, null, null, ValueProvider);
    }

    [...]

    protected internal bool TryUpdateModel&amp;lt;TModel&amp;gt;(TModel model, string prefix, string[] includeProperties, string[] excludeProperties, IDictionary&amp;lt;string, ValueProviderResult&amp;gt; valueProvider) where TModel : class {
        [...]

        Predicate&amp;lt;string&amp;gt; propertyFilter = propertyName =&amp;gt; BindAttribute.IsPropertyAllowed(propertyName, includeProperties, excludeProperties);
        IModelBinder binder = Binders.GetBinder(typeof(TModel));

        ModelBindingContext bindingContext = new ModelBindingContext() {
            Model = model,
            ModelName = prefix,
            ModelState = ModelState,
            ModelType = typeof(TModel),
            PropertyFilter = propertyFilter,
            ValueProvider = valueProvider
        };
        binder.BindModel(ControllerContext, bindingContext);
        return ModelState.IsValid;
    }

    protected internal void UpdateModel&amp;lt;TModel&amp;gt;(TModel model) where TModel : class {
        UpdateModel(model, null, null, null, ValueProvider);
    }

    [...]

    protected internal void UpdateModel&amp;lt;TModel&amp;gt;(TModel model, string prefix, string[] includeProperties, string[] excludeProperties, IDictionary&amp;lt;string, ValueProviderResult&amp;gt; valueProvider) where TModel : class {
        bool success = TryUpdateModel(model, prefix, includeProperties, excludeProperties, valueProvider);
        if (!success) {
            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.Controller_UpdateModel_UpdateUnsuccessful,
                typeof(TModel).FullName);
            throw new InvalidOperationException(message);
        }
    }

    protected internal ViewResult View() {
        return View(null /* viewName */, null /* masterName */, null /* model */);
    }

    protected internal ViewResult View(object model) {
        return View(null /* viewName */, null /* masterName */, model);
    }

    protected internal ViewResult View(string viewName) {
        return View(viewName, null /* masterName */, null /* model */);
    }

    protected internal ViewResult View(string viewName, string masterName) {
        return View(viewName, masterName, null /* model */);
    }

    protected internal ViewResult View(string viewName, object model) {
        return View(viewName, null /* masterName */, model);
    }

    protected internal virtual ViewResult View(string viewName, string masterName, object model) {
        if (model != null) {
            ViewData.Model = model;
        }

        return new ViewResult {
            ViewName = viewName,
            MasterName = masterName,
            ViewData = ViewData,
            TempData = TempData
        };
    }

    protected internal ViewResult View(IView view) {
        return View(view, null /* model */);
    }

    protected internal virtual ViewResult View(IView view, object model) {
        if (model != null) {
            ViewData.Model = model;
        }

        return new ViewResult {
            View = view,
            ViewData = ViewData,
            TempData = TempData
        };
    }

    #region IActionFilter Members
    void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) {
        OnActionExecuting(filterContext);
    }

    void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext) {
        OnActionExecuted(filterContext);
    }
    #endregion

    #region IAuthorizationFilter Members
    void IAuthorizationFilter.OnAuthorization(AuthorizationContext filterContext) {
        OnAuthorization(filterContext);
    }
    #endregion

    #region IExceptionFilter Members
    void IExceptionFilter.OnException(ExceptionContext filterContext) {
        OnException(filterContext);
    }
    #endregion

    #region IResultFilter Members
    void IResultFilter.OnResultExecuting(ResultExecutingContext filterContext) {
        OnResultExecuting(filterContext);
    }

    void IResultFilter.OnResultExecuted(ResultExecutedContext filterContext) {
        OnResultExecuted(filterContext);
    }
    #endregion
}&lt;/pre&gt;The Controller class implements the &lt;em&gt;ExecuteCore()&lt;/em&gt; function. It sets the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.tempdatadictionary.aspx" target="_blank"&gt;&lt;em&gt;TempData&lt;/em&gt;&lt;/a&gt; to make it available during the action method execution. The method reads the action name from the &lt;em&gt;RouteData&lt;/em&gt; and calls the action method, identified by the recently read name, using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.iactioninvoker.aspx" target="_blank"&gt;&lt;em&gt;ActionInvoker.InvokeAction()&lt;/em&gt;&lt;/a&gt; method. &lt;br /&gt;
All the usually used helper methods such as &lt;a href="http://msdn.microsoft.com/en-us/library/dd460331.aspx" target="_blank"&gt;&lt;em&gt;View()&lt;/em&gt;&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/dd470933.aspx" target="_blank"&gt;&lt;em&gt;UpdateModel()&lt;/em&gt;&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/dd492492.aspx" target="_blank"&gt;&lt;em&gt;File()&lt;/em&gt;&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/dd504936.aspx" target="_blank"&gt;&lt;em&gt;Json()&lt;/em&gt;&lt;/a&gt; are defined by the Controller class. &lt;br /&gt;
&lt;a href="http://s63.photobucket.com/albums/h134/artur02/Blog/?action=view&amp;amp;current=d37cdc78.png" target="_blank"&gt;&lt;img alt="ASP.NET MCV: Controller inheritance" border="0" src="http://i63.photobucket.com/albums/h134/artur02/Blog/th_d37cdc78.png" /&gt;&lt;/a&gt;&lt;br /&gt;
Link: &lt;a href="http://artur02.googlecode.com/svn/trunk/AspNetMvc/RequestPipeline/Controller.png" target="_blank"&gt;ASP.NET MVC – Controller inheritance&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-5063986328175351888?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=MYRI6CZ3DmE:_8GgVbdMrpE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=MYRI6CZ3DmE:_8GgVbdMrpE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=MYRI6CZ3DmE:_8GgVbdMrpE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=MYRI6CZ3DmE:_8GgVbdMrpE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=MYRI6CZ3DmE:_8GgVbdMrpE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=MYRI6CZ3DmE:_8GgVbdMrpE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/5063986328175351888/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2011/09/aspnet-mvc-internals-3-controller.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5063986328175351888?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5063986328175351888?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/MYRI6CZ3DmE/aspnet-mvc-internals-3-controller.html" title="ASP.NET MVC Internals 3: Controller structure" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_d37cdc78.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2011/09/aspnet-mvc-internals-3-controller.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8ARXs-cCp7ImA9WhdVFEg.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-4539859615961424893</id><published>2011-09-17T18:42:00.001+02:00</published><updated>2011-09-19T18:47:24.558+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-19T18:47:24.558+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><title>ASP.NET MVC Internals 2: Controller</title><content type="html">The &lt;em&gt;&lt;strong&gt;MvcHandler&lt;/strong&gt;&lt;/em&gt; class processes an HTTP request. The routing framework calls its &lt;em&gt;ProcessRequest()&lt;/em&gt; function in case of an incoming request matching an MVC route.&lt;br /&gt;
&lt;pre class="brush: csharp; toolbar: false;"&gt;public class MvcHandler : IHttpHandler, IRequiresSessionState 
{
    [...]
    protected internal virtual void ProcessRequest(HttpContextBase httpContext) 
    {
        AddVersionHeader(httpContext);

        // Get the controller type
        string controllerName = RequestContext.RouteData.GetRequiredString(&amp;amp;quot;controller&amp;amp;quot;);

        // Instantiate the controller and call Execute
        IControllerFactory factory = ControllerBuilder.GetControllerFactory();
        IController controller = factory.CreateController(RequestContext, controllerName);
        if (controller == null) {
            throw new InvalidOperationException(
                String.Format(
                    CultureInfo.CurrentUICulture,
                    MvcResources.ControllerBuilder_FactoryReturnedNull,
                    factory.GetType(),
                    controllerName));
        }
        try {
            controller.Execute(RequestContext);
        }
        finally {
            factory.ReleaseController(controller);
        }
    }
    [...]
}&lt;/pre&gt;&lt;p&gt;Firstly it reads the controller name from the routing data and after that it creates a controller by the name read before. Finally it calls the &lt;em&gt;Execute&lt;/em&gt; method of the controller to run the controller’s code.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The &lt;em&gt;&lt;strong&gt;ControllerBuilder&lt;/strong&gt;&lt;/em&gt; is a factory for creating the controller instance. &lt;/p&gt;&lt;pre class="brush: csharp; toolbar: false; highlight: [8];"&gt;public class ControllerBuilder 
{
    [...]
    private Func&amp;lt;IControllerFactory&amp;gt; _factoryThunk;

    public ControllerBuilder() 
    {
        SetControllerFactory(new DefaultControllerFactory() {
            ControllerBuilder = this
        });
    }

    [...]
    public IControllerFactory GetControllerFactory() {
        IControllerFactory controllerFactoryInstance = _factoryThunk();
        return controllerFactoryInstance;
    }

    public void SetControllerFactory(IControllerFactory controllerFactory) 
    {
        if (controllerFactory == null) {
            throw new ArgumentNullException("controllerFactory");
        }

        _factoryThunk = () =&amp;gt; controllerFactory;
    }
    [...]
}&lt;/pre&gt;The constructor of the class at line 8 calls the &lt;em&gt;SetControllerFactory&lt;/em&gt; method with a &lt;em&gt;DefaultControllerFactory&lt;/em&gt; instance. Thus the &lt;em&gt;&lt;strong&gt;DefaultControllerFactory&lt;/strong&gt;&lt;/em&gt; class will look up and call the controller with the name provided by the &lt;em&gt;RouteData&lt;/em&gt;.&lt;br /&gt;
&lt;pre class="brush: csharp; gutter: false; toolbar: false;"&gt;public class DefaultControllerFactory : IControllerFactory 
{
    private IBuildManager _buildManager;
    private ControllerBuilder _controllerBuilder;
    private ControllerTypeCache _instanceControllerTypeCache;
    private static ControllerTypeCache _staticControllerTypeCache = new ControllerTypeCache();

    [...]

    public virtual IController CreateController(RequestContext requestContext, string controllerName) 
    {
        [...]
        RequestContext = requestContext;
        Type controllerType = GetControllerType(controllerName);
        IController controller = GetControllerInstance(controllerType);
        return controller;
    }

    protected internal virtual IController GetControllerInstance(Type controllerType) 
    {
        [...]
        try {
            return (IController)Activator.CreateInstance(controllerType);
        }
        catch (Exception ex) {
            throw new InvalidOperationException(
                String.Format(
                    CultureInfo.CurrentUICulture,
                    MvcResources.DefaultControllerFactory_ErrorCreatingController,
                    controllerType),
                ex);
        }
    }

    protected internal virtual Type GetControllerType(string controllerName) 
    {
        [...]

        // first search in the current route's namespace collection
        object routeNamespacesObj;
        Type match;
        [...]

        // then search in the application's default namespace collection
        [...]

        // if all else fails, search every namespace
        return GetControllerTypeWithinNamespaces(controllerName, null /* namespaces */);
    }

    private Type GetControllerTypeWithinNamespaces(string controllerName, HashSet&amp;lt;string&amp;gt; namespaces) 
    {
        // Once the master list of controllers has been created we can quickly index into it
        ControllerTypeCache.EnsureInitialized(BuildManager);

        IList&amp;lt;Type&amp;gt; matchingTypes = ControllerTypeCache.GetControllerTypes(controllerName, namespaces);
        switch (matchingTypes.Count) {
            case 0:
                // no matching types
                return null;

            case 1:
                // single matching type
                return matchingTypes[0];

            default:
                // multiple matching types
                // we need to generate an exception containing all the controller types
                StringBuilder sb = new StringBuilder();
                foreach (Type matchedType in matchingTypes) {
                    sb.AppendLine();
                    sb.Append(matchedType.FullName);
                }
                throw new InvalidOperationException([...]);
        }
    }

}&lt;/pre&gt;As soon as the &lt;em&gt;DefaultControllerFactory.CreateController&lt;/em&gt; function, it finds the type of the controller by its name and creates an instance after that. The framework uses the &lt;em&gt;&lt;strong&gt;ControllerTypeCache&lt;/strong&gt;&lt;/em&gt; class to find the controller types. &lt;br /&gt;
&lt;pre class="brush: csharp; gutter: false; toolbar: false;"&gt;internal sealed class ControllerTypeCache 
{
    [...]

    public void EnsureInitialized(IBuildManager buildManager) 
    {
        if (_cache == null) {
            lock (_lockObj) {
                if (_cache == null) {
                    List&amp;lt;Type&amp;gt; controllerTypes = GetAllControllerTypes(buildManager);
                    [...]
                }
            }
        }
    }

    private static List&amp;lt;Type&amp;gt; GetAllControllerTypes(IBuildManager buildManager) 
    {
        // Go through all assemblies referenced by the application and search for
        // controllers and controller factories.
        List&amp;lt;Type&amp;gt; controllerTypes = new List&amp;lt;Type&amp;gt;();
        ICollection assemblies = buildManager.GetReferencedAssemblies();
        foreach (Assembly assembly in assemblies) {
            Type[] typesInAsm;
            try {
                typesInAsm = assembly.GetTypes();
            }
            catch (ReflectionTypeLoadException ex) {
                typesInAsm = ex.Types;
            }
            controllerTypes.AddRange(typesInAsm.Where(IsControllerType));
        }
        return controllerTypes;
    }

    [...]

    internal static bool IsControllerType(Type t) {
        return
            t != null &amp;amp;&amp;amp;
            t.IsPublic &amp;amp;&amp;amp;
            t.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp;
            !t.IsAbstract &amp;amp;&amp;amp;
            typeof(IController).IsAssignableFrom(t);
    }
}&lt;/pre&gt;The &lt;em&gt;ControllerTypeCache.EnsureInitialized&lt;/em&gt; (called by &lt;em&gt;DefaultControllerFactory.GetControllerTypeWithinNamespaces&lt;/em&gt;) uses the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.compilation.buildmanager.aspx" target="_blank"&gt;BuildManager&lt;/a&gt; class (in MVC, wrapped by &lt;em&gt;BuildManagerWrapper&lt;/em&gt; that implements the internal &lt;em&gt;IBuildManager&lt;/em&gt; interface) to find the available assemblies. The &lt;em&gt;ControllerTypeCache.GetAllControllerTypes&lt;/em&gt; returns the controller types referenced by the project. A class is a controller type if the class is&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;public &lt;/li&gt;
&lt;li&gt;its name ends with “Controller”, casing is ignored &lt;/li&gt;
&lt;li&gt;the type is not abstract &lt;/li&gt;
&lt;li&gt;the type “implements” (can be assigned to) the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.icontroller.aspx" target="_blank"&gt;IController&lt;/a&gt; interface. &lt;/li&gt;
&lt;/ul&gt;Finally the &lt;em&gt;DefaultControllerFactory.GetControllerInstance&lt;/em&gt; creates the instance for the Type using &lt;a href="http://msdn.microsoft.com/en-us/library/wccyzw83.aspx" target="_blank"&gt;&lt;em&gt;Activator.CreateInstance()&lt;/em&gt;&lt;/a&gt; method. Now we have the controller instance to work with.&lt;br /&gt;
The &lt;em&gt;MvcHandler.ProcessRequest()&lt;/em&gt; calls the &lt;em&gt;controller.Execute()&lt;/em&gt; to run the controller code.&lt;br /&gt;
&lt;a href="http://s63.photobucket.com/albums/h134/artur02/Blog/?action=view&amp;amp;current=80d84305.png" target="_blank"&gt;&lt;img alt="ASP.NET MVC Finding Controller" border="0" src="http://i63.photobucket.com/albums/h134/artur02/Blog/th_80d84305.png" /&gt;&lt;/a&gt; &lt;br /&gt;
Link: &lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/80d84305.png" target="_blank"&gt;ASP.NET MVC – Finding the controller&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-4539859615961424893?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9x1jJzZr_1s:ltNRlCNqI9Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9x1jJzZr_1s:ltNRlCNqI9Q:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=9x1jJzZr_1s:ltNRlCNqI9Q:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9x1jJzZr_1s:ltNRlCNqI9Q:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=9x1jJzZr_1s:ltNRlCNqI9Q:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9x1jJzZr_1s:ltNRlCNqI9Q:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/4539859615961424893/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2011/09/aspnet-mvc-internals-2-controller.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4539859615961424893?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4539859615961424893?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/9x1jJzZr_1s/aspnet-mvc-internals-2-controller.html" title="ASP.NET MVC Internals 2: Controller" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_80d84305.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2011/09/aspnet-mvc-internals-2-controller.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUMQnsyfyp7ImA9WhdVEkU.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-2715534065769580403</id><published>2011-09-15T10:11:00.001+02:00</published><updated>2011-09-17T20:14:43.597+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-17T20:14:43.597+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><title>ASP.NET MVC Internals 1: Bootstrapping</title><content type="html">&lt;p&gt;The topic of this article is the ASP.NET MVC bootstrapping process.&lt;/p&gt;&lt;p&gt;Everything starts in &lt;strong&gt;Global.asax&lt;/strong&gt;:&lt;/p&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:795f1de5-a86c-43dd-b1b2-1ff40b358afe" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;gutter:false;toolbar:false;"&gt;public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

    }

    protected void Application_Start()
    {
        RegisterRoutes(RouteTable.Routes);
    }
}&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This code initializes the ASP.NET Routing framework. The MapRoute() function is an extension method, defined in &lt;strong&gt;RouteCollectionExtensions.cs&lt;/strong&gt;. It’s code is simple:&lt;/p&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:984baf9e-d0f4-4ab5-8eec-0df8ecacf521" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;toolbar:false;"&gt;public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces) {
	if (routes == null) {
		throw new ArgumentNullException("routes");
	}
	if (url == null) {
		throw new ArgumentNullException("url");
	}

	Route route = new Route(url, new MvcRouteHandler()) {
		Defaults = new RouteValueDictionary(defaults),
		Constraints = new RouteValueDictionary(constraints)
	};

	if ((namespaces != null) &amp;amp;&amp;amp; (namespaces.Length &amp;gt; 0)) {
		route.DataTokens = new RouteValueDictionary();
		route.DataTokens["Namespaces"] = namespaces;
	}

	routes.Add(name, route);

	return route;
}&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Simply creates a route with an MvcRouteHandler at line 9. ASP.NET MVC registers this routing handler to catch the routing requests (&lt;strong&gt;MvcRouteHandler.cs&lt;/strong&gt;):&lt;/p&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:dc078b00-3c45-4e1d-944a-151f58006284" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;gutter:false;toolbar:false;"&gt;namespace System.Web.Mvc {
    using System.Web.Routing;

    public class MvcRouteHandler : IRouteHandler {
        protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext) {
            return new MvcHandler(requestContext);
        }

        #region IRouteHandler Members
        IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) {
            return GetHttpHandler(requestContext);
        }
        #endregion
    }
}&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This code registers the MvcHandler class (&lt;strong&gt;MvcHandler.cs&lt;/strong&gt;) for handling MVC routing requests:&lt;/p&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:e22c9dd9-8d14-48ee-ac83-7183e35a997f" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;gutter:false;toolbar:false;"&gt;public class MvcHandler : IHttpHandler, IRequiresSessionState 
{ [...] }&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The class implements the &lt;a href="http://msdn.microsoft.com/en-us/library/7ezc17x8.aspx" target="_blank"&gt;IHttpHandler&lt;/a&gt; interface from System.Web.dll to be able to ‘synchronously process HTTP Web requests using custom HTTP handlers’. This interface has only one method: &lt;/p&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:b7435f46-307c-478a-848b-0268d0674fb1" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;gutter:false;toolbar:false;"&gt;void ProcessRequest(httpContext context)&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The implementation of this method will handle the HTTP request. It builds up the MVC infrastructure and calls the appropriate classes (in transitive way) to select the controller, find the action method and do all the related functionality.&lt;/p&gt;&lt;p&gt;&lt;a href="http://s63.photobucket.com/albums/h134/artur02/Blog/?action=view&amp;amp;current=f63d836e.png" target="_blank"&gt;&lt;img src="http://i63.photobucket.com/albums/h134/artur02/Blog/th_f63d836e.png" border="0" alt="Photobucket" &gt;&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;Link: &lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/f63d836e.png" target="_blank"&gt;ASP.MET MVC Bootstrapping process&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-2715534065769580403?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cd9pN8HUS5A:QnOBsbIXbwo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cd9pN8HUS5A:QnOBsbIXbwo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=cd9pN8HUS5A:QnOBsbIXbwo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cd9pN8HUS5A:QnOBsbIXbwo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=cd9pN8HUS5A:QnOBsbIXbwo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cd9pN8HUS5A:QnOBsbIXbwo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/2715534065769580403/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2011/09/aspnet-mvc-internals-1.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2715534065769580403?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2715534065769580403?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/cd9pN8HUS5A/aspnet-mvc-internals-1.html" title="ASP.NET MVC Internals 1: Bootstrapping" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_f63d836e.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2011/09/aspnet-mvc-internals-1.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UDRnY6eyp7ImA9Wx9REUo.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-9138791909410880456</id><published>2010-12-12T18:34:00.001+01:00</published><updated>2010-12-12T18:34:37.813+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-12T18:34:37.813+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Internet" /><title>jQuery and DOM dimension measurement</title><content type="html">&lt;p&gt;I had to rewrite a code that used standard DOM functions (like offsetWidth) to jQuery functions (like outerWidth).    &lt;br /&gt;This is a simple document visually summarizing the differences.&lt;/p&gt;  &lt;p&gt;Link: &lt;a href="http://code.google.com/p/artur02/source/browse/trunk/docs/jQueryHtmlHeight/jQueryHtmlHeight.docx?r=10" target="_blank"&gt;jQuery HMTL with height cheat sheet (DOCX)&lt;/a&gt;     &lt;br /&gt;Link: &lt;a href="http://code.google.com/p/artur02/source/browse/trunk/docs/jQueryHtmlHeight/jQueryHtmlHeight.pdf?r=10" target="_blank"&gt;jQuery HMTL with height cheat sheet (PDF)&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-9138791909410880456?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=LIN1WaZ3X7E:cHBSiQCoAz4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=LIN1WaZ3X7E:cHBSiQCoAz4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=LIN1WaZ3X7E:cHBSiQCoAz4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=LIN1WaZ3X7E:cHBSiQCoAz4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=LIN1WaZ3X7E:cHBSiQCoAz4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=LIN1WaZ3X7E:cHBSiQCoAz4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/9138791909410880456/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/12/jquery-and-dom-dimension-measurement.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/9138791909410880456?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/9138791909410880456?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/LIN1WaZ3X7E/jquery-and-dom-dimension-measurement.html" title="jQuery and DOM dimension measurement" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/12/jquery-and-dom-dimension-measurement.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UBQXk9fCp7ImA9Wx9TFEg.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-4157840089121160363</id><published>2010-11-22T21:54:00.001+01:00</published><updated>2010-11-22T21:54:10.764+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-22T21:54:10.764+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>WaitableTimer in C++</title><content type="html">&lt;p&gt;This is an example code for calling a &lt;strong&gt;waitable timer&lt;/strong&gt;. This is a good way to wait for a timer event without using CPU (thread blocks). There is a small &lt;strong&gt;trick in the code&lt;/strong&gt;. It’s hard to create a FILETIME properly so I create a SYSTEMTIME (and set it according to my needs), convert it to FILETIME, finally I cast that to LARGE_INTEGER* (to fulfill the needs of SetWaitableTimer).&lt;/p&gt;  &lt;p&gt;I set the timer to &lt;strong&gt;autoreset&lt;/strong&gt;, so it will restart counting after firing the event (counts again and again). The first event (“CALLED”) occurs after 3 secs, the subsequent events occur after 2 secs.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;WaitForSingleObject&lt;/strong&gt; blocks until a timer event is fired. I break the loop after 5 events, stop the timer and delete the timer handle.&lt;/p&gt;    &lt;h3&gt;stdafx.h&lt;/h3&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #cc6633"&gt;#pragma&lt;/span&gt; &lt;span style="color: #cc6633"&gt;once&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;targetver.h&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;tchar.h&amp;gt;&lt;br /&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;Windows.h&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h3&gt;WaitableTimer.cpp&lt;/h3&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;stdafx.h&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; _tmain(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; argc, _TCHAR* argv[])&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; count = 0;    &lt;span style="color: #008000"&gt;// Iteration counter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    HANDLE hTimer = NULL;    &lt;span style="color: #008000"&gt;// WaitableTimer handle&lt;/span&gt;&lt;br /&gt;    hTimer = CreateWaitableTimer(    &lt;span style="color: #008000"&gt;// Create waitable timer&lt;/span&gt;&lt;br /&gt;        NULL,&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;FALSE&lt;/span&gt;,    &lt;span style="color: #008000"&gt;// Autoreset --&amp;gt; timer restarts counting after event fired&lt;/span&gt;&lt;br /&gt;        NULL);&lt;br /&gt;&lt;br /&gt;    SYSTEMTIME time;        &lt;span style="color: #008000"&gt;// System time structure&lt;/span&gt;&lt;br /&gt;    GetSystemTime(&amp;amp;time);    &lt;span style="color: #008000"&gt;// Curren time&lt;/span&gt;&lt;br /&gt;    time.wSecond += 3;        &lt;span style="color: #008000"&gt;// Wait 3 sec&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    FILETIME ftime;    &lt;span style="color: #008000"&gt;// File time (expected by SetWaitableTimer)&lt;/span&gt;&lt;br /&gt;    SystemTimeToFileTime(&amp;amp;time, &amp;amp;ftime);    &lt;span style="color: #008000"&gt;// Convert system to file time&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!SetWaitableTimer(    &lt;span style="color: #008000"&gt;// Set waitable timer&lt;/span&gt;&lt;br /&gt;        hTimer,    &lt;span style="color: #008000"&gt;// Timer handle&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;reinterpret_cast&lt;/span&gt;&amp;lt;LARGE_INTEGER*&amp;gt;(&amp;amp;ftime),    &lt;span style="color: #008000"&gt;// Convert file time to large integer&lt;/span&gt;&lt;br /&gt;        2000,    &lt;span style="color: #008000"&gt;// Period time, fire again after 2 sec&lt;/span&gt;&lt;br /&gt;        NULL,&lt;br /&gt;        NULL,&lt;br /&gt;        0))&lt;br /&gt;    {&lt;br /&gt;            cout &amp;lt;&amp;lt; &lt;span style="color: #006080"&gt;&amp;quot;SetWaitableTimer failed&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt;  GetLastError() &amp;lt;&amp;lt; endl;&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;(WaitForSingleObject(hTimer, 5000) == WAIT_OBJECT_0){    &lt;span style="color: #008000"&gt;// Wait for timer event&lt;/span&gt;&lt;br /&gt;        cout &amp;lt;&amp;lt; &lt;span style="color: #006080"&gt;&amp;quot;CALLED &amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; ++count &amp;lt;&amp;lt; endl;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(count+1 &amp;gt; 5){    &lt;span style="color: #008000"&gt;// Exit after 5 events&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;break&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;        &lt;br /&gt;    CancelWaitableTimer(hTimer);    &lt;span style="color: #008000"&gt;// Stop timer&lt;/span&gt;&lt;br /&gt;    CloseHandle(hTimer);            &lt;span style="color: #008000"&gt;// Delete handle&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;See source code&lt;/strong&gt;: &lt;a href="http://code.google.com/p/artur02/source/browse/trunk/CPP/WaitableTimer/WaitableTimer.cpp"&gt;http://code.google.com/p/artur02/source/browse/trunk/CPP/WaitableTimer/WaitableTimer.cpp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Waitable timer objects: &lt;a href="http://msdn.microsoft.com/en-us/library/ms687012(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms687012(VS.85).aspx&lt;/a&gt;

  &lt;br /&gt;CreateWaitableTimer function: &lt;a href="http://msdn.microsoft.com/en-us/library/ms682492(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms682492(v=VS.85).aspx&lt;/a&gt;

  &lt;br /&gt;SetWaitableTimer function: &lt;a href="http://msdn.microsoft.com/en-us/library/ms686289(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms686289(v=VS.85).aspx&lt;/a&gt;

  &lt;br /&gt;Systemtime structure: &lt;a href="http://msdn.microsoft.com/en-us/library/ms687008(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms687008(v=VS.85).aspx&lt;/a&gt;

  &lt;br /&gt;Usage example: &lt;a href="http://msdn.microsoft.com/en-us/library/ms687008(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms687008(v=VS.85).aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-4157840089121160363?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=fALS4d03NDg:HUjjOaMouo0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=fALS4d03NDg:HUjjOaMouo0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=fALS4d03NDg:HUjjOaMouo0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=fALS4d03NDg:HUjjOaMouo0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=fALS4d03NDg:HUjjOaMouo0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=fALS4d03NDg:HUjjOaMouo0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/4157840089121160363/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/11/waitabletimer-in-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4157840089121160363?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4157840089121160363?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/fALS4d03NDg/waitabletimer-in-c.html" title="WaitableTimer in C++" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/11/waitabletimer-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MHQHszfSp7ImA9Wx5aEEk.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-2336633939422852102</id><published>2010-11-06T12:03:00.001+01:00</published><updated>2010-11-06T12:03:51.585+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-06T12:03:51.585+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>Perforce file exclusion</title><content type="html">&lt;p&gt;There are file types and folders I don’t want to see in a source control repository. These are user-specific settings, temporary folders and binaries. There is a simple client-side way to exclude these files and folders. Just add the following lines to your workspace definition:&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="598"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="363"&gt;&lt;strong&gt;Pattern&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="233"&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="363"&gt;         &lt;pre&gt;-//depot/.../*.suo //WORKSPACE/.../*.suo&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="233"&gt;Solution user options file.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="363"&gt;
        &lt;pre&gt;-//depot/.../bin/... //WORKSPACE/.../bin/...&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="233"&gt;Generated binaries.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="363"&gt;
        &lt;pre&gt;-//depot/.../obj/... //WORKSPACE/.../obj/...&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="233"&gt;Object files.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="363"&gt;
        &lt;pre&gt;-//depot/.../*.user //WORKSPACE/.../*.user&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="233"&gt;User settings. Can contain useful information, e.g. startup parameters.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-2336633939422852102?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dAmx8sSPlEM:a9TynD0R5yA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dAmx8sSPlEM:a9TynD0R5yA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=dAmx8sSPlEM:a9TynD0R5yA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dAmx8sSPlEM:a9TynD0R5yA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=dAmx8sSPlEM:a9TynD0R5yA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dAmx8sSPlEM:a9TynD0R5yA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/2336633939422852102/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/11/perforce-file-exclusion.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2336633939422852102?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2336633939422852102?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/dAmx8sSPlEM/perforce-file-exclusion.html" title="Perforce file exclusion" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/11/perforce-file-exclusion.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAASX87eCp7ImA9Wx5aEEk.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-5084535758128752632</id><published>2010-11-06T11:51:00.001+01:00</published><updated>2010-11-06T11:52:28.100+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-06T11:52:28.100+01:00</app:edited><title>CV Tag Cloud</title><content type="html">&lt;p&gt;&lt;a href="http://www.wordle.net/show/wrdl/2686570/CV" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" border="0" src="http://i63.photobucket.com/albums/h134/artur02/Blog/6466b550.png" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The tag cloud of my CV. Can be viewed in full size: &lt;a href="http://www.wordle.net/show/wrdl/2686570/CV"&gt;http://www.wordle.net/show/wrdl/2686570/CV&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-5084535758128752632?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=ew1y8yDAPvQ:KsmNXDspDhM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=ew1y8yDAPvQ:KsmNXDspDhM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=ew1y8yDAPvQ:KsmNXDspDhM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=ew1y8yDAPvQ:KsmNXDspDhM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=ew1y8yDAPvQ:KsmNXDspDhM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=ew1y8yDAPvQ:KsmNXDspDhM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/5084535758128752632/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/11/cv-tag-cloud.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5084535758128752632?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5084535758128752632?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/ew1y8yDAPvQ/cv-tag-cloud.html" title="CV Tag Cloud" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_6466b550.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/11/cv-tag-cloud.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UARHw6fip7ImA9Wx5bFU4.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-2515990663665082279</id><published>2010-10-31T15:19:00.001+01:00</published><updated>2010-10-31T15:27:25.216+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-31T15:27:25.216+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Simple Map Reduce Example in C#</title><content type="html">&lt;p&gt;This is an example of map-reduce implementation for IEnumerable. This code is not optimized. I think we shouldn’t create separate Task for each enumerated item. Probably partitioning the enumeration and dealing with bigger chunks of data would be much more efficient.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Browse source code&lt;/strong&gt;: &lt;a href="http://code.google.com/p/artur02/source/browse/#svn/trunk/MapReduce" target="_blank"&gt;Google Code&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;MapReduce function for IEnumerable:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Collections;

namespace MapReduceCode
{
    public static class MapReduce
    {
        public static Task&amp;lt;TResult&amp;gt; ForEachParallel&amp;lt;TItem, TSubResult, TResult, TParam&amp;gt;(this IEnumerable items, Func&amp;lt;TItem, TParam, TSubResult&amp;gt; map, Func&amp;lt;TSubResult[], TResult&amp;gt; reduce, TParam &lt;span class="kwrd"&gt;param&lt;/span&gt;)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (items == null) { &lt;span class="kwrd"&gt;throw&lt;/span&gt; new ArgumentNullException(&lt;span class="str"&gt;&amp;quot;items&amp;quot;&lt;/span&gt;); }
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (map == null) { &lt;span class="kwrd"&gt;throw&lt;/span&gt; new ArgumentNullException(&lt;span class="str"&gt;&amp;quot;map&amp;quot;&lt;/span&gt;); }
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (reduce == null) { &lt;span class="kwrd"&gt;throw&lt;/span&gt; new ArgumentNullException(&lt;span class="str"&gt;&amp;quot;reduce&amp;quot;&lt;/span&gt;); }

            &lt;span class="kwrd"&gt;return&lt;/span&gt; Task&amp;lt;TResult&amp;gt;.Factory.StartNew(() =&amp;gt;
            {
                List&amp;lt;Task&amp;lt;TSubResult&amp;gt;&amp;gt; tasks = new List&amp;lt;Task&amp;lt;TSubResult&amp;gt;&amp;gt;();

                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (TItem item &lt;span class="kwrd"&gt;in&lt;/span&gt; items)
                {
                    Task&amp;lt;TSubResult&amp;gt; t = Task&amp;lt;TSubResult&amp;gt;.Factory.StartNew(item2 =&amp;gt;
                        {
                            var mparam = (Tuple&amp;lt;TItem, TParam&amp;gt;)item2;
                            &lt;span class="kwrd"&gt;return&lt;/span&gt; map(mparam.Item1, mparam.Item2);
                        },
                        new Tuple&amp;lt;TItem, TParam&amp;gt;(item, &lt;span class="kwrd"&gt;param&lt;/span&gt;),
                        TaskCreationOptions.None | TaskCreationOptions.AttachedToParent);
                    tasks.Add(t);
                }

                List&amp;lt;TSubResult&amp;gt; results = new List&amp;lt;TSubResult&amp;gt;();
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Task&amp;lt;TSubResult&amp;gt; task &lt;span class="kwrd"&gt;in&lt;/span&gt; tasks)
                {
                    results.Add(task.Result);
                }

                &lt;span class="kwrd"&gt;return&lt;/span&gt; reduce(results.ToArray());
            });
        }
    }
}&lt;/pre&gt;

&lt;p&gt;Usage example: &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections;
&lt;span class="kwrd"&gt;using&lt;/span&gt; MapReduceCode;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Threading;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Threading.Tasks;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MapReduce
{
    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program
    {
        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)
        {
            var a = Generate().ForEachParallel&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;(
                (element, param)=&amp;gt; 
                {
                    var result = element * param;
                    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Map: {0}, {1}&amp;quot;&lt;/span&gt;, result, Task.CurrentId);
                    Thread.Sleep(&lt;span class="kwrd"&gt;new&lt;/span&gt; Random(DateTime.Now.Millisecond).Next(500));
                    &lt;span class="kwrd"&gt;return&lt;/span&gt; result;
                }, 
                (subresult)=&amp;gt;
                {
                    var sum = 0;
                    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var item &lt;span class="kwrd"&gt;in&lt;/span&gt; subresult)
                    {
                        sum += item;
                    }
                    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Reduce: {0}&amp;quot;&lt;/span&gt;, sum);
                    &lt;span class="kwrd"&gt;return&lt;/span&gt; sum;
                }, 
                5);

            Console.WriteLine(a.Result);
            
        }

        &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable Generate()
        {
            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 100; i++)
            {
                &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; i;
            }
        }
    }
}&lt;/pre&gt;
&lt;style type="text/css"&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;/style&gt;&lt;style type="text/css"&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;/style&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;Map: 0, 1
    &lt;br /&gt;Map: 5, 2

    &lt;br /&gt;Map: 10, 3

    &lt;br /&gt;Map: 20, 4

    &lt;br /&gt;Map: 15, 5

    &lt;br /&gt;Map: 25, 6

    &lt;br /&gt;Map: 30, 7

    &lt;br /&gt;Map: 35, 8

    &lt;br /&gt;Map: 40, 9

    &lt;br /&gt;Map: 45, 10

    &lt;br /&gt;Map: 50, 11

    &lt;br /&gt;Map: 55, 12

    &lt;br /&gt;Map: 60, 13

    &lt;br /&gt;Map: 65, 14

    &lt;br /&gt;Map: 70, 15

    &lt;br /&gt;Map: 75, 16

    &lt;br /&gt;Map: 80, 17

    &lt;br /&gt;Map: 85, 18

    &lt;br /&gt;Map: 90, 19

    &lt;br /&gt;Map: 95, 20

    &lt;br /&gt;Map: 100, 21

    &lt;br /&gt;Map: 105, 22

    &lt;br /&gt;Map: 110, 23

    &lt;br /&gt;Map: 115, 24

    &lt;br /&gt;Map: 120, 25

    &lt;br /&gt;Map: 125, 26

    &lt;br /&gt;Map: 130, 27

    &lt;br /&gt;Map: 135, 28

    &lt;br /&gt;Map: 140, 29

    &lt;br /&gt;Map: 145, 30

    &lt;br /&gt;Map: 150, 31

    &lt;br /&gt;Map: 155, 32

    &lt;br /&gt;Map: 160, 33

    &lt;br /&gt;Map: 165, 34

    &lt;br /&gt;Map: 170, 35

    &lt;br /&gt;Map: 175, 36

    &lt;br /&gt;Map: 180, 37

    &lt;br /&gt;Map: 185, 38

    &lt;br /&gt;Map: 190, 39

    &lt;br /&gt;Map: 195, 40

    &lt;br /&gt;Map: 200, 41

    &lt;br /&gt;Map: 205, 42

    &lt;br /&gt;Map: 210, 43

    &lt;br /&gt;Map: 215, 44

    &lt;br /&gt;Map: 225, 45

    &lt;br /&gt;&lt;em&gt;&lt;strong&gt;Map: 230, 47&lt;/strong&gt;

      &lt;br /&gt;&lt;/em&gt;Map: 220, 46

    &lt;br /&gt;Map: 235, 48

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 245, 50&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 240, 49

    &lt;br /&gt;Map: 250, 51

    &lt;br /&gt;Map: 255, 52

    &lt;br /&gt;Map: 260, 53

    &lt;br /&gt;Map: 265, 54

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 275, 56
        &lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;Map: 270, 55

    &lt;br /&gt;Map: 285, 57

    &lt;br /&gt;Map: 280, 58

    &lt;br /&gt;Map: 290, 59

    &lt;br /&gt;Map: 295, 60

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 300, 62&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 305, 61

    &lt;br /&gt;Map: 310, 63

    &lt;br /&gt;Map: 315, 64

    &lt;br /&gt;Map: 320, 65

    &lt;br /&gt;Map: 325, 66

    &lt;br /&gt;Map: 330, 67

    &lt;br /&gt;Map: 335, 68

    &lt;br /&gt;Map: 340, 69

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 355, 72&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 350, 71

    &lt;br /&gt;Map: 360, 73

    &lt;br /&gt;Map: 365, 74

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 345, 70&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 370, 75

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 380, 77&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 375, 76

    &lt;br /&gt;Map: 390, 79

    &lt;br /&gt;Map: 395, 80

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 385, 78&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 400, 81

    &lt;br /&gt;Map: 405, 82

    &lt;br /&gt;Map: 415, 84

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 425, 86
        &lt;br /&gt;Map: 410, 83&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 420, 85

    &lt;br /&gt;Map: 430, 87

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 440, 89&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 435, 88

    &lt;br /&gt;Map: 450, 90

    &lt;br /&gt;Map: 445, 91

    &lt;br /&gt;Map: 455, 92

    &lt;br /&gt;Map: 460, 93

    &lt;br /&gt;Map: 470, 95

    &lt;br /&gt;Map: 480, 97

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 475, 96&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 485, 98

    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Map: 465, 94&lt;/em&gt;&lt;/strong&gt;

    &lt;br /&gt;Map: 490, 99

    &lt;br /&gt;Map: 495, 100

    &lt;br /&gt;Reduce: 24750

    &lt;br /&gt;24750&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-2515990663665082279?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=AMqkNRmXQfM:bccnqg2P-OU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=AMqkNRmXQfM:bccnqg2P-OU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=AMqkNRmXQfM:bccnqg2P-OU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=AMqkNRmXQfM:bccnqg2P-OU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=AMqkNRmXQfM:bccnqg2P-OU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=AMqkNRmXQfM:bccnqg2P-OU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/2515990663665082279/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/10/simple-map-reduce-example-in-c.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2515990663665082279?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/2515990663665082279?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/AMqkNRmXQfM/simple-map-reduce-example-in-c.html" title="Simple Map Reduce Example in C#" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/10/simple-map-reduce-example-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIHQHcycSp7ImA9WxFXEkU.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-8407657171768765254</id><published>2010-05-19T18:28:00.001+02:00</published><updated>2010-05-19T18:28:51.999+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-19T18:28:51.999+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>CAL and AutoMapper</title><content type="html">&lt;p&gt;I’m using &lt;strong&gt;Composite Application Library&lt;/strong&gt; (CAL) in a project. I decided to use &lt;strong&gt;AutoMapper&lt;/strong&gt; as well. I put AutoMapper’s &lt;em&gt;Mapper.CreateMap&amp;lt;source, dest&amp;gt;()&lt;/em&gt; calls into one of the &lt;em&gt;Bootstrapper.cs&lt;/em&gt; methods. I got an &lt;strong&gt;InvalidOperationException in the ModuleCatalog’s InnerLoad()&lt;/strong&gt; function.&lt;/p&gt;  &lt;h3&gt;Reason&lt;/h3&gt;  &lt;p&gt;AutoMapper creates an in-memory assembly and CAL tries to read all the assemblies’ &lt;em&gt;Location&lt;/em&gt; property. This property raises an InvalidOperationException in case of in-memory assemblies.&lt;/p&gt;  &lt;h3&gt;Solution&lt;/h3&gt;  &lt;p&gt;Insert AutoMapper mappings right after the &lt;em&gt;Bootstrapper.Run()&lt;/em&gt; call. In my case I call this in &lt;em&gt;App.xaml.cs&lt;/em&gt;, so you can write the following:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnStartup(StartupEventArgs e)
{
    &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnStartup(e);

    &lt;span class="rem"&gt;// Run bootstrapper&lt;/span&gt;
    Bootstrapper bootstrapper = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bootstrapper();
    bootstrapper.Run();

    &lt;span class="rem"&gt;// AutoMapper mappings&lt;/span&gt;
    Parallel.Invoke(CreateAutoMapperMappings);
}

&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// Creates the AutoMapper mappings.&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CreateAutoMapperMappings()
{
    Mapper.CreateMap&amp;lt;Source, Dest&amp;gt;();
}&lt;/pre&gt;
&lt;style type="text/css"&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;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-8407657171768765254?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=zoPTknMAaB8:3oiggCUjQ8o:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=zoPTknMAaB8:3oiggCUjQ8o:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=zoPTknMAaB8:3oiggCUjQ8o:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=zoPTknMAaB8:3oiggCUjQ8o:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=zoPTknMAaB8:3oiggCUjQ8o:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=zoPTknMAaB8:3oiggCUjQ8o:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/8407657171768765254/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/05/cal-and-automapper.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/8407657171768765254?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/8407657171768765254?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/zoPTknMAaB8/cal-and-automapper.html" title="CAL and AutoMapper" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/05/cal-and-automapper.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEENRH48fyp7ImA9WxFQGEo.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-4421392213878580628</id><published>2010-05-14T23:31:00.001+02:00</published><updated>2010-05-14T23:31:35.077+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-14T23:31:35.077+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="F#" /><title>F#: Piping and Composition</title><content type="html">&lt;p&gt;Piping and compositions are very expressive tools in F#. It significantly improves code readability. &lt;/p&gt;  &lt;p&gt;Let’s have the following functions:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; let square x = x*x;;      &lt;br /&gt;val square : int -&amp;gt; int &lt;/p&gt;    &lt;p&gt;&amp;gt; let negate x = -x;;      &lt;br /&gt;val negate : int –&amp;gt; int&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Function &lt;em&gt;square&lt;/em&gt; returns the square of x, while &lt;em&gt;negate&lt;/em&gt; returns the negated value of x. &lt;/p&gt;  &lt;p&gt;We can calculate square(negate(10)) as follows:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; let x = negate 10;;      &lt;br /&gt;val x : int = –10&lt;/p&gt;    &lt;p&gt;&amp;gt; let x = square x;;      &lt;br /&gt;val x : int = 100&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Or a simpler way:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; let x = square (negate 10);;      &lt;br /&gt;val x : int = 100&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/h3&gt;  &lt;h3&gt;&lt;strong&gt;Piping&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;We can define piping as symbol-named function definition that simply applies two functions in reverse order:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;let (|&amp;gt;) f x =      &lt;br /&gt;&amp;#160; x f&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The example with piping:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; 10 |&amp;gt; negate |&amp;gt; square;;      &lt;br /&gt;val it : int = 100&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;That means ((10 negate) square) –&amp;gt; (square (negate 10)). I used an integer (10) as &lt;em&gt;f&lt;/em&gt;. &lt;/p&gt;  &lt;h3&gt;Composition&lt;/h3&gt;  &lt;p&gt;Composition is a reverse-order function composition:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;let (&amp;gt;&amp;gt;) f g x =      &lt;br /&gt;&amp;#160; g(f x)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The example with composition:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; (negate &amp;gt;&amp;gt; square) 10;;      &lt;br /&gt;val it : int = 100&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;That means ((negate square) 10) –&amp;gt; (square (negate 10)).&lt;/p&gt;  &lt;h3&gt;Usage&lt;/h3&gt;  &lt;p&gt;The examples above are very simple ones. The real benefits of piping and composition reveal in case of function definitions and usage.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Pipes&lt;/strong&gt; can reverse parameter definition orders (like in 10 |&amp;gt; negate) and can help type inferring. When F# infers types, it evaluates from upper left corner to lover right corner of the text file, so sometimes it doesn't know the type of a function parameter. Pipe brings parameters forward.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Composition&lt;/strong&gt; can help omitting function parameter declaration. If the first function expects a parameter, the composed function expects it’s parameter.&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-4421392213878580628?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=c84C8YY3c14:tU90JYuqI-s:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=c84C8YY3c14:tU90JYuqI-s:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=c84C8YY3c14:tU90JYuqI-s:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=c84C8YY3c14:tU90JYuqI-s:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=c84C8YY3c14:tU90JYuqI-s:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=c84C8YY3c14:tU90JYuqI-s:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/4421392213878580628/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/05/f-piping-and-composition.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4421392213878580628?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4421392213878580628?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/c84C8YY3c14/f-piping-and-composition.html" title="F#: Piping and Composition" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/05/f-piping-and-composition.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkYBSH84fSp7ImA9WxFQEE0.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-5569859929436754087</id><published>2010-05-04T21:09:00.001+02:00</published><updated>2010-05-04T21:09:19.135+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-04T21:09:19.135+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>Database Comparison</title><content type="html">&lt;p&gt;I' am very interested in open source database comparisons. I found two interesting blog posts:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.ss.javaworld.in/sukhvindersingh" target="_blank"&gt;Sukhvinder Singh&lt;/a&gt; wrote about the &lt;a href="http://www.ss.javaworld.in/articles/design-concepts/database-comparison-table-h2-hsqldb-derby-postgresql-mysql" target="_blank"&gt;comparison of H2, HSQLDB, DERBY, PostgreSQL, MySQL&lt;/a&gt;.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://3rdstage.blogspot.com/" target="_blank"&gt;Thirdstage&lt;/a&gt; wrote about the comparison of about &lt;a href="http://3rdstage.blogspot.com/2009/03/comparion-of-hsqldb-h2-sqlite.html" target="_blank"&gt;HSQLDB, H2, SQLite&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Link: &lt;a href="http://www.ss.javaworld.in/articles/design-concepts/database-comparison-table-h2-hsqldb-derby-postgresql-mysql" target="_blank"&gt;H2, HSQLDB, DERBY, PostgreSQL, MySQL&lt;/a&gt;    &lt;br /&gt;Link: &lt;a href="http://3rdstage.blogspot.com/2009/03/comparion-of-hsqldb-h2-sqlite.html" target="_blank"&gt;HSQLDB, H2, SQLite&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-5569859929436754087?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=jnezJ8x-JqA:qb5PPoNxwVw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=jnezJ8x-JqA:qb5PPoNxwVw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=jnezJ8x-JqA:qb5PPoNxwVw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=jnezJ8x-JqA:qb5PPoNxwVw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=jnezJ8x-JqA:qb5PPoNxwVw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=jnezJ8x-JqA:qb5PPoNxwVw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/5569859929436754087/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/05/database-comparison.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5569859929436754087?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5569859929436754087?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/jnezJ8x-JqA/database-comparison.html" title="Database Comparison" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/05/database-comparison.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcAQ305cCp7ImA9WxFRF0Q.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-4501151035766918632</id><published>2010-05-02T11:54:00.001+02:00</published><updated>2010-05-02T11:54:02.328+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-02T11:54:02.328+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Get WPF DataGrid row and cell</title><content type="html">&lt;style type="text/css"&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;/style&gt;  &lt;p&gt;There are no simple built-in methods for accessing individual rows or columns in WPF DataGrid. The following code samples will provide simple methods for accessing these items. &lt;/p&gt;  &lt;p&gt;First of all we need a helper function for &lt;strong&gt;selecting a visual child&lt;/strong&gt;:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; T GetVisualChild&amp;lt;T&amp;gt;(Visual parent) &lt;span class="kwrd"&gt;where&lt;/span&gt; T : Visual
{
    T child = &lt;span class="kwrd"&gt;default&lt;/span&gt;(T);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; numVisuals = VisualTreeHelper.GetChildrenCount(parent);
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; numVisuals; i++)
    {
        Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
        child = v &lt;span class="kwrd"&gt;as&lt;/span&gt; T;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (child == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            child = GetVisualChild&amp;lt;T&amp;gt;(v);
        }
       &lt;span class="kwrd"&gt;if&lt;/span&gt; (child != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
       {
           &lt;span class="kwrd"&gt;break&lt;/span&gt;;
       }
   }
       &lt;span class="kwrd"&gt;return&lt;/span&gt; child;
}&lt;/pre&gt;

&lt;p&gt;There is a simple method for getting the &lt;strong&gt;current (selected) row&lt;/strong&gt; of the DataGrid:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DataGridRow GetSelectedRow(&lt;span class="kwrd"&gt;this&lt;/span&gt; DataGrid grid)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; (DataGridRow)grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem);
}&lt;/pre&gt;

&lt;p&gt;We can also get a &lt;strong&gt;row by its indices&lt;/strong&gt;:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DataGridRow GetRow(&lt;span class="kwrd"&gt;this&lt;/span&gt; DataGrid grid, &lt;span class="kwrd"&gt;int&lt;/span&gt; index)
{
    DataGridRow row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (row == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        &lt;span class="rem"&gt;// May be virtualized, bring into view and try again.&lt;/span&gt;
        grid.UpdateLayout();
        grid.ScrollIntoView(grid.Items[index]);
        row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; row;
}&lt;/pre&gt;

&lt;p&gt;Now we can &lt;strong&gt;get a cell&lt;/strong&gt; of a DataGrid by an existing row:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DataGridCell GetCell(&lt;span class="kwrd"&gt;this&lt;/span&gt; DataGrid grid, DataGridRow row, &lt;span class="kwrd"&gt;int&lt;/span&gt; column)
{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (row != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        DataGridCellsPresenter presenter = GetVisualChild&amp;lt;DataGridCellsPresenter&amp;gt;(row);

        &lt;span class="kwrd"&gt;if&lt;/span&gt; (presenter == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            grid.ScrollIntoView(row, grid.Columns[column]);
            presenter = GetVisualChild&amp;lt;DataGridCellsPresenter&amp;gt;(row);
        }

        DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; cell;
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;
}&lt;/pre&gt;

&lt;p&gt;Or we can simply select a &lt;strong&gt;row by its indices&lt;/strong&gt;:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DataGridCell GetCell(&lt;span class="kwrd"&gt;this&lt;/span&gt; DataGrid grid, &lt;span class="kwrd"&gt;int&lt;/span&gt; row, &lt;span class="kwrd"&gt;int&lt;/span&gt; column)
{
    DataGridRow rowContainer = grid.GetRow(row);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; grid.GetCell(rowContainer, column);
}&lt;/pre&gt;

&lt;p&gt;The functions above are extension methods. &lt;strong&gt;Their use is simple&lt;/strong&gt;:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var selectedRow = grid.GetSelectedRow();
var columnCell = grid.GetCell(selectedRow, 0);&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/artur02/source/browse/trunk/DataGridExtensions/DataGridHelper.cs" target="_blank"&gt;View source on Google Code (unformatted selection possible)&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-4501151035766918632?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=qmDEadAQD2I:pzCTi6100yA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=qmDEadAQD2I:pzCTi6100yA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=qmDEadAQD2I:pzCTi6100yA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=qmDEadAQD2I:pzCTi6100yA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=qmDEadAQD2I:pzCTi6100yA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=qmDEadAQD2I:pzCTi6100yA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/4501151035766918632/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/05/get-wpf-datagrid-row-and-cell.html#comment-form" title="20 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4501151035766918632?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4501151035766918632?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/qmDEadAQD2I/get-wpf-datagrid-row-and-cell.html" title="Get WPF DataGrid row and cell" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>20</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/05/get-wpf-datagrid-row-and-cell.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEDRnk5fyp7ImA9WxFSFUw.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-5126978408898582528</id><published>2010-04-17T16:31:00.001+02:00</published><updated>2010-04-17T16:31:17.727+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-17T16:31:17.727+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Mixed mode assemblies on .NET 4.0</title><content type="html">&lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I got this message when I tried to start a project migrated from .NET 3.5 to .NET 4.0. I case of migration, migration wizard inserts a &lt;font face="Courier New"&gt;&amp;lt;startup&amp;gt;&amp;lt;/startup&amp;gt;&lt;/font&gt; tag into the app.config file. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: insert the &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;useLegacyV2RuntimeActivationPolicy=&amp;quot;true&amp;quot;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;attribute into the &lt;font face="Courier New"&gt;startup&lt;/font&gt; tag. Application should work now.&lt;/p&gt;  &lt;p&gt;Reason: .NET 4.0 changed mixed mode assembly loading mechanisms. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-5126978408898582528?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=_jpTYzlBzmA:8AEZHd8ebr8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=_jpTYzlBzmA:8AEZHd8ebr8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=_jpTYzlBzmA:8AEZHd8ebr8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=_jpTYzlBzmA:8AEZHd8ebr8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=_jpTYzlBzmA:8AEZHd8ebr8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=_jpTYzlBzmA:8AEZHd8ebr8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/5126978408898582528/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/04/mixed-mode-assemblies-on-net-40.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5126978408898582528?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5126978408898582528?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/_jpTYzlBzmA/mixed-mode-assemblies-on-net-40.html" title="Mixed mode assemblies on .NET 4.0" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/04/mixed-mode-assemblies-on-net-40.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUERnw_cSp7ImA9WxFSFU0.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-6498687240108291726</id><published>2010-04-17T14:36:00.001+02:00</published><updated>2010-04-17T14:43:27.249+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-17T14:43:27.249+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="NHibernate" /><title>NHibernate session management</title><content type="html">&lt;p&gt;When you start working with NHibernate, you will see code examples like this one:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; userID = 1234;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt;( ISession session = sessionFactory.OpenSession() )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt;( session.BeginTransaction() ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    User user = session.Get&amp;lt;User&amp;gt;(userID); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    session.Transaction.Commit();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You get a session object, start a transaction and finally commit that. This is fine when you work in a simple one-layer application or you are OK with tight coupling. When you have multiple layers, or working with binding like in WPF, things get complicated.&lt;/p&gt;

&lt;h3&gt;Session management strategies&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Session per application&lt;/strong&gt; 

    &lt;br /&gt;Simplest approach. Just one session for the whole application, typically returned by a singleton. 

    &lt;br /&gt;&lt;em&gt;Problem&lt;/em&gt;: Async calls can interfere with each other, cache size grows, unrecoverable exceptions, stale data &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Session per screen&lt;/strong&gt; 

    &lt;br /&gt;New session for every form/view/… There are multiple concurrent sessions. 

    &lt;br /&gt;&lt;em&gt;Problem&lt;/em&gt;: You can keep a screen opened for a long time, so stale data is expectable. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Session per data access&lt;/strong&gt; 

    &lt;br /&gt;Every single data access uses a new session object. 

    &lt;br /&gt;&lt;em&gt;Problem&lt;/em&gt;: Lazy loading won’t work, problem with 1st level cache… &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Session per use-case&lt;/strong&gt; 

    &lt;br /&gt;You create a new session for every use-case. There will be concurrent sessions. &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Firs try: Following examples – Session per data access&lt;/h3&gt;

&lt;p&gt;I’ve created an application with the simplest solution possible. I followed the examples and whenever I tried to access data, I created a session and a transaction. Everything was fine, until I tried to employ lazy loading. It simply did not work. There was no open sessions the lazy loader proxy could have used.&lt;/p&gt;

&lt;h3&gt;Second try: Session per application&lt;/h3&gt;

&lt;p&gt;I modified the application. I created a singleton that returned a session object. Every single data access used this session. The application worked fine – for a while. I used SQLite as DBMS, and SQLite has not the best threading support. So I got exceptions randomly. Sometimes a control was empty, sometimes it was filled with data. Exceptions happened about 1 out of 15 tries. I suspected a threading issue and it seems it was.&lt;/p&gt;

&lt;h3&gt;Third try: Session per use-case&lt;/h3&gt;

&lt;p&gt;I had to implement a session per use-case (business transaction) solution to solve the problems above. A business transaction is a user-initiated action involving multiple complicated operations (steps). All operations (and the transaction itself) are either successful or unsuccessful. The state of the involved members are well-defined and consistent at the end of the transaction.&lt;/p&gt;

&lt;p&gt;We have to be able to keep alive the NHiberanate &lt;font face="Courier New"&gt;ISession&lt;/font&gt; object over multiple operations. The solution is the &lt;a href="http://www.martinfowler.com/eaaCatalog/unitOfWork.html" target="_blank"&gt;unit of work&lt;/a&gt; pattern. It encapsulates the &lt;font face="Courier New"&gt;ISession&lt;/font&gt; object, so we can pass it around and implement the &lt;font face="Courier New"&gt;IDisposable&lt;/font&gt; pattern. The class implementing the unit of work pattern can expose &lt;font face="Courier New"&gt;ISession&lt;/font&gt; functionality. See the example UML class diagram below.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/3508c3ca.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Illustration: Unit of Work" border="0" alt="Illustration: Unit of Work" src="http://i63.photobucket.com/albums/h134/artur02/Blog/3508c3ca.png" width="244" height="204" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;

&lt;p&gt;This is an example of calling the UnitOfWork object instance:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (UnitOfWork unitOfWork = database.CreateUnitOfWork())&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    PropertiesRepository propertiesRepository = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PropertiesRepository(unitOfWork);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    properties = propertiesRepository.Current;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You can use a simple factory (it is the &lt;font face="Courier New"&gt;database&lt;/font&gt; object here) to create a new &lt;font face="Courier New"&gt;UnitOfWork&lt;/font&gt; instance. This instance should be passed to all the classes accessing NHibernate functionality. This is important, so design your data access and manipulating classes according to this constraint!&lt;/p&gt;

&lt;p&gt;Link: &lt;a href="http://blog.schuager.com/2009/03/rich-client-nhibernate-session.html" target="_blank"&gt;Rich-client NHibernate session management&lt;/a&gt; 

  &lt;br /&gt;Link: &lt;a href="http://www.martinfowler.com/eaaCatalog/unitOfWork.html" target="_blank"&gt;Unit of Work&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-6498687240108291726?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=sNC56IWvTbc:bRWY1jKZmI0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=sNC56IWvTbc:bRWY1jKZmI0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=sNC56IWvTbc:bRWY1jKZmI0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=sNC56IWvTbc:bRWY1jKZmI0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=sNC56IWvTbc:bRWY1jKZmI0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=sNC56IWvTbc:bRWY1jKZmI0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/6498687240108291726/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/04/nhibernate-session-management.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/6498687240108291726?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/6498687240108291726?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/sNC56IWvTbc/nhibernate-session-management.html" title="NHibernate session management" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_3508c3ca.png" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/04/nhibernate-session-management.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUGRXo9fSp7ImA9WxFSFU0.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-9130391049981985289</id><published>2010-04-17T13:03:00.001+02:00</published><updated>2010-04-17T13:03:44.465+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-17T13:03:44.465+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Visual Basic" /><title>CodePlex TFS from VS2010</title><content type="html">&lt;p&gt;Visual Studio 2010 Professional has a built-in Team Foundation Server (TFS) client. There are some user interface changes on the Add Team Foundation Server screen. When you are connecting to the CodePlex TFS, you need to specify the following information:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Name or URL of TFS: &lt;strong&gt;tfs&amp;lt;number&amp;gt;.codeplex.com&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Connection details&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Path: &lt;strong&gt;tfs&lt;/strong&gt;&lt;/li&gt;      &lt;li&gt;Port number: &lt;strong&gt;443&lt;/strong&gt;&lt;/li&gt;      &lt;li&gt;Protocol: &lt;strong&gt;HTTPS&lt;/strong&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;There is no need to specify &lt;strong&gt;Project name&lt;/strong&gt; anywhere on this screen.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-9130391049981985289?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=FrArP2QN1OQ:Cc-1YM3w3NU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=FrArP2QN1OQ:Cc-1YM3w3NU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=FrArP2QN1OQ:Cc-1YM3w3NU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=FrArP2QN1OQ:Cc-1YM3w3NU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=FrArP2QN1OQ:Cc-1YM3w3NU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=FrArP2QN1OQ:Cc-1YM3w3NU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/9130391049981985289/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/04/codeplex-tfs-from-vs2010.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/9130391049981985289?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/9130391049981985289?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/FrArP2QN1OQ/codeplex-tfs-from-vs2010.html" title="CodePlex TFS from VS2010" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/04/codeplex-tfs-from-vs2010.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MCSHo4eCp7ImA9WxBXE0g.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-8351527564716516158</id><published>2010-01-24T19:57:00.001+01:00</published><updated>2010-01-24T19:57:49.430+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-24T19:57:49.430+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>Refresh WPF DataGrid</title><content type="html">&lt;p&gt;I am using WPF DataGrid for displaying a list of items. I had to modify an item, but the &lt;strong&gt;item had no &lt;font face="Courier New"&gt;INotifyPropertyChanged&lt;/font&gt; event on that property&lt;/strong&gt; (it was a collection).&lt;/p&gt;  &lt;p&gt;So my first idea was:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Update the list behind ItemsSource&lt;/li&gt;    &lt;li&gt;Set ItemsSource property to null to force unbinding&lt;/li&gt;    &lt;li&gt;Set ItemsSource property to the new collection&lt;/li&gt;    &lt;li&gt;Set the SelectedItem to the new item&lt;/li&gt;    &lt;li&gt;Call ScrollIntoView() on the new item&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Well, I got a huge exception at step 5. There must be a simpler solution. And there is.&lt;/p&gt;  &lt;p&gt;The DataGrid generates a view of the ItemsSource. All I have to do is &lt;strong&gt;call the &lt;font face="Courier New"&gt;Items.Refresh()&lt;/font&gt; method&lt;/strong&gt;, and it will rebind to the &lt;font face="Courier New"&gt;ItemsSource&lt;/font&gt;. Everything will be rebound, all updates will be visible. Selected item kept, visibility kept.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-8351527564716516158?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dW0ew0DFI5E:-QEooClyTio:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dW0ew0DFI5E:-QEooClyTio:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=dW0ew0DFI5E:-QEooClyTio:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dW0ew0DFI5E:-QEooClyTio:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=dW0ew0DFI5E:-QEooClyTio:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=dW0ew0DFI5E:-QEooClyTio:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/8351527564716516158/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/01/refresh-wpf-datagrid.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/8351527564716516158?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/8351527564716516158?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/dW0ew0DFI5E/refresh-wpf-datagrid.html" title="Refresh WPF DataGrid" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/01/refresh-wpf-datagrid.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QDQHc5eip7ImA9WxBQGE8.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-6266598050399411705</id><published>2010-01-18T15:33:00.001+01:00</published><updated>2010-01-18T15:36:11.922+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-18T15:36:11.922+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>DispatcherPriority</title><content type="html">&lt;p&gt;I had a very tough problem today. The following code did not work correctly:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;var books = _bookRepository.All;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Dispatcher.Invoke(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ThreadStart(&lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Book book &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; books)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                CatalogItems.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BookViewModel(book));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            OnLoaded(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, EventArgs.Empty);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            OnPropertyChanged(&lt;span style="color: #006080"&gt;&amp;quot;CatalogItems&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        }),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    DispatcherPriority.ApplicationIdle);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;When I run the code above the first time, the debugger didn’t even break into the dispatched code. The subsequent calls were fine.&lt;/p&gt;

&lt;p&gt;Finally I realized that &lt;strong&gt;&lt;font face="Courier New"&gt;DispatcherPriority.ApplicationIdle&lt;/font&gt; should be changed to &lt;font face="Courier New"&gt;DispatcherPriority.Normal&lt;/font&gt;&lt;/strong&gt; – and everything was fine. Don’t forget to check the &lt;font face="Courier New"&gt;DispatcherPriority&lt;/font&gt; value of the dispatcher! It’s hard to debug and hard to recognize.&lt;/p&gt;

&lt;p&gt;These are the possible dispatcher priority levels: &lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="686"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;
        &lt;p align="center"&gt;&lt;strong&gt;Priority&lt;/strong&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p align="center"&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Inactive&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are queued but not processed.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;SystemIdle&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are only dispatched to the UI thread when the system is idle. This is the lowest priority of items that are actually processed.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;ApplicationIdle&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are only dispatched to the UI thread when the application itself is idle.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;ContextIdle&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are only dispatched to the UI thread after higher-priority work items are processed.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Background&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched after all layout, rendering, and input items are processed.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Input&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched to the UI thread at the same priority as user input.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Loaded&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched to the UI thread after all layout and rendering are complete.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Render&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched to the UI thread at the same priority as the rendering engine.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;DataBind&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched to the UI thread at the same priority as data binding.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Normal&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched to the UI thread with normal priority. This is the priority at which most application work items should be dispatched.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="129"&gt;Send&lt;/td&gt;

      &lt;td valign="top" width="555"&gt;
        &lt;p&gt;Work items are dispatched to the UI thread with the highest priority.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Link: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163328.aspx" target="_blank"&gt;Build More Responsive Apps With The Dispatcher (MSDN)&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-6266598050399411705?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=HJ_Ob8ny9_A:f6ilb_aqo3w:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=HJ_Ob8ny9_A:f6ilb_aqo3w:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=HJ_Ob8ny9_A:f6ilb_aqo3w:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=HJ_Ob8ny9_A:f6ilb_aqo3w:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=HJ_Ob8ny9_A:f6ilb_aqo3w:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=HJ_Ob8ny9_A:f6ilb_aqo3w:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/6266598050399411705/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/01/dispatcherpriority.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/6266598050399411705?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/6266598050399411705?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/HJ_Ob8ny9_A/dispatcherpriority.html" title="DispatcherPriority" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/01/dispatcherpriority.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAERX84fSp7ImA9WxBQEk0.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-8022939846884108712</id><published>2010-01-11T10:55:00.001+01:00</published><updated>2010-01-11T10:55:04.135+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-11T10:55:04.135+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Events with anonymous delegate</title><content type="html">&lt;p&gt;I subscribed to an event with an anonymous delegate. Later I was in need for a solution to be able to unsubscribe this delegate. This is a simple solution for the problem:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; ClassName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    MouseButtonEventHandler eventHandler;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ClassName()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        eventHandler = &lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                            &lt;span style="color: #008000"&gt;// operations&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Functionality()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (_subscribe)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _object.MouseLeftButtonDown += eventHandler;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _object.MouseLeftButtonDown -= eventHandler;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-8022939846884108712?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9QoXdIN27vk:U8vrxJuMVNQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9QoXdIN27vk:U8vrxJuMVNQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=9QoXdIN27vk:U8vrxJuMVNQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9QoXdIN27vk:U8vrxJuMVNQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=9QoXdIN27vk:U8vrxJuMVNQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=9QoXdIN27vk:U8vrxJuMVNQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/8022939846884108712/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/01/events-with-anonymous-delegate.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/8022939846884108712?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/8022939846884108712?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/9QoXdIN27vk/events-with-anonymous-delegate.html" title="Events with anonymous delegate" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/01/events-with-anonymous-delegate.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcMSHg-eCp7ImA9WxFSFU0.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-1046847588160768146</id><published>2010-01-09T12:50:00.002+01:00</published><updated>2010-04-17T14:41:29.650+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-17T14:41:29.650+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Testing" /><category scheme="http://www.blogger.com/atom/ns#" term="NHibernate" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title>NHibernate and SQLite in-memory database</title><content type="html">I’m implementing and in-memory database-based unit test framework for an application. I hope it speeds up unit tests. Unfortunately I have to redesign my entity repositories to support in-memory behavior. As far as I can learn from SUT behavior, &lt;b&gt;SQLite will create a brand new database when&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;you close the session&lt;/li&gt;
&lt;li&gt;you commit or close a transaction&lt;/li&gt;
&lt;/ul&gt;
It means you &lt;b&gt;can’t use &lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;using(ISession)&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;using(ITransaction transaction){ … transaction.Commit() }&lt;/span&gt;&lt;/b&gt; constructs in the repository.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-1046847588160768146?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cAKj8JEilR0:PlWTsTDUj-4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cAKj8JEilR0:PlWTsTDUj-4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=cAKj8JEilR0:PlWTsTDUj-4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cAKj8JEilR0:PlWTsTDUj-4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=cAKj8JEilR0:PlWTsTDUj-4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=cAKj8JEilR0:PlWTsTDUj-4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/1046847588160768146/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2010/01/nhibernate-and-sqlite-in-memory.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/1046847588160768146?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/1046847588160768146?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/cAKj8JEilR0/nhibernate-and-sqlite-in-memory.html" title="NHibernate and SQLite in-memory database" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2010/01/nhibernate-and-sqlite-in-memory.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAEQH07eSp7ImA9WxBTGUs.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-931675744417349105</id><published>2009-12-16T13:47:00.001+01:00</published><updated>2009-12-16T13:48:21.301+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-16T13:48:21.301+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>Web-style WPF popup</title><content type="html">&lt;p&gt;I like &lt;strong&gt;modal web dialogs, especially when they dim the background&lt;/strong&gt;. Here is an example:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/WPFWebPopup_WebExample.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="WPFWebPopup WebExample" border="0" alt="WPFWebPopup WebExample" src="http://i63.photobucket.com/albums/h134/artur02/Blog/WPFWebPopup_WebExample.png" width="244" height="150" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The background is dimmed, not clickable, and the dialog box is in the foreground. The work area is visible at first site, you must focus on the current content.&lt;/p&gt;  &lt;p&gt;I wanted something similar in WPF. Here is my example application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/WPFWebPopup_Window.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="WPFWebPopup Window" border="0" alt="WPFWebPopup Window" src="http://i63.photobucket.com/albums/h134/artur02/Blog/WPFWebPopup_Window.png" width="244" height="137" /&gt;&lt;/a&gt; &lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/WPFWebPopup_PoppedUp.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="WPFWebPopup PoppedUp" border="0" alt="WPFWebPopup PoppedUp" src="http://i63.photobucket.com/albums/h134/artur02/Blog/WPFWebPopup_PoppedUp.png" width="244" height="137" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;How it works?&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;There are two parts of the window. There is a DataGrid in the left pane and a ListBox in the right pane. The same data is loaded into both controls. When you select an item in the grid, the popup will appear over the grid, displaying the selected name. Clicking on the popup will close that. You can’t click through the popup. The right pane demonstrates that you can do anything with other controls. The popup resizes itself (drag the grid splitter to test it).&lt;/p&gt;  &lt;h3&gt;About adorners&lt;/h3&gt;  &lt;p&gt;The key component to the popup control is the &lt;strong&gt;adorner class of WPF&lt;/strong&gt;. The definition of &lt;a href="http://msdn.microsoft.com/en-us/library/ms743737.aspx" target="_blank"&gt;adorners from MSDN&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;An Adorner is a custom FrameworkElement that is bound to a UIElement. Adorners are rendered in an AdornerLayer, which is a rendering surface that is always on top of the adorned element or a collection of adorned elements. Rendering of an adorner is independent from rendering of the UIElement that the adorner is bound to. An adorner is typically positioned relative to the element to which it is bound, using the standard 2-D coordinate origin located at the upper-left of the adorned element.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are three &lt;strong&gt;types of adorners&lt;/strong&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Adorner: &lt;/em&gt;An abstract base class from which all concrete adorner implementations inherit.&lt;/p&gt;    &lt;p&gt;&lt;em&gt;AdornerLayer: &lt;/em&gt;A class representing a rendering layer for the adorner(s) of one or more adorned elements.&lt;/p&gt;    &lt;p&gt;&lt;em&gt;AdornerDecorator: &lt;/em&gt;A class that enables an adorner layer to be associated with a collection of elements.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;The code&lt;/h3&gt;  &lt;p&gt;The code of the &lt;strong&gt;popup adorner&lt;/strong&gt; is the following:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows.Documents;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; AdornerTest1&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; PopUp : Adorner&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; VisualCollection _Visuals;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; ContentPresenter _ContentPresenter;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Initializes a new instance of the &amp;lt;see cref=&amp;quot;PopUp&amp;quot;/&amp;gt; class.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;adornedElement&amp;quot;&amp;gt;The element to bind the adorner to.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;exception cref=&amp;quot;T:System.ArgumentNullException&amp;quot;&amp;gt;Raised when adornedElement is null.&amp;lt;/exception&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; PopUp(UIElement adornedElement)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;             : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;(adornedElement)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;             _Visuals = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; VisualCollection(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;             _ContentPresenter = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ContentPresenter();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;             _Visuals.Add(_ContentPresenter);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Initializes a new instance of the &amp;lt;see cref=&amp;quot;PopUp&amp;quot;/&amp;gt; class.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;adornedElement&amp;quot;&amp;gt;The adorned element.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;content&amp;quot;&amp;gt;The content.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; PopUp(UIElement adornedElement, Visual content)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;             : &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;(adornedElement)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;         { Content = content; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Implements any custom measuring behavior for the adorner.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;constraint&amp;quot;&amp;gt;A size to constrain the adorner to.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// A &amp;lt;see cref=&amp;quot;T:System.Windows.Size&amp;quot;/&amp;gt; object representing the amount of layout space needed by the adorner.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum42"&gt;  42:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; Size MeasureOverride(Size constraint)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum43"&gt;  43:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum44"&gt;  44:&lt;/span&gt;             _ContentPresenter.Measure(constraint);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum45"&gt;  45:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _ContentPresenter.DesiredSize;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum46"&gt;  46:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum47"&gt;  47:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum48"&gt;  48:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum49"&gt;  49:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// When overridden in a derived class, positions child elements and determines a size for a &amp;lt;see cref=&amp;quot;T:System.Windows.FrameworkElement&amp;quot;/&amp;gt; derived class.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum50"&gt;  50:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum51"&gt;  51:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;finalSize&amp;quot;&amp;gt;The final area within the parent that this element should use to arrange itself and its children.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum52"&gt;  52:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The actual size used.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum53"&gt;  53:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; Size ArrangeOverride(Size finalSize)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum54"&gt;  54:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum55"&gt;  55:&lt;/span&gt;             _ContentPresenter.Arrange(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Rect(0, 0,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum56"&gt;  56:&lt;/span&gt;                  finalSize.Width, finalSize.Height));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum57"&gt;  57:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _ContentPresenter.RenderSize;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum58"&gt;  58:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum59"&gt;  59:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum60"&gt;  60:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum61"&gt;  61:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Overrides &amp;lt;see cref=&amp;quot;M:System.Windows.Media.Visual.GetVisualChild(System.Int32)&amp;quot;/&amp;gt;, and returns a child at the specified index from a collection of child elements.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum62"&gt;  62:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum63"&gt;  63:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;The zero-based index of the requested child element in the collection.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum64"&gt;  64:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum65"&gt;  65:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// The requested child element. This should not return null; if the provided index is out of range, an exception is thrown.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum66"&gt;  66:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum67"&gt;  67:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; Visual GetVisualChild(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; index)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum68"&gt;  68:&lt;/span&gt;         { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _Visuals[index]; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum69"&gt;  69:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum70"&gt;  70:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; VisualChildrenCount&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum71"&gt;  71:&lt;/span&gt;         { get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _Visuals.Count; } }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum72"&gt;  72:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum73"&gt;  73:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum74"&gt;  74:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Gets or sets the content.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum75"&gt;  75:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum76"&gt;  76:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;value&amp;gt;The content.&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum77"&gt;  77:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; Content&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum78"&gt;  78:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum79"&gt;  79:&lt;/span&gt;             get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _ContentPresenter.Content; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum80"&gt;  80:&lt;/span&gt;             set { _ContentPresenter.Content = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum81"&gt;  81:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum82"&gt;  82:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum83"&gt;  83:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You can set a content for the popup adorner, and that is all what I want. The VisualCollection is responsible for rendering the content on screen, and the ContentPresenter is responsible for storing the popup’s content.&lt;/p&gt;

&lt;p&gt;There is a &lt;strong&gt;BackgroundShade user control&lt;/strong&gt; to represent the dimmed background. The code is very short and simple:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;     [...]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;Opacity&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.705&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I set the background to black at line 3 and I set the opacity of the control to 70% at line 4.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Main window layout&lt;/strong&gt;:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Window&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;xmlns:Custom&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/wpf/2008/toolkit&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:d&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/expression/blend/2008&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:mc&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:AdornerTest1&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:AdornerTest1&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;x:Class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AdornerTest1.MainWindow&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Window&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;Title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Popup with shaded background sample&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;640&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Height&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;480&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;mc:Ignorable&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;d&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;DataTemplate&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Key&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ItemTemplate&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Name}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Foreground&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;White&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Phone}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Note}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0 0 0 8&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DataContext&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Source={StaticResource SampleDataSource}}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ColumnDefinition&lt;/span&gt; &lt;span style="color: #ff0000"&gt;MinWidth&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Custom:DataGrid&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Grid&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Collection}&amp;quot;&lt;/span&gt;  &lt;span style="color: #ff0000"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;SelectionChanged&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Grid_SelectionChanged&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;GridSplitter&lt;/span&gt; &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Stretch&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Grid&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;Column&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;List&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Grid&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;Column&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{DynamicResource ItemTemplate}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Collection}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;d:LayoutOverrides&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;GridBox&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Window&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
There is a Grid as layout root with 3 columns. There is a DataGrid in the left pane, a GridSplitter in the middle pane, and a ListBox in the right pane. 

&lt;p&gt;The &lt;strong&gt;Main window code&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; [...]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; AdornerTest1&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MainWindow : Window&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MainWindow()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         { [...] }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         BackgroundShade shade;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         PopUp adorner;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Grid_SelectionChanged(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, SelectionChangedEventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Create adorner&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;             AdornerLayer layer = AdornerLayer.GetAdornerLayer(Grid);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;             adorner = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PopUp(Grid);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;             &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Close adorner&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;             adorner.MouseLeftButtonDown += &lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;                                        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;                                            layer.Remove(adorner);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;                                        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;             ((FrameworkElement) adorner.AdornedElement).&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;                 SizeChanged += AdornedElement_SizeChanged;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Create shaded background&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;             shade = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BackgroundShade();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;             AdornedElement_SizeChanged(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;             &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Create text&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;             TextBlock text = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; TextBlock();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;             text.Foreground = Brushes.White;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Bind text to selected item&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;             Binding binding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Binding(&lt;span style="color: #006080"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;             binding.Source = Grid.SelectedItem;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;             text.SetBinding(TextBlock.TextProperty, binding);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Register text&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;             shade.LayoutRoot.Children.Add(text);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum42"&gt;  42:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// Display adorner&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum43"&gt;  43:&lt;/span&gt;             adorner.Content = shade;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum44"&gt;  44:&lt;/span&gt;             layer.Add(adorner);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum45"&gt;  45:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum46"&gt;  46:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum47"&gt;  47:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum48"&gt;  48:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Adorned element's size changed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum49"&gt;  49:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum50"&gt;  50:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AdornedElement_SizeChanged(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, SizeChangedEventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum51"&gt;  51:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum52"&gt;  52:&lt;/span&gt;             shade.Width = adorner.AdornedElement.RenderSize.Width;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum53"&gt;  53:&lt;/span&gt;             shade.Height = adorner.AdornedElement.RenderSize.Height;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum54"&gt;  54:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum55"&gt;  55:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum56"&gt;  56:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The implementation details are in the comments. One interesting thing: I couldn’t simply bind the AdornedElement’s RenderSize to the shade’s width property, so it seems simpler to convert the AdornedElement to FrameworkElement and attach an event handler to the SizeChanged event.&lt;/p&gt;

&lt;p&gt;You can download the source and the binaries from Google code, or you can simply browse source at the same place. Links are below.&lt;/p&gt;

&lt;p&gt;Link: &lt;a href="http://artur02.googlecode.com/files/WPFWebPopup.zip" target="_blank"&gt;Demo source [Google Code]&lt;/a&gt; 

  &lt;br /&gt;Link: &lt;a href="http://artur02.googlecode.com/files/wpfpopup.zip" target="_blank"&gt;Demo executable [Google Code]&lt;/a&gt; 

  &lt;br /&gt;Link: &lt;a href="http://code.google.com/p/artur02/source/browse/#svn/trunk/WPFWebPopup/AdornerTest1" target="_blank"&gt;Browse source [Google Code]&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-931675744417349105?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=-hNrwopefYg:hETRb2H1_r0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=-hNrwopefYg:hETRb2H1_r0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=-hNrwopefYg:hETRb2H1_r0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=-hNrwopefYg:hETRb2H1_r0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=-hNrwopefYg:hETRb2H1_r0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=-hNrwopefYg:hETRb2H1_r0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/931675744417349105/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2009/12/web-style-wpf-popup.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/931675744417349105?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/931675744417349105?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/-hNrwopefYg/web-style-wpf-popup.html" title="Web-style WPF popup" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_WPFWebPopup_WebExample.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2009/12/web-style-wpf-popup.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkYER3oycCp7ImA9WxBTF00.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-7295830024755388094</id><published>2009-12-13T13:41:00.001+01:00</published><updated>2009-12-13T13:41:46.498+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-13T13:41:46.498+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Testing" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>NUnit and Microsoft Contracts library</title><content type="html">&lt;p&gt;I’m using &lt;strong&gt;NUnit and Microsoft Code Contracts&lt;/strong&gt; library to implement unit tests and code contracts (mostly preconditions).&lt;/p&gt;  &lt;p&gt;Unfortunately Contracts library throws a generated (internal) exception class &lt;strong&gt;that can’t be used as &lt;font face="Courier New"&gt;Assert.Throws&amp;lt;ContractException&amp;gt;(…)&lt;/font&gt;&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Contracts documentation suggests the following code for MSTest framework:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestClass]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;  &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;  Test&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    [AssemblyInitialize]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt;  &lt;span style="color: #0000ff"&gt;static&lt;/span&gt;  &lt;span style="color: #0000ff"&gt;void&lt;/span&gt;   AssemblyInitialize (TestContext tc)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Contract. ContractFailed+= (sender, e) =&amp;gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            e.SetHandled();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            e.SetUnwind(); &lt;span style="color: #008000"&gt;// cause code to  abort  after  event&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Assert.Fail(e.FailureKind.ToString() + &lt;span style="color: #006080"&gt;&amp;quot;:&amp;quot;&lt;/span&gt; + e.DebugMessage);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I wrote the following code to &lt;strong&gt;mimic this functionality&lt;/strong&gt;:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestFixtureSetUp]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetUpFixture()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Contract.ContractFailed +=&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (sender, e) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        e.SetHandled();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        e.SetUnwind();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Assert.Fail(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;&amp;quot;{0}:{1}&amp;quot;&lt;/span&gt;, e.FailureKind.ToString(), e.Message));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Well, &lt;strong&gt;it did not work&lt;/strong&gt;, I couldn’t make the &lt;font face="Courier New"&gt;Assert.Throws&lt;/font&gt; structure work. I always got the &lt;font face="Courier New"&gt;ContractException&lt;/font&gt; exception. Finally I found a &lt;a href="http://dotnet-forum.de/forums/p/1916/6837.aspx" target="_blank"&gt;blog entry&lt;/a&gt; (in German) with &lt;strong&gt;a classic solution&lt;/strong&gt;: &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;use try/catch block &lt;/li&gt;

  &lt;li&gt;check exception type name &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;So here is the working code:&lt;/strong&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Method under test&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Assert.True(ex.GetType().Name == &lt;span style="color: #006080"&gt;&amp;quot;ContractException&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Assert.Fail(&lt;span style="color: #006080"&gt;&amp;quot;ContractException has not been thrown.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-7295830024755388094?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=aqovpBz9hTw:_7TydSuIrak:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=aqovpBz9hTw:_7TydSuIrak:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=aqovpBz9hTw:_7TydSuIrak:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=aqovpBz9hTw:_7TydSuIrak:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=aqovpBz9hTw:_7TydSuIrak:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=aqovpBz9hTw:_7TydSuIrak:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/7295830024755388094/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2009/12/nunit-and-microsoft-contracts-library.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/7295830024755388094?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/7295830024755388094?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/aqovpBz9hTw/nunit-and-microsoft-contracts-library.html" title="NUnit and Microsoft Contracts library" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2009/12/nunit-and-microsoft-contracts-library.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUIGQHcyfip7ImA9WxBTEUU.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-4940955587116436313</id><published>2009-12-07T13:05:00.001+01:00</published><updated>2009-12-07T13:05:21.996+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-07T13:05:21.996+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="visual studio" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>NDepend</title><content type="html">&lt;p&gt;I've started using NDepend Pro on my open-source project. I will try to outline some important features and explain some ideas that differenciate this tool from others like FXCop or ReSharper rules. &lt;/p&gt;  &lt;h3&gt;What is NDepend?&lt;/h3&gt;  &lt;p&gt;For me &lt;strong&gt;NDepend is a tool for monitoring and improving code quality&lt;/strong&gt;. It uses &lt;a href="http://en.wikipedia.org/wiki/Software_metric" target="_blank"&gt;software metrics&lt;/a&gt; and .NET IL characteristics to help us understand, analyze, visualize and compare different code bases and builds. We learnt code coverage, cohesion, coupling and other code metrics at university, but we hardly had the chance to employ this knowledge (or even understand deeper them). Who wants to calculate them for hundreds of code lines? Well, NDepend just does it instead of us. We can &lt;strong&gt;see the internals of code structure and dependencies&lt;/strong&gt; with just one click!&lt;/p&gt;  &lt;h3&gt;Costs&lt;/h3&gt;  &lt;p&gt;NDepend is a &lt;strong&gt;free tool for academic and open-source projects&lt;/strong&gt;. Unfortunately it comes with a cost: you will be restricted with CQL (creating custom code metrics queries) usage, won’t be able to compare builds, won’t be able to integrate test metrics into the dataset and (almost) won’t have Visual Studio integration. I think it’s OK for an open-source project.&lt;/p&gt;  &lt;h3&gt;Where to start?&lt;/h3&gt;  &lt;p&gt;NDepend is not an easy tool. Easy to use, but it &lt;strong&gt;takes time to learn and understand the metrics and find the proper threshold limits for your project&lt;/strong&gt;. NDepend team knows it, so they set up a lot of preset thresholds and built-in CQL queries. There are useful demo videos and there is a &lt;a href="http://www.ndepend.com/Metrics.aspx" target="_blank"&gt;metrics library&lt;/a&gt;. So it’s easy to start using it.&lt;/p&gt;  &lt;h3&gt;How do I use it?&lt;/h3&gt;  &lt;p&gt;I use NDepend as a guard. I use other tools (like Resharper, Team System Tools or FXCop) in Visual Studio to check against naming conventions and some other rules. Visual NDepend helps me to understand the structure of my application and recheck some rules, mainly with built-in CQL queries. &lt;/p&gt;  &lt;p&gt;I found a circular call in one of my assemblies. It was not trivial to me, I couldn’t have found that without NDepend.&lt;/p&gt;  &lt;p&gt;Link: &lt;a href="http://www.ndepend.com/" target="_blank"&gt;NDepend&lt;/a&gt;    &lt;br /&gt;Link: &lt;a href="http://en.wikipedia.org/wiki/Software_metric" target="_blank"&gt;software metrics&lt;/a&gt;    &lt;br /&gt;Link: &lt;a href="http://techiethings.blogspot.com/2009/10/inheritance-depth.html" target="_blank"&gt;Inheritance Depth in CQL&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-4940955587116436313?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=OObqfPX7LVg:0_swaGEOkBw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=OObqfPX7LVg:0_swaGEOkBw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=OObqfPX7LVg:0_swaGEOkBw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=OObqfPX7LVg:0_swaGEOkBw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=OObqfPX7LVg:0_swaGEOkBw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=OObqfPX7LVg:0_swaGEOkBw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/4940955587116436313/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2009/12/ndepend.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4940955587116436313?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/4940955587116436313?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/OObqfPX7LVg/ndepend.html" title="NDepend" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2009/12/ndepend.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8MQ387fSp7ImA9WxNbE00.&quot;"><id>tag:blogger.com,1999:blog-581522584150589505.post-5303026816000663423</id><published>2009-11-15T17:33:00.001+01:00</published><updated>2009-11-15T17:34:42.105+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-15T17:34:42.105+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Internet" /><title>Pin m3u to taskbar</title><content type="html">&lt;p&gt;&lt;a href="http://i63.photobucket.com/albums/h134/artur02/Blog/6ff26e7c.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title=".m3u pinned" border="0" alt=".m3u pinned" align="right" src="http://i63.photobucket.com/albums/h134/artur02/Blog/6ff26e7c.png" width="150" height="139" /&gt;&lt;/a&gt; I wanted to &lt;strong&gt;pin&lt;/strong&gt; (keep permanently) some&lt;strong&gt; .m3u files to my taskbar&lt;/strong&gt;. A lot of radios publish their live streams in .m3u files and I could have listened to them with just one click. &lt;/p&gt;  &lt;p&gt;It is really simple in case of Windows 7. Just &lt;strong&gt;drag and drop the .m3u files to the taskbar&lt;/strong&gt; (to an empty area) and these files will appear in the pin list of their default program. In my case this program is Media Player Classic. &lt;/p&gt;  &lt;p&gt;This is a great feature of Windows 7!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/581522584150589505-5303026816000663423?l=techiethings.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=7MoVc_oSzB0:KQADezU2Eu0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=7MoVc_oSzB0:KQADezU2Eu0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=7MoVc_oSzB0:KQADezU2Eu0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=7MoVc_oSzB0:KQADezU2Eu0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?i=7MoVc_oSzB0:KQADezU2Eu0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/techiethings?a=7MoVc_oSzB0:KQADezU2Eu0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/techiethings?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techiethings.blogspot.com/feeds/5303026816000663423/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techiethings.blogspot.com/2009/11/pin-m3u-to-taskbar.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5303026816000663423?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/581522584150589505/posts/default/5303026816000663423?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/techiethings/~3/7MoVc_oSzB0/pin-m3u-to-taskbar.html" title="Pin m3u to taskbar" /><author><name>Artur Herczeg</name><uri>http://www.blogger.com/profile/06980674445694201967</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_Z17XqalrT40/SgQGAD_PH-I/AAAAAAAAB9U/V6D4hcAwgcQ/S220/head_optimized.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i63.photobucket.com/albums/h134/artur02/Blog/th_6ff26e7c.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://techiethings.blogspot.com/2009/11/pin-m3u-to-taskbar.html</feedburner:origLink></entry></feed>

