<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Naresh.Jois &#187; .net</title>
	<atom:link href="http://www.nareshjois.com/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nareshjois.com</link>
	<description>Home of a professional developer &#38; a aspiring photographer</description>
	<lastBuildDate>Fri, 03 Feb 2012 16:57:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Zune Window in WPF</title>
		<link>http://www.nareshjois.com/2011/07/zune-window-in-wpf/</link>
		<comments>http://www.nareshjois.com/2011/07/zune-window-in-wpf/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 10:30:53 +0000</pubDate>
		<dc:creator>naresh</dc:creator>
				<category><![CDATA[.net Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[zune]]></category>

		<guid isPermaLink="false">http://www.nareshjois.com/?p=892</guid>
		<description><![CDATA[I have become a huge fan of Metro UI design and i really like the Zune interface and the starting point would be the custom chrome so i searched a bit and found this neat little thing , thought I would share /// &#60;summary&#62; /// Borderless Window Behavior /// &#60;/summary&#62; public class BorderlessWindowBehavior : Behavior&#60;window&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I have become a huge fan of Metro UI design and i really like the Zune interface and the starting point would be the custom chrome so i searched a bit and found this neat little thing , thought I would share</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;"> <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Borderless Window Behavior</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> BorderlessWindowBehavior <span style="color: #008000;">:</span> Behavior<span style="color: #008000;">&lt;</span>window<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080;">#region Native Methods</span>
&nbsp;
        <span style="color: #008000;">&#91;</span>StructLayout<span style="color: #008000;">&#40;</span>LayoutKind<span style="color: #008000;">.</span><span style="color: #0000FF;">Sequential</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> MARGINS
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> leftWidth<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> rightWidth<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> topHeight<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> bottomHeight<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008000;">&#91;</span>DllImport<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;dwmapi.dll&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">extern</span> <span style="color: #6666cc; font-weight: bold;">int</span> DwmExtendFrameIntoClientArea<span style="color: #008000;">&#40;</span>IntPtr hWnd, <span style="color: #0600FF; font-weight: bold;">ref</span> MARGINS pMarInset<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// POINT aka POINTAPI</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008000;">&#91;</span>StructLayout<span style="color: #008000;">&#40;</span>LayoutKind<span style="color: #008000;">.</span><span style="color: #0000FF;">Sequential</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> POINT
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// x coordinate of point.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> x<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// y coordinate of point.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> y<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Construct a point of coordinates (x,y).</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> POINT<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> x, <span style="color: #6666cc; font-weight: bold;">int</span> y<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">x</span> <span style="color: #008000;">=</span> x<span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">y</span> <span style="color: #008000;">=</span> y<span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008000;">&#91;</span>StructLayout<span style="color: #008000;">&#40;</span>LayoutKind<span style="color: #008000;">.</span><span style="color: #0000FF;">Sequential</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> MINMAXINFO
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> POINT ptReserved<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> POINT ptMaxSize<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> POINT ptMaxPosition<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> POINT ptMinTrackSize<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> POINT ptMaxTrackSize<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008000;">&#91;</span>StructLayout<span style="color: #008000;">&#40;</span>LayoutKind<span style="color: #008000;">.</span><span style="color: #0000FF;">Sequential</span>, CharSet <span style="color: #008000;">=</span> CharSet<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Auto</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MONITORINFO
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> cbSize <span style="color: #008000;">=</span> Marshal<span style="color: #008000;">.</span><span style="color: #008000;">SizeOf</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>MONITORINFO<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">public</span> RECT rcMonitor <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RECT<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">public</span> RECT rcWork <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RECT<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> dwFlags <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt; Win32 &lt;/summary&gt;</span>
        <span style="color: #008000;">&#91;</span>StructLayout<span style="color: #008000;">&#40;</span>LayoutKind<span style="color: #008000;">.</span><span style="color: #0000FF;">Sequential</span>, Pack <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> RECT
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> left<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> top<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> right<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> bottom<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> RECT Empty <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RECT<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Width
            <span style="color: #008000;">&#123;</span>
                <span style="color: #008080; font-style: italic;">// Abs needed for BIDI OS</span>
                get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Abs</span><span style="color: #008000;">&#40;</span>right <span style="color: #008000;">-</span> left<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>  
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Height
            <span style="color: #008000;">&#123;</span>
                get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> bottom <span style="color: #008000;">-</span> top<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;left&quot;&gt;The left.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;top&quot;&gt;The top.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;right&quot;&gt;The right.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;bottom&quot;&gt;The bottom.&lt;/param&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> RECT<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> left, <span style="color: #6666cc; font-weight: bold;">int</span> top, <span style="color: #6666cc; font-weight: bold;">int</span> right, <span style="color: #6666cc; font-weight: bold;">int</span> bottom<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">left</span> <span style="color: #008000;">=</span> left<span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">top</span> <span style="color: #008000;">=</span> top<span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">right</span> <span style="color: #008000;">=</span> right<span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">bottom</span> <span style="color: #008000;">=</span> bottom<span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rcSrc&quot;&gt;The rc SRC.&lt;/param&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> RECT<span style="color: #008000;">&#40;</span>RECT rcSrc<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">left</span> <span style="color: #008000;">=</span> rcSrc<span style="color: #008000;">.</span><span style="color: #0000FF;">left</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">top</span> <span style="color: #008000;">=</span> rcSrc<span style="color: #008000;">.</span><span style="color: #0000FF;">top</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">right</span> <span style="color: #008000;">=</span> rcSrc<span style="color: #008000;">.</span><span style="color: #0000FF;">right</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">bottom</span> <span style="color: #008000;">=</span> rcSrc<span style="color: #008000;">.</span><span style="color: #0000FF;">bottom</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Win32</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;value&gt;</span>
            <span style="color: #008080; font-style: italic;">///   &lt;c&gt;true&lt;/c&gt; if this instance is empty; otherwise, &lt;c&gt;false&lt;/c&gt;.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/value&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsEmpty
            <span style="color: #008000;">&#123;</span>
                get
                <span style="color: #008000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">// BUGBUG : On Bidi OS (hebrew arabic) left &gt; right</span>
                    <span style="color: #0600FF; font-weight: bold;">return</span> left <span style="color: #008000;">&gt;=</span> right <span style="color: #008000;">||</span> top <span style="color: #008000;">&gt;=</span> bottom<span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Return a user friendly representation of this struct</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;</span>
            <span style="color: #008080; font-style: italic;">/// A &lt;see cref=&quot;System.String&quot;/&gt; that represents this instance.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/returns&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">string</span> ToString<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #008000;">==</span> RECT<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span> 
                    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #666666;">&quot;RECT {Empty}&quot;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;RECT {{ left : {0} / top : {1} / right : {2} / bottom : {3} }}&quot;</span>, left, top, right, bottom<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Determine if 2 RECT are equal (deep compare)</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;obj&quot;&gt;The &lt;see cref=&quot;System.Object&quot;/&gt; to compare with this instance.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;</span>
            <span style="color: #008080; font-style: italic;">///   &lt;c&gt;true&lt;/c&gt; if the specified &lt;see cref=&quot;System.Object&quot;/&gt; is equal to this instance; otherwise, &lt;c&gt;false&lt;/c&gt;.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/returns&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Equals<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> obj<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #008000;">&#40;</span>obj <span style="color: #008000;">is</span> Rect<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #008000;">==</span> <span style="color: #008000;">&#40;</span>RECT<span style="color: #008000;">&#41;</span>obj<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Return the HashCode for this struct (not guaranteed to be unique)</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;</span>
            <span style="color: #008080; font-style: italic;">/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. </span>
            <span style="color: #008080; font-style: italic;">/// &lt;/returns&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">int</span> GetHashCode<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> left<span style="color: #008000;">.</span><span style="color: #0000FF;">GetHashCode</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> top<span style="color: #008000;">.</span><span style="color: #0000FF;">GetHashCode</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> right<span style="color: #008000;">.</span><span style="color: #0000FF;">GetHashCode</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> bottom<span style="color: #008000;">.</span><span style="color: #0000FF;">GetHashCode</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Determine if 2 RECT are equal (deep compare)</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rect1&quot;&gt;The rect1.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rect2&quot;&gt;The rect2.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;</span>
            <span style="color: #008080; font-style: italic;">/// The result of the operator.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/returns&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> <span style="color: #0600FF; font-weight: bold;">operator</span> <span style="color: #008000;">==</span><span style="color: #008000;">&#40;</span>RECT rect1, RECT rect2<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>rect1<span style="color: #008000;">.</span><span style="color: #0000FF;">left</span> <span style="color: #008000;">==</span> rect2<span style="color: #008000;">.</span><span style="color: #0000FF;">left</span> <span style="color: #008000;">&amp;&amp;</span> rect1<span style="color: #008000;">.</span><span style="color: #0000FF;">top</span> <span style="color: #008000;">==</span> rect2<span style="color: #008000;">.</span><span style="color: #0000FF;">top</span> <span style="color: #008000;">&amp;&amp;</span> rect1<span style="color: #008000;">.</span><span style="color: #0000FF;">right</span> <span style="color: #008000;">==</span> rect2<span style="color: #008000;">.</span><span style="color: #0000FF;">right</span> <span style="color: #008000;">&amp;&amp;</span> rect1<span style="color: #008000;">.</span><span style="color: #0000FF;">bottom</span> <span style="color: #008000;">==</span> rect2<span style="color: #008000;">.</span><span style="color: #0000FF;">bottom</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// Determine if 2 RECT are different (deep compare)</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rect1&quot;&gt;The rect1.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rect2&quot;&gt;The rect2.&lt;/param&gt;</span>
            <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;</span>
            <span style="color: #008080; font-style: italic;">/// The result of the operator.</span>
            <span style="color: #008080; font-style: italic;">/// &lt;/returns&gt;</span>
            <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> <span style="color: #0600FF; font-weight: bold;">operator</span> <span style="color: #008000;">!=</span><span style="color: #008000;">&#40;</span>RECT rect1, RECT rect2<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">!</span><span style="color: #008000;">&#40;</span>rect1 <span style="color: #008000;">==</span> rect2<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets the monitor info.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;hMonitor&quot;&gt;The h monitor.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;lpmi&quot;&gt;The lpmi.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
        <span style="color: #008000;">&#91;</span>DllImport<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;user32&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">internal</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">extern</span> <span style="color: #6666cc; font-weight: bold;">bool</span> GetMonitorInfo<span style="color: #008000;">&#40;</span>IntPtr hMonitor, MONITORINFO lpmi<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Monitors from window.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;handle&quot;&gt;The handle.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;flags&quot;&gt;The flags.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
        <span style="color: #008000;">&#91;</span>DllImport<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;User32&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">internal</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">extern</span> IntPtr MonitorFromWindow<span style="color: #008000;">&#40;</span>IntPtr handle, <span style="color: #6666cc; font-weight: bold;">int</span> flags<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Wms the get min max info.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;hwnd&quot;&gt;The HWND.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;lParam&quot;&gt;The l param.&lt;/param&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> WmGetMinMaxInfo<span style="color: #008000;">&#40;</span><span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IntPtr</span> hwnd, <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IntPtr</span> lParam<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            MINMAXINFO mmi <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>MINMAXINFO<span style="color: #008000;">&#41;</span>Marshal<span style="color: #008000;">.</span><span style="color: #0000FF;">PtrToStructure</span><span style="color: #008000;">&#40;</span>lParam, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>MINMAXINFO<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Adjust the maximized size and position to fit the work area of the correct monitor</span>
            <span style="color: #6666cc; font-weight: bold;">int</span> MONITOR_DEFAULTTONEAREST <span style="color: #008000;">=</span> 0x00000002<span style="color: #008000;">;</span>
            <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IntPtr</span> monitor <span style="color: #008000;">=</span> MonitorFromWindow<span style="color: #008000;">&#40;</span>hwnd, MONITOR_DEFAULTTONEAREST<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>monitor <span style="color: #008000;">!=</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IntPtr</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Zero</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                MONITORINFO monitorInfo <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MONITORINFO<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                GetMonitorInfo<span style="color: #008000;">&#40;</span>monitor, monitorInfo<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                RECT rcWorkArea <span style="color: #008000;">=</span> monitorInfo<span style="color: #008000;">.</span><span style="color: #0000FF;">rcWork</span><span style="color: #008000;">;</span>
                RECT rcMonitorArea <span style="color: #008000;">=</span> monitorInfo<span style="color: #008000;">.</span><span style="color: #0000FF;">rcMonitor</span><span style="color: #008000;">;</span>
                mmi<span style="color: #008000;">.</span><span style="color: #0000FF;">ptMaxPosition</span><span style="color: #008000;">.</span><span style="color: #0000FF;">x</span> <span style="color: #008000;">=</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Abs</span><span style="color: #008000;">&#40;</span>rcWorkArea<span style="color: #008000;">.</span><span style="color: #0000FF;">left</span> <span style="color: #008000;">-</span> rcMonitorArea<span style="color: #008000;">.</span><span style="color: #0000FF;">left</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                mmi<span style="color: #008000;">.</span><span style="color: #0000FF;">ptMaxPosition</span><span style="color: #008000;">.</span><span style="color: #0000FF;">y</span> <span style="color: #008000;">=</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Abs</span><span style="color: #008000;">&#40;</span>rcWorkArea<span style="color: #008000;">.</span><span style="color: #0000FF;">top</span> <span style="color: #008000;">-</span> rcMonitorArea<span style="color: #008000;">.</span><span style="color: #0000FF;">top</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                mmi<span style="color: #008000;">.</span><span style="color: #0000FF;">ptMaxSize</span><span style="color: #008000;">.</span><span style="color: #0000FF;">x</span> <span style="color: #008000;">=</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Abs</span><span style="color: #008000;">&#40;</span>rcWorkArea<span style="color: #008000;">.</span><span style="color: #0000FF;">right</span> <span style="color: #008000;">-</span> rcWorkArea<span style="color: #008000;">.</span><span style="color: #0000FF;">left</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                mmi<span style="color: #008000;">.</span><span style="color: #0000FF;">ptMaxSize</span><span style="color: #008000;">.</span><span style="color: #0000FF;">y</span> <span style="color: #008000;">=</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Abs</span><span style="color: #008000;">&#40;</span>rcWorkArea<span style="color: #008000;">.</span><span style="color: #0000FF;">bottom</span> <span style="color: #008000;">-</span> rcWorkArea<span style="color: #008000;">.</span><span style="color: #0000FF;">top</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            Marshal<span style="color: #008000;">.</span><span style="color: #0000FF;">StructureToPtr</span><span style="color: #008000;">&#40;</span>mmi, lParam, <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Defs the window proc.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;hwnd&quot;&gt;The HWND.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;msg&quot;&gt;The MSG.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;wParam&quot;&gt;The w param.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;lParam&quot;&gt;The l param.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
        <span style="color: #008000;">&#91;</span>DllImport<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;user32.dll&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">extern</span> IntPtr DefWindowProc<span style="color: #008000;">&#40;</span>IntPtr hwnd, <span style="color: #6666cc; font-weight: bold;">int</span> msg, IntPtr wParam, IntPtr lParam<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080;">#endregion</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> WM_NCCALCSIZE <span style="color: #008000;">=</span> 0x83<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> WM_NCPAINT <span style="color: #008000;">=</span> 0x85<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> WM_NCACTIVATE <span style="color: #008000;">=</span> 0x86<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> WM_GETMINMAXINFO <span style="color: #008000;">=</span> 0x24<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> HwndSource m_hwndSource<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> IntPtr m_hwnd<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> DependencyProperty ResizeWithGripProperty <span style="color: #008000;">=</span> DependencyProperty<span style="color: #008000;">.</span><span style="color: #0000FF;">Register</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ResizeWithGrip&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">&#41;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>BorderlessWindowBehavior<span style="color: #008000;">&#41;</span>, <span style="color: #008000;">new</span> PropertyMetadata<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets or sets a value indicating whether [resize with grip].</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;value&gt;</span>
        <span style="color: #008080; font-style: italic;">///   &lt;c&gt;true&lt;/c&gt; if [resize with grip]; otherwise, &lt;c&gt;false&lt;/c&gt;.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/value&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> ResizeWithGrip
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">&#41;</span>GetValue<span style="color: #008000;">&#40;</span>ResizeWithGripProperty<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetValue<span style="color: #008000;">&#40;</span>ResizeWithGripProperty, value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Called after the behavior is attached to an AssociatedObject.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnAttached<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>AssociatedObject<span style="color: #008000;">.</span><span style="color: #0000FF;">IsInitialized</span><span style="color: #008000;">&#41;</span>
                AddHwndHook<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">else</span>
                AssociatedObject<span style="color: #008000;">.</span><span style="color: #0000FF;">SourceInitialized</span> <span style="color: #008000;">+=</span> AssociatedObject_SourceInitialized<span style="color: #008000;">;</span>
&nbsp;
            AssociatedObject<span style="color: #008000;">.</span><span style="color: #0000FF;">WindowStyle</span> <span style="color: #008000;">=</span> WindowStyle<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span><span style="color: #008000;">;</span>
            AssociatedObject<span style="color: #008000;">.</span><span style="color: #0000FF;">ResizeMode</span> <span style="color: #008000;">=</span> ResizeWithGrip <span style="color: #008000;">?</span> ResizeMode<span style="color: #008000;">.</span><span style="color: #0000FF;">CanResizeWithGrip</span> <span style="color: #008000;">:</span> ResizeMode<span style="color: #008000;">.</span><span style="color: #0000FF;">CanResize</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnAttached</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Called when the behavior is being detached from its AssociatedObject, but before it has actually occurred.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnDetaching<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            RemoveHwndHook<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnDetaching</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Adds the HWND hook.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> AddHwndHook<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            m_hwndSource <span style="color: #008000;">=</span> HwndSource<span style="color: #008000;">.</span><span style="color: #0000FF;">FromVisual</span><span style="color: #008000;">&#40;</span>AssociatedObject<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> HwndSource<span style="color: #008000;">;</span>
            m_hwndSource<span style="color: #008000;">.</span><span style="color: #0000FF;">AddHook</span><span style="color: #008000;">&#40;</span>HwndHook<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            m_hwnd <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WindowInteropHelper<span style="color: #008000;">&#40;</span>AssociatedObject<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Handle</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Removes the HWND hook.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> RemoveHwndHook<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            AssociatedObject<span style="color: #008000;">.</span><span style="color: #0000FF;">SourceInitialized</span> <span style="color: #008000;">-=</span> AssociatedObject_SourceInitialized<span style="color: #008000;">;</span>
            m_hwndSource<span style="color: #008000;">.</span><span style="color: #0000FF;">RemoveHook</span><span style="color: #008000;">&#40;</span>HwndHook<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Handles the SourceInitialized event of the AssociatedObject control.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.EventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> AssociatedObject_SourceInitialized<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            AddHwndHook<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// HWNDs the hook.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;hWnd&quot;&gt;The h WND.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;message&quot;&gt;The message.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;wParam&quot;&gt;The w param.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;lParam&quot;&gt;The l param.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;handled&quot;&gt;if set to &lt;c&gt;true&lt;/c&gt; [handled].&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> IntPtr HwndHook<span style="color: #008000;">&#40;</span>IntPtr hWnd, <span style="color: #6666cc; font-weight: bold;">int</span> message, IntPtr wParam, IntPtr lParam, <span style="color: #0600FF; font-weight: bold;">ref</span> <span style="color: #6666cc; font-weight: bold;">bool</span> handled<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            IntPtr returnval <span style="color: #008000;">=</span> IntPtr<span style="color: #008000;">.</span><span style="color: #0000FF;">Zero</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>message<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> WM_NCCALCSIZE<span style="color: #008000;">:</span>
                    <span style="color: #008080; font-style: italic;">/* Hides the border */</span>
                    handled <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> WM_NCPAINT<span style="color: #008000;">:</span>
                    <span style="color: #008000;">&#123;</span>
                        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Environment<span style="color: #008000;">.</span><span style="color: #0000FF;">OSVersion</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Version</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Major</span> <span style="color: #008000;">&gt;=</span> <span style="color: #FF0000;">6</span><span style="color: #008000;">&#41;</span>
                        <span style="color: #008000;">&#123;</span>
                            var m <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MARGINS <span style="color: #008000;">&#123;</span> bottomHeight <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>, leftWidth <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>, rightWidth <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>, topHeight <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
                            DwmExtendFrameIntoClientArea<span style="color: #008000;">&#40;</span>m_hwnd, <span style="color: #0600FF; font-weight: bold;">ref</span> m<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                        <span style="color: #008000;">&#125;</span>
                        handled <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                    <span style="color: #008000;">&#125;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> WM_NCACTIVATE<span style="color: #008000;">:</span>
                    <span style="color: #008000;">&#123;</span>
                        <span style="color: #008080; font-style: italic;">/* As per http://msdn.microsoft.com/en-us/library/ms632633(VS.85).aspx , &quot;-1&quot; lParam
                         * &quot;does not repaint the nonclient area to reflect the state change.&quot; */</span>
                        returnval <span style="color: #008000;">=</span> DefWindowProc<span style="color: #008000;">&#40;</span>hWnd, message, wParam, <span style="color: #008000;">new</span> IntPtr<span style="color: #008000;">&#40;</span><span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                        handled <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                    <span style="color: #008000;">&#125;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> WM_GETMINMAXINFO<span style="color: #008000;">:</span>
                    <span style="color: #008080; font-style: italic;">/* From Lester's Blog (thanks @aeoth):  
                     * http://blogs.msdn.com/b/llobo/archive/2006/08/01/maximizing-window-_2800_with-windowstyle_3d00_none_2900_-considering-taskbar.aspx */</span>
                    WmGetMinMaxInfo<span style="color: #008000;">&#40;</span>hWnd, lParam<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    handled <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> returnval<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>window<span style="color: #008000;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nareshjois.com/2011/07/zune-window-in-wpf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Play with Clay</title>
		<link>http://www.nareshjois.com/2011/06/play-with-clay/</link>
		<comments>http://www.nareshjois.com/2011/06/play-with-clay/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 08:13:10 +0000</pubDate>
		<dc:creator>naresh</dc:creator>
				<category><![CDATA[.net Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[clay]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[expando]]></category>

		<guid isPermaLink="false">http://www.nareshjois.com/?p=868</guid>
		<description><![CDATA[I have been a big fan of ExpandoObject ever since it was introduced with .net 4.0, and I have been using the Expando Object object ever since, but I always felt that it was not enough, ExpandoObject was fun and all but it was just not enough, and me being really lazy remember coying and [...]]]></description>
			<content:encoded><![CDATA[<p>I have been a big fan of ExpandoObject ever since it was introduced with .net 4.0, and I have been using the Expando Object object ever since, but I always felt that it was not enough, ExpandoObject was fun and all but it was just not enough, and me being really lazy remember coying and pasting code just to loop through properties of a class using reflection and all that headache.</p>
<p>Enter Clay : The moment I have laid my eyes on this beautiful piece of code, I have become a huge fan, and it has all the things the expando should have been.</p>
<p>So How do you begin , Its really simple and also follows unique naming convention you begin with a clay object with New (emphasis on uppercase &#8216;N&#8217;)</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;">dynamic <span style="color: #008000;">New</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ClayFactory<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var cUser <span style="color: #008000;">=</span> <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>and thats it,<br />
In Clay Indexer Syntax and Property Accessors are the same so</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;">cUser<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> cUser<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Name&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span></pre></div></div>

<p>you can pass anonymous objects and also accepts named arguments, you can also use jQuery style chain able setters or put use them as an array</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;">var cUser <span style="color: #008000;">=</span> <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> <span style="color: #008000;">&#123;</span> Name <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Naresh&quot;</span>, Mail <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;something@mail.com&quot;</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var cUser <span style="color: #008000;">=</span> <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">&#40;</span> Name <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;Naresh&quot;</span>, Mail <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;something@mail.com&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var cUser <span style="color: #008000;">=</span> <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Naresh&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Mail</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;something@mail.com&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var Users <span style="color: #008000;">=</span> <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Array</span><span style="color: #008000;">&#40;</span>
           <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Naresh&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Mail</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;something@mail.com&quot;</span><span style="color: #008000;">&#41;</span>,
           <span style="color: #008000;">New</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Rakesh&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Mail</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;something@mail.com&quot;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>So What are you waiting for get started at<br />
<a href="http://clay.codeplex.com/">clay.codeplex.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nareshjois.com/2011/06/play-with-clay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Linq to Find a Control</title>
		<link>http://www.nareshjois.com/2010/10/using-linq-to-find-a-control/</link>
		<comments>http://www.nareshjois.com/2010/10/using-linq-to-find-a-control/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 11:04:04 +0000</pubDate>
		<dc:creator>naresh</dc:creator>
				<category><![CDATA[.net Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://www.nareshjois.com/?p=827</guid>
		<description><![CDATA[I think Every one has one time or the other tried to find a control by looping over and find the required control, but we can use Linq to do the same thing. public static class PageExtensions &#123; public static IEnumerable&#60;control&#62; All&#40;this ControlCollection controls&#41; &#123; foreach &#40;Control control in controls&#41; &#123; foreach &#40;Control grandChild in [...]]]></description>
			<content:encoded><![CDATA[<p>I think Every one has one time or the other tried to find a control by looping over and find the required control, but we can use Linq to do the same thing.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;"> <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> PageExtensions
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> IEnumerable<span style="color: #008000;">&lt;</span>control<span style="color: #008000;">&gt;</span> All<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> ControlCollection controls<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Control control <span style="color: #0600FF; font-weight: bold;">in</span> controls<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Control grandChild <span style="color: #0600FF; font-weight: bold;">in</span> control<span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">All</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #0600FF; font-weight: bold;">yield</span> <span style="color: #0600FF; font-weight: bold;">return</span> grandChild<span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">yield</span> <span style="color: #0600FF; font-weight: bold;">return</span> control<span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>control<span style="color: #008000;">&gt;</span></pre></div></div>

<p>Then you can use as a Linq Expression</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;">var ctrls <span style="color: #008000;">=</span> controls<span style="color: #008000;">.</span><span style="color: #0000FF;">All</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>c <span style="color: #008000;">=&gt;</span> c<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>Button<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nareshjois.com/2010/10/using-linq-to-find-a-control/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mix and Mash Asp.net MVC with Webforms</title>
		<link>http://www.nareshjois.com/2010/10/mix-asp-net-mvc-with-webforms/</link>
		<comments>http://www.nareshjois.com/2010/10/mix-asp-net-mvc-with-webforms/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 07:48:26 +0000</pubDate>
		<dc:creator>naresh</dc:creator>
				<category><![CDATA[.net Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[Asp.net MVC]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Webforms]]></category>

		<guid isPermaLink="false">http://www.nareshjois.com/?p=819</guid>
		<description><![CDATA[A lot of people including me wanted to to get on the bandwagon of ASP.net MVC, but the main problem is we do not always get to start new projects and there is always a timeline hanging. I will not talk about the benefits of MVC Pattern as most of us already aware of it, [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people including me wanted to to get on the bandwagon of ASP.net MVC, but the main problem is we do not always get to start new projects and there is always a timeline hanging. I will not talk about the benefits of MVC Pattern as most of us already aware of it, But for an ASP.net Developer where everything is tied up in Webforms this may seem difficult, but once you start taking advantages of this pattern, the usefulness becomes obvious, me having worked on Rails and PHP frameworks such as CodeIgnitor and CakePHP, It was never a question of If, but when, and the best way to begin would be use your existing skills with webforms and start bringin in MVC Pattern, and before you know it you can be completely taking the benefits out of both worlds.</p>
<h2>Webforms with MVC</h2>
<p>If you are starting with a new project its really simple, start of with a new MVC Project in Visual Studio Add a New Webform run it and thats it no configuration required, the reason is that because MVC Framework is built on top of same ASP.net platform, it runs and the reason why the routing doesn&#8217;t try and hijack this request is because of the way it works, if the physical file of the request exists the request is always made to the aspx file, for better performance and save disk query on each .aspx request you can also add the following line in your global.asax</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> RegisterRoutes<span style="color: #008000;">&#40;</span>RouteCollection routes<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
&nbsp;
            routes<span style="color: #008000;">.</span><span style="color: #0000FF;">IgnoreRoute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{resource}.axd/{*pathInfo}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            routes<span style="color: #008000;">.</span><span style="color: #0000FF;">IgnoreRoute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{resource}.aspx/{*pathInfo}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            routes<span style="color: #008000;">.</span><span style="color: #0000FF;">MapRoute</span><span style="color: #008000;">&#40;</span>
                <span style="color: #666666;">&quot;Default&quot;</span>, <span style="color: #008080; font-style: italic;">// Route name</span>
                <span style="color: #666666;">&quot;{controller}/{action}/{id}&quot;</span>, <span style="color: #008080; font-style: italic;">// URL with parameters</span>
                <span style="color: #008000;">new</span> <span style="color: #008000;">&#123;</span> controller <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Home&quot;</span>, action <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Index&quot;</span>, id <span style="color: #008000;">=</span> UrlParameter<span style="color: #008000;">.</span><span style="color: #0000FF;">Optional</span> <span style="color: #008000;">&#125;</span> <span style="color: #008080; font-style: italic;">// Parameter defaults</span>
            <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008000;">&#125;</span></pre></div></div>

<h2>MVC with Webforms</h2>
<p>But most of us never start with new projects right ?, so you have to do a bit more work, Add the following as Reference to your Web Application<br />
<a href="http://www.nareshjois.com/wp-content/uploads/2010/10/references.png" rel="lightbox[819]"><img src="http://www.nareshjois.com/wp-content/uploads/2010/10/references.png" alt="" title="references" width="500" height="401" class="alignnone size-full wp-image-822" /></a></p>
<p>Now Update your <b>web.config </b> to reflect</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:consolas, monaco;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system</span> .web<span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;compilation</span> <span style="color: #000066;">debug</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">targetFramework</span>=<span style="color: #ff0000;">&quot;4.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assemblies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">assembly</span>=<span style="color: #ff0000;">&quot;System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">assembly</span>=<span style="color: #ff0000;">&quot;System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">assembly</span>=<span style="color: #ff0000;">&quot;System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/assemblies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/compilation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pages<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;namespaces<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;System.Web.Mvc&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;System.Web.Mvc.Ajax&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;System.Web.Mvc.Html&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;System.Web.Routing&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/namespaces<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pages<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
......
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Add the following code to <b>global.asax</b></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;"> <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> RegisterRoutes<span style="color: #008000;">&#40;</span>RouteCollection routes<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            routes<span style="color: #008000;">.</span><span style="color: #0000FF;">IgnoreRoute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{resource}.axd/{*pathInfo}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            routes<span style="color: #008000;">.</span><span style="color: #0000FF;">IgnoreRoute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{resource}.aspx/{*pathInfo}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            routes<span style="color: #008000;">.</span><span style="color: #0000FF;">MapRoute</span><span style="color: #008000;">&#40;</span>
                <span style="color: #666666;">&quot;Default&quot;</span>, <span style="color: #008080; font-style: italic;">// Route name</span>
                <span style="color: #666666;">&quot;{controller}/{action}/{id}&quot;</span>, <span style="color: #008080; font-style: italic;">// URL with parameters</span>
                <span style="color: #008000;">new</span> <span style="color: #008000;">&#123;</span> controller <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Home&quot;</span>, action <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Index&quot;</span>, id <span style="color: #008000;">=</span> UrlParameter<span style="color: #008000;">.</span><span style="color: #0000FF;">Optional</span> <span style="color: #008000;">&#125;</span> <span style="color: #008080; font-style: italic;">// Parameter defaults</span>
            <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
        <span style="color: #6666cc; font-weight: bold;">void</span> Application_Start<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            AreaRegistration<span style="color: #008000;">.</span><span style="color: #0000FF;">RegisterAllAreas</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            RegisterRoutes<span style="color: #008000;">&#40;</span>RouteTable<span style="color: #008000;">.</span><span style="color: #0000FF;">Routes</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008000;">&#125;</span></pre></div></div>

<p>Now Add the Controllers, Views, Folders to the root of application and you are good to go:<br />
<br />
<b>Home Controller &#8211; /Controllers/HomeControllers.cs</b></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:consolas, monaco;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.Mvc</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> WebApp<span style="color: #008000;">.</span><span style="color: #0000FF;">Test</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Controllers</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#91;</span>HandleError<span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> HomeController <span style="color: #008000;">:</span> Controller
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> ActionResult Index<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            ViewData<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Message&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Welcome to ASP.NET MVC!&quot;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> View<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>View &#8211; /Views/Home/Index.aspx</p>

<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:consolas, monaco;"><span style="color: #006600; font-weight: bold;">&lt;</span> <span style="color: #006600; font-weight: bold;">%@</span> Page Language<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;C#&quot;</span> MasterPageFile<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;~/Site.Master&quot;</span> Inherits<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;System.Web.Mvc.ViewPage&quot;</span> <span style="color: #000000; font-weight: bold;">%&gt;</span>
&nbsp;
<span style="color: #006600; font-weight: bold;">&lt;</span>asp<span style="color: #006600; font-weight: bold;">:</span>content ID<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;Content1&quot;</span> ContentPlaceHolderID<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;HeadContent&quot;</span> runat<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;server&quot;</span><span style="color: #006600; font-weight: bold;">&gt;</span>
<span style="color: #006600; font-weight: bold;">&lt;/</span>asp<span style="color: #006600; font-weight: bold;">:</span>content<span style="color: #006600; font-weight: bold;">&gt;</span>
<span style="color: #006600; font-weight: bold;">&lt;</span>asp<span style="color: #006600; font-weight: bold;">:</span>content ID<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;Content2&quot;</span> ContentPlaceHolderID<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;MainContent&quot;</span> runat<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;server&quot;</span><span style="color: #006600; font-weight: bold;">&gt;</span>
  <span style="color: #006600; font-weight: bold;">&lt;</span>h2<span style="color: #006600; font-weight: bold;">&gt;&lt;</span> <span style="color: #006600; font-weight: bold;">%:</span> ViewData<span style="color: #006600; font-weight:bold;">&#91;</span><span style="color: #cc0000;">&quot;Message&quot;</span><span style="color: #006600; font-weight:bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">%&gt;</span><span style="color: #006600; font-weight: bold;">&lt;/</span>h2<span style="color: #006600; font-weight: bold;">&gt;</span>
    <span style="color: #006600; font-weight: bold;">&lt;</span>p<span style="color: #006600; font-weight: bold;">&gt;</span>
        <span style="color: #990099; font-weight: bold;">To</span> learn more about ASP.<span style="color: #9900cc;">NET</span> MVC visit <span style="color: #006600; font-weight: bold;">&lt;</span>a href<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;http://asp.net/mvc&quot;</span> title<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;ASP.NET MVC Website&quot;</span><span style="color: #006600; font-weight: bold;">&gt;</span>http<span style="color: #006600; font-weight: bold;">:</span><span style="color: #ff6600;">//asp.net/mvc&lt;/a&gt;.</span>
    <span style="color: #006600; font-weight: bold;">&lt;/</span>p<span style="color: #006600; font-weight: bold;">&gt;</span>
<span style="color: #006600; font-weight: bold;">&lt;/</span>asp<span style="color: #006600; font-weight: bold;">:</span>content<span style="color: #006600; font-weight: bold;">&gt;</span></pre></div></div>

<p>You can even use the same Master Page<br />
<a href="http://www.nareshjois.com/wp-content/uploads/2010/10/screen1.png" rel="lightbox[819]"><img src="http://www.nareshjois.com/wp-content/uploads/2010/10/screen1-300x227.png" alt="" title="screen1" width="300" height="227" class="alignnone size-medium wp-image-823" /></a><br />
<a href="http://www.nareshjois.com/wp-content/uploads/2010/10/screen2.png" rel="lightbox[819]"><img src="http://www.nareshjois.com/wp-content/uploads/2010/10/screen2-300x227.png" alt="" title="screen2" width="300" height="227" class="alignnone size-medium wp-image-824" /></a></p>
<p>P.S: The VS Project doesn&#8217;t support integrated way of creating Views and Controllers in this method</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nareshjois.com/2010/10/mix-asp-net-mvc-with-webforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cascade Delete with Linq2SQL</title>
		<link>http://www.nareshjois.com/2009/12/cascade-delete-with-linq2sql/</link>
		<comments>http://www.nareshjois.com/2009/12/cascade-delete-with-linq2sql/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 17:46:52 +0000</pubDate>
		<dc:creator>naresh</dc:creator>
				<category><![CDATA[.net Programming]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[LINQ2SQL]]></category>

		<guid isPermaLink="false">http://www.nareshjois.com/?p=660</guid>
		<description><![CDATA[Consider this, you have Invoice and Invioce details in 2 tables and the details are referenced by InvoiceId, What happens to Invoice Details once you delete the invoice ?, In SQL atleast you can do cascade delete and also set the value to null, but most real life programs would want to delete the details, [...]]]></description>
			<content:encoded><![CDATA[<p>Consider this, you have Invoice and Invioce details in 2 tables and the details are referenced by InvoiceId, What happens to Invoice Details once you delete the invoice ?, In SQL atleast you can do cascade delete and also set the value to null, but most real life programs would want to delete the details, Linq2SQL by default tries to set a null value which in most cases fails, and there is no visual way to set this the only way to do this is to do some manual xml editing.<br />
Right click and open the .dbml file with the XML Editor and then navigate to the table for which you want to do this, then look for the relation which references the parent table</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:consolas, monaco;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;association</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">Member</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">ThisKey</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">OtherKey</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">IsForeignKey</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Now add DeleteOnNull=&#8221;true&#8221; to this association so this behaves as expected</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:consolas, monaco;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;association</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">Member</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">ThisKey</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">OtherKey</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">&quot;....&quot;</span> <span style="color: #000066;">IsForeignKey</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">DeleteOnNull</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nareshjois.com/2009/12/cascade-delete-with-linq2sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My latest Work on WPF</title>
		<link>http://www.nareshjois.com/2009/01/my-latest-work-on-wpf/</link>
		<comments>http://www.nareshjois.com/2009/01/my-latest-work-on-wpf/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 18:19:24 +0000</pubDate>
		<dc:creator>naresh</dc:creator>
				<category><![CDATA[.net Programming]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[my work]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.nareshjois.com/?p=268</guid>
		<description><![CDATA[WPF has been here for quite a while now and i done some basic projects on wpf, but for the last two months i had the opportunity to completely work on WPF, not just WPF but also used Linq2SQL as the base for the complete application, wet my hands with ADO.net Entity Model and lot [...]]]></description>
			<content:encoded><![CDATA[<p>WPF has been here for quite a while now and i done some basic projects on wpf, but for the last two months i had the opportunity to completely work on WPF, not just WPF but also used Linq2SQL as the base for the complete application, wet my hands with ADO.net Entity Model and lot of work in Expression Blend,<br />
The software was for KPCC and it an complete automation and information management system for them, I will not reveal much more, but a few screens which are not part of the NDA have been posted here,<br />
<a href="http://www.nareshjois.com/wp-content/uploads/2009/01/kpcc1.png" rel="lightbox[268]"><img src="http://www.nareshjois.com/wp-content/uploads/2009/01/kpcc1-300x190.png" alt="KPCC" title="KPCC" width="300" height="190" class="alignnone size-medium wp-image-267" rel=”lightbox[KPCC]“ /></a><br />
<a href="http://www.nareshjois.com/wp-content/uploads/2009/01/kpcc2.png" rel="lightbox[268]"><img src="http://www.nareshjois.com/wp-content/uploads/2009/01/kpcc2-300x190.png" alt="KPCC" title="KPCC" width="300" height="190" class="alignnone size-medium wp-image-270" rel=”lightbox[KPCC]“/></a><br />
<a href="http://www.nareshjois.com/wp-content/uploads/2009/01/kpcc3.png" rel="lightbox[268]"><img src="http://www.nareshjois.com/wp-content/uploads/2009/01/kpcc3-300x190.png" alt="KPCC" title="KPCC" width="300" height="190" class="alignnone size-medium wp-image-271" rel=”lightbox[KPCC]“/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nareshjois.com/2009/01/my-latest-work-on-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

