<?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>Tigraine &#187; WPF</title>
	<atom:link href="http://www.tigraine.at/category/programmierung/net/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tigraine.at</link>
	<description>Daniel Hoelbling talks about .NET</description>
	<lastBuildDate>Mon, 06 Sep 2010 20:47:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Untangling the dependency ball! Windsor + NServiceBus + Caliburn + Fluent Nhibernate in one package</title>
		<link>http://www.tigraine.at/2010/09/06/untangling-the-dependency-ball-windsor-nservicebus-caliburn-fluent-nhibernate-in-one-package/</link>
		<comments>http://www.tigraine.at/2010/09/06/untangling-the-dependency-ball-windsor-nservicebus-caliburn-fluent-nhibernate-in-one-package/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 20:47:41 +0000</pubDate>
		<dc:creator>Daniel Hölbling</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.tigraine.at/2010/09/06/untangling-the-dependency-ball-windsor-nservicebus-caliburn-fluent-nhibernate-in-one-package/</guid>
		<description><![CDATA[
Unfortunately nu is still falling short on one thing: Making sure that all the stuff you install is actually compatible with the other stuff you have already installed. There is a ticket for this and I’m fairly confident this will get resolved (please vote the ticket up), but for now I was back to figuring [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tigraine.at/wp-content/uploads/2010/09/confusingroadsignlargewebview.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 3px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="confusing-road-sign-large-web-view" border="0" alt="confusing-road-sign-large-web-view" src="http://www.tigraine.at/wp-content/uploads/2010/09/confusingroadsignlargewebview_thumb.jpg" width="211" height="244" /></a></p>
<p>Unfortunately <a href="http://www.tigraine.at/2010/08/25/the-fastest-way-to-install-dotless-nubular-nu/">nu</a> is still falling short on one thing: Making sure that all the stuff you install is actually compatible with the other stuff you have already installed. There is a <a href="http://github.com/nu/nu/issues/issue/13">ticket for this</a> and I’m fairly confident this will get resolved (please vote the ticket up), but for now I was back to figuring out what version of what framework to use to make my app compile.</p>
<p>As always, the main problem was Castle.Core, being present in 3 different versions. (NSB used version 1.1, Caliburn 1.2 and the latest Windsor release targets 2.5) </p>
<p>I decided to back down and use 1.2 since there is a NHibernate gem for 1.2 and a Windsor gem for 1.2. I’m now using NHibernate 3.0 alpha so think about using this “stack”. </p>
<p>Anyway, this is a collection of:</p>
<ol>
<li>NServiceBus 2.0 .NET 4 (2.0.0.1219)</li>
<li>NServiceBus.ObjectBuilder.CastleWindsor</li>
<li>Castle.Windsor (2.1)</li>
<li>Caliburn 2.0 (still unreleased from the trunk)</li>
<li>NHibernate 3.0.0.1002</li>
<li>FluentNhibernate 1.1 (Updated to NHibernate 3.0)</li>
<li>AutoMapper</li>
</ol>
<p>Disclaimer: The whole thing is built for .NET 4.0 and works on my machine. Don’t blame me if it’s broken for you.</p>
<p>Anyway. You can download the whole package of libraries here: <a href="http://www.tigraine.at/wp-content/uploads/2010/09/castle-stack.rar">castle-stack.rar</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tigraine.at/2010/09/06/untangling-the-dependency-ball-windsor-nservicebus-caliburn-fluent-nhibernate-in-one-package/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Useful Resharper Live Template for WPF development</title>
		<link>http://www.tigraine.at/2010/04/29/useful-resharper-live-template-for-wpf-development/</link>
		<comments>http://www.tigraine.at/2010/04/29/useful-resharper-live-template-for-wpf-development/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 17:13:30 +0000</pubDate>
		<dc:creator>Daniel Hölbling</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.tigraine.at/2010/04/29/useful-resharper-live-template-for-wpf-development/</guid>
		<description><![CDATA[While doing some work in WPF for a customer project I found myself writing far too often code like this:


private bool isSelected;

public bool IsSelected
{
&#160;&#160;&#160;&#160;get { return isSelected; }
&#160;&#160;&#160;&#160;set
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;isSelected = value;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;OnPropertyChanged("IsSelected");
&#160;&#160;&#160;&#160;}
}


Auto-properties simply don’t work with INotifyPropertyChanged so you have to do all the grunt work over again .. Thank god there is Resharper!
It’s said lazyness is [...]]]></description>
			<content:encoded><![CDATA[<p>While doing some work in WPF for a customer project I found myself writing far too often code like this:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:2e6d557b-b705-4c34-b5ad-8606cf99c7de:b615157c-4b99-4860-ba0b-66974eecb1b5" class="wlWriterEditableSmartContent">
<pre name="code" class="csharp">
private bool isSelected;

public bool IsSelected
{
&#160;&#160;&#160;&#160;get { return isSelected; }
&#160;&#160;&#160;&#160;set
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;isSelected = value;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;OnPropertyChanged("IsSelected");
&#160;&#160;&#160;&#160;}
}
</pre>
</div>
<p>Auto-properties simply don’t work with INotifyPropertyChanged so you have to do all the grunt work over again .. Thank god there is Resharper!</p>
<p>It’s said lazyness is a virtue on a programmer, so I made this little Live Template that will create all that code with you only having to fill in type and name of your property:</p>
<p><a href="http://www.tigraine.at/wp-content/uploads/2010/04/image3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.tigraine.at/wp-content/uploads/2010/04/image_thumb2.png" width="236" height="193" /></a> </p>
<p>Download it here: <a href="http://tigraine.at/wpfprop.xml">wpfprop.xml</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tigraine.at/2010/04/29/useful-resharper-live-template-for-wpf-development/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WebKit like focus indicator for WPF Windows</title>
		<link>http://www.tigraine.at/2009/06/22/webkit-like-focus-indicator-for-wpf-windows/</link>
		<comments>http://www.tigraine.at/2009/06/22/webkit-like-focus-indicator-for-wpf-windows/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 11:58:48 +0000</pubDate>
		<dc:creator>Daniel Hölbling</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.tigraine.at/?p=580</guid>
		<description><![CDATA[If you like Chrome/Safari or not, one thing that both have and all others lack is a good focus indicator that graphically shows me where my focus currently is. Jeff Atwood wrote something interesting on the topic of Where the Heck is My Focus:
But even if developers do remember to test for basic keyboard behavior, [...]]]></description>
			<content:encoded><![CDATA[<p>If you like Chrome/Safari or not, one thing that both have and all others lack is a good focus indicator that graphically shows me where my focus currently is. Jeff Atwood wrote something interesting on the topic of <a href="http://www.codinghorror.com/blog/archives/001055.html">Where the Heck is My Focus</a>:</p>
<blockquote><p>But even if developers do remember to test for basic keyboard behavior, there&#8217;s a deeper problem here. <b>Keyboard navigation relies heavily on the focus.</b> In order to move from one area to the next, you have to be able to reliably know where you are. Unfortunately, <b>web browsers make it needlessly difficult to tell where the focus is</b>.</p>
</blockquote>
<p>I believe he not only has a valid point here, but also that his criticism this should not be limited to web browsers. Most if not all Windows applications do this thing badly, and it’s up to us developers to fix it.</p>
<p>So, I decided to try to put my recent WPF research to good use and tried to implement a small class that applies/removes a WebKit like focus caret:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tigraine.at/wp-content/uploads/2009/06/image4.png" width="300" height="145" /> </p>
<p>The whole implementation is completely encapsulated inside a class named <a href="http://bitbucket.org/Tigraine/tigraine-samples/src/tip/WebkitInputs/WebkitFocusEffect.cs">WebkitFocusEffect</a> that only needs to be initialized during your window construction:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:2e6d557b-b705-4c34-b5ad-8606cf99c7de:7d6cb718-92e9-4338-86a2-ae7276ea0b11" class="wlWriterEditableSmartContent">
<pre name="code" class="csharp">
public Window1()
{
&#160;&#160;&#160;&#160;InitializeComponent();

&#160;&#160;&#160;&#160;WebkitFocusEffect.Initialize(this);
}
</pre>
</div>
<h4>How does it work?</h4>
<p>First of all, <a href="http://bitbucket.org/Tigraine/tigraine-samples/src/tip/WebkitInputs/WebkitFocusEffect.cs">the source is available</a> on BitBucket in my <a href="http://bitbucket.org/Tigraine/tigraine-samples/">repository</a>, so you can just go ahead and look at it. But I’ll also try to shed some light about what goes on there.</p>
<h5>Routed Events</h5>
<p>WPF introduced a cool concept called RoutedEvents, meaning that an Event like GotFocus/LostFocus will travel through the object model to the point where it gets handled and stops there. This technique is important because, unlike Windows Forms, WPF controls can contain other UIElements. This gives you far more control over the look and feel of your application, allowing for crazy things like a button with a image instead of text:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:2e6d557b-b705-4c34-b5ad-8606cf99c7de:3bd97067-1206-4c74-9d66-c09fc94c1346" class="wlWriterEditableSmartContent">
<pre name="code" class="xml">
&lt;Button Width="100"&gt;
&#160;&#160;&#160;&#160;&lt;Image Source="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/100px-Smiley.svg.png"&gt;&lt;/Image&gt;
&lt;/Button&gt;
</pre>
</div>
<p>Resulting in this:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tigraine.at/wp-content/uploads/2009/06/image5.png" width="159" height="163" /> </p>
<p>And that leads to the point of RoutedEvents: How do you know that the button was clicked? The event that was fired was the image’s click event, not the button. So, WPF introduced the concept of RoutedEvents that can traverse the object tree upwards and downwards. What means that the image’s ClickEvent gets passed on to it’s direct parent (our friend the button) to get handled there.</p>
<p>&#160;<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tigraine.at/wp-content/uploads/2009/06/image6.png" width="400" height="235" /> </p>
<p>If not handled at some level the event would travel up through the whole tree until reaching the root.</p>
<p>I used this technique to hook up the GotFocus/LostFocus events on our window (being the root element), relying on the fact that any GotFocus events by it’s children will bubble upwards the graph eventually reaching the window’s handler.</p>
<p>The handler then just unwraps the event’s source object (the source of the RoutedEvent gets passed along through the RoutedEventArgs parameter) and modifies it’s Effect property:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:2e6d557b-b705-4c34-b5ad-8606cf99c7de:53353ad9-5043-497d-ac84-588d9db99247" class="wlWriterEditableSmartContent">
<pre name="code" class="csharp">
protected virtual void WindowGotFocus(object sender, RoutedEventArgs e)
{
&#160;&#160;&#160;&#160;try
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!(e.Source is UIElement)) return;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;var element = (UIElement) e.Source;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (element.Effect == null)
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;var effect = new DropShadowEffect {Color = Colors.Gold, ShadowDepth = 0, BlurRadius = 8};
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;element.Effect = effect;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;removeEffect = true;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;catch (Exception ex)
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Log(ex);
&#160;&#160;&#160;&#160;}
}
</pre>
</div>
<p>One problem still remained: RoutedEvents can stop bubbling if they get handled at a lower level. This is how the button stops the image’s click event from spreading to it’s parent element, therefore containing it. So if you set an RoutedEventArgs.Handled property to true, it will stop bubbling up the tree:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:2e6d557b-b705-4c34-b5ad-8606cf99c7de:63d90cb1-6644-4e6f-8b6a-e3a523361c63" class="wlWriterEditableSmartContent">
<pre name="code" class="csharp">
private void LoginButton_GotFocus(object sender, RoutedEventArgs e)
{
&#160;&#160;&#160;&#160;//This Event was handled and will not call Window's GotHandled eventhandler
&#160;&#160;&#160;&#160;e.Handled = true;
}
</pre>
</div>
<p>Cool though is that RoutedEvents can’t really be stopped from bubbling, they do so anyway. Handled events just don’t invoke any event handlers up the tree any more, and that can be overridden explicitly when subscribing to the event:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:2e6d557b-b705-4c34-b5ad-8606cf99c7de:a647969b-f8d9-404d-af20-0b63b8797ed8" class="wlWriterEditableSmartContent">
<pre name="code" class="csharp">
window.AddHandler(UIElement.GotFocusEvent, new RoutedEventHandler(WindowGotFocus), true);
</pre>
</div>
<p>The last parameter is “handledEventsToo” and if set to true the event handler will be fired even if the event was already handled at a lower level. Allowing us to still do our thing while not getting in your way when subscribing to GotFocus / LostFocus events.</p>
<h5>Effect</h5>
<p>One little limitation is there though. Currently there is no EffectGroup container similar to the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.effects.bitmapeffectgroup.aspx">BitmapEffectGroup</a>, and therefore only one effect can be applied to any UIElement at one time. So WebkitFocusEffect will just skip elements that already have a Effect defined.</p>
<p>I consciously went with the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.effects.dropshadoweffect.aspx">DropShadowEffect</a> and not with the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.effects.outerglowbitmapeffect.aspx">OuterGlowBitmapEffect</a> because Effects are hardware accelerated (means they get processed by your idle graphics card instead of the CPU) and will not slow your application down as BitmapEffects would. </p>
</p>
<p>You can download the <a href="http://bitbucket.org/Tigraine/tigraine-samples/src/tip/WebkitInputs/WebkitFocusEffect.cs">WebkitFocusEffect.cs</a> through Bitbucket.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tigraine.at/2009/06/22/webkit-like-focus-indicator-for-wpf-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
