<?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>systemsabuse.com &#187; Uncategorized</title>
	<atom:link href="http://www.systemsabuse.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.systemsabuse.com</link>
	<description>helping you abuse your system one day at a time</description>
	<lastBuildDate>Thu, 17 Jun 2010 19:46:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Showing different text (or elements) in a disabled ToolTip versus an enabled ToolTip in WPF</title>
		<link>http://www.systemsabuse.com/2007/09/23/showing-different-text-or-elements-in-a-disabled-tooltip-versus-an-enabled-tooltip-in-wpf/</link>
		<comments>http://www.systemsabuse.com/2007/09/23/showing-different-text-or-elements-in-a-disabled-tooltip-versus-an-enabled-tooltip-in-wpf/#comments</comments>
		<pubDate>Sun, 23 Sep 2007 07:06:25 +0000</pubDate>
		<dc:creator>John Rennemeyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.systemsabuse.com/2007/09/23/showing-different-text-or-elements-in-a-disabled-tooltip-versus-an-enabled-tooltip-in-wpf/</guid>
		<description><![CDATA[I originally started this post with a title of &#8220;WPF ToolTip Child Element Visibility Based on the Parent of the ToolTip IsEnabled Property… and you are not it with a dirty dirty dish rag on your toe reading behind a dirty magazine&#8221;, but I decided that in the best interest of my sanity (read: &#8220;what [...]]]></description>
			<content:encoded><![CDATA[<p>I originally started this post with a title of &#8220;WPF ToolTip Child Element Visibility Based on the Parent of the ToolTip IsEnabled Property… and you are not it with a dirty dirty dish rag on your toe reading behind a dirty magazine&#8221;, but I decided that in the best interest of my sanity (read: &#8220;what sanity&#8221;) that I would make it a little more descriptive to what my goal for creating this functionality was and a lot less wordy (read: less words than the number of pieces of bubble gum in a dish that you wished for). Don&#8217;t ask.</p>
<p>After writing my last post about the advanced tooltip functionality in .NET 2.0 using the <a href="http://components.skybound.ca/Products/VisualTips/">VisualTips</a> component, <strong>I realized that WPF (Windows Presentation Foundation) lacked a way OOTB to create two distinctive tooltips on an element that could be displayed based on whether or not the control was disabled or enabled</strong>. <a href="http://components.skybound.ca/Products/VisualTips/">VisualTips</a> provides this functionality. This helps users to better understand what step they need to take before a control will become enabled and why the heck they can&#8217;t click on it. For instance, in <a target="_blank" href="http://www.muvaudio.com">MuvAudio</a>, the &#8220;Record&#8221; button is disabled until an item has been added to the playlist. When they move their mouse over the button, as of right now, they get no message whatsoever. They don&#8217;t even get the regular tooltip telling them what it would do if it were enabled. (I&#8217;m in the process of implementing the <a href="http://components.skybound.ca/Products/VisualTips/">VisualTips</a> so the next version of <a target="_blank" href="http://www.muvaudio.com">MuvAudio </a>will have the functionality I&#8217;m about to explain). It would make sense to do the following:</p>
<ul>
<li>Make the Record button, in the disabled state, display a message that says: &#8220;To being recording you must first add at least one audio file to the playlist. You can do this by double-clicking anywhere in the playlist area or by clicking on &#8220;Playlist&#8221;, &#8220;Add File(s)&#8221; and selecting the audio files that you would like to record.&#8221;</li>
<li>Make the Record button in the enabled state display: &#8220;Starts the recording process.&#8221;</li>
</ul>
<p>To do this in WPF I had look at the problem from a <a href="http://blogs.msdn.com/karstenj/archive/2006/04/05/curve.aspx">different perspective</a>. Now, I&#8217;m not the greatest programmer in the world and I am definitely am open to suggestion, so please leave me comments, but this is what I came up with:</p>
<p>To add a ToolTip that displays different text based on the enabled/disabled of a button (this can be replaced with any element) that it is the child of:</p>
<p><Button x:Name=”btnToolTip” Content=”My ToolTip displays different elements based on whether I am disabled or enabled” ToolTipService.ShowOnDisabled=”True”><br />
    <Button.ToolTip><br />
        <ToolTip DataContext=”{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}”><br />
            <StackPanel><br />
                <TextBlock x:Name=”buttonToolTipText” Text=”This is a sample tooltip in WPF” /><br />
                <TextBlock FontWeight=”Bold” Text=”This is only shown when the parent control is enabled” Visibility=”{Binding Path=IsEnabled, Converter={StaticResource ToolTipElementVisibilityConverter}, ConverterParameter=VisibleOnEnabled}” /><br />
                <TextBlock FontWeight=”Bold” Text=”This is only shown when the parent control is disabled” Visibility=”{Binding Path=IsEnabled, Converter={StaticResource ToolTipElementVisibilityConverter}, ConverterParameter=VisibleOnDisabled}” /><br />
            </StackPanel><br />
        </ToolTip><br />
    </Button.ToolTip><br />
</Button></p>
<p>The important parts are as follows:</p>
<p>Visibility=”{Binding Path=IsEnabled, Converter={StaticResource ToolTipElementVisibilityConverter}, ConverterParameter=VisibleOnDisabled}”<br />
<!-- vs. --><br />
Visibility=”{Binding Path=IsEnabled, Converter={StaticResource ToolTipElementVisibilityConverter}, ConverterParameter=VisibleOnEnabled}”</p>
<ul>
<li>In the declaration of the Element that will contain the tooltip, you need to make sure you have <span style="font-size: 8pt; font-family: Monaco"><span style="color: red; background-color: silver">ToolTipService.ShowOnDisabled</span><span style="color: blue"><span style="background-color: silver">=&#8221;True&#8221;</span><br />
</span></span>because this allows the tooltip to still be displayed when the element is disabled.</li>
<li>You need to set the DataContext of the tooltip as follows: <span style="font-size: 8pt; font-family: Monaco"><span style="color: red; background-color: silver">DataContext</span><span style="color: blue; background-color: silver">=&#8221;{</span><span style="color: #a31515; background-color: silver">Binding</span><span style="color: red; background-color: silver"> Path</span><span style="color: blue; background-color: silver">=PlacementTarget,</span><span style="color: red; background-color: silver"> RelativeSource</span><span style="color: blue; background-color: silver">={</span><span style="color: #a31515; background-color: silver">RelativeSource</span><span style="color: red; background-color: silver"> Self</span><span style="color: blue"><span style="background-color: silver">}}&#8221;</span>; </span></span>this allows us to set the binding of the IsEnabled property in the elements of the tooltip.</li>
<li>Finally, you need to set the Visibility using a binding with a Converter and a ConverterParameter based on when you want the items to be displayed. In the above example we only want one of the textblocks to be displayed in either state so we have the parameter set to the opposite of each other:
<ul>
<li>The <strong>Path</strong> is bound to the IsEnabled property of the element that is the parent of this tooltip (as described above).</li>
<li>The <strong>Converter</strong> is a converter that we created that returns back the Visibility we want (Visible or Collapsed) based on the IsEnabled property and the ConvertParameter.</li>
<li>The <strong>ConverterParameter</strong> is a string that we use to tell the item to be visible when the item is enabled or when the item is disabled. The two choices are <strong>VisibleOnDisabled</strong> and <strong>VisibleOnEnabled</strong>.</li>
</ul>
</li>
</ul>
<p>The actual converter is contained in the sample project.</p>
<p>As a side, I looked into using enums for the parameter instead of strings but they just added extra code that doesn&#8217;t get taken advantage of (Visual Studio 2008 Beta 2 doesn&#8217;t display auto completion for enums in xaml). An example would look like this: &#8220;ConverterParameter={x:Static local:ToolTipElementVisibility.VisibleOnDisabled}&#8221;, where &#8220;local&#8221; is a xml namespace you would add to the window declaration.</p>
<p>The other pieces of the puzzle are as follows:</p>
<ol>
<li>Add an xml namespace declaration for the converter class to reference the converter (I prefer to add this to the window.xaml the tooltip will be used on): <span style="font-size: 8pt; font-family: Monaco"><span style="color: red; background-color: silver">xmlns</span><span style="color: blue; background-color: silver">:</span><span style="color: red; background-color: silver">cvrt</span><span style="color: blue; background-color: silver">=&#8221;clr-namespace:MuvEnum.ToolTipElementVisibility.Converters&#8221;</span></span></li>
<li>Add the converter as a resource in the same window.xaml you used in #1: <span style="font-size: 8pt; font-family: Monaco"><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">Window.Resources</span><span style="color: blue; background-color: silver">&gt;</span><span style="color: #a31515; background-color: silver">        </span><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">cvrt</span><span style="color: blue; background-color: silver">:</span><span style="color: #a31515; background-color: silver">ToolTipElementVisibilityConverter</span><span style="color: red; background-color: silver"> x</span><span style="color: blue; background-color: silver">:</span><span style="color: red; background-color: silver">Key</span><span style="color: blue; background-color: silver">=&#8221;ToolTipElementVisibilityConverter&#8221; /&gt;</span><span style="color: #a31515; background-color: silver">    </span><span style="color: blue; background-color: silver">&lt;/</span><span style="color: #a31515; background-color: silver">Window.Resources</span><span style="color: blue; background-color: silver">&gt;</span></span></li>
</ol>
<p><strong>A full sample is attached and has a compiled executable.<br />
</strong></p>
<p>You&#8217;re free to use this code in any project you like. A reference to this post would be appreciated but is not required.</p>
<p>After I finished this code, which I&#8217;ll definitely be using in a soon to be finished WPF product, I realized that this goes above and beyond what the <a href="http://components.skybound.ca/Products/VisualTips/">VisualTips</a> for .NET can do by allowing a user to create distinctively different tooltips based on the enabled and/or disabled state of the element they are a child of thanks to the ability of tooltips to host any WPF element.</p>
<p>I assume this idea can be used to bind to other Boolean properties of elements and not just the IsEnabled. One of the most exciting things about WPF is the ability to create things that even those that created WPF didn&#8217;t even foresee. Now that deserves a post of its own.</p>
<p><a href="http://www.systemsabuse.com/wp-content/uploads/2007/09/wpftooltipelementvisibility.zip" title="WPF ToolTip Element Visibility Sample Project">WPF ToolTip Element Visibility Sample Project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.systemsabuse.com/2007/09/23/showing-different-text-or-elements-in-a-disabled-tooltip-versus-an-enabled-tooltip-in-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade your .NET Tooltips to the Office 2007 style</title>
		<link>http://www.systemsabuse.com/2007/09/22/upgrade-your-net-tooltips-to-the-office-2007-style/</link>
		<comments>http://www.systemsabuse.com/2007/09/22/upgrade-your-net-tooltips-to-the-office-2007-style/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 21:47:42 +0000</pubDate>
		<dc:creator>John Rennemeyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.systemsabuse.com/2007/09/22/upgrade-your-net-tooltips-to-the-office-2007-style/</guid>
		<description><![CDATA[I&#8217;m a big fan of the Office 2007 style tooltips and one of the areas where I feel .NET lets me down a little is in the ToolTip department. Here&#8217;s the default .NET ToolTip: Now take a look at the following ToolTips: Not only do they look much better, but they also provide some very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of the Office 2007 style tooltips and one of the areas where I feel .NET lets me down a little is in the ToolTip department.</p>
<p>Here&#8217;s the default .NET ToolTip:</p>
<p><img src="http://www.systemsabuse.com/wp-content/uploads/2007/09/092207-2148-upgradeyour12.png" /></p>
<p>Now take a look at the following ToolTips:</p>
<p><img src="http://www.systemsabuse.com/wp-content/uploads/2007/09/092207-2148-upgradeyour22.png" /></p>
<p><img src="http://www.systemsabuse.com/wp-content/uploads/2007/09/092207-2148-upgradeyour32.png" /></p>
<p><img src="http://www.systemsabuse.com/wp-content/uploads/2007/09/092207-2148-upgradeyour42.png" /></p>
<p>Not only do they look much better, but they also provide some very needed features.</p>
<ol>
<li><strong>Each ToolTip can be defined with an access key</strong>, F2 in the above samples, which provides you with the ability to give extra functionality for each ToolTip.</li>
<li><strong>Each ToolTip can be given a specific &#8220;disabled&#8221; message</strong> that you can define to let your users know why a button is disabled and what the next step would be to get it enabled. In the regular ToolTips, if a control is disabled then no ToolTip is shown.</li>
</ol>
<p>The best part about the above ToolTips is that you can add this functionality to your program for free thanks to <a href="http://components.skybound.ca/">SKYBOUND</a>. Their free .NET component is called <a href="http://components.skybound.ca/Products/VisualTips">VisualTips</a> and it&#8217;s a breeze to implement. They also have a bunch of other free components to help you spruce up your application so definitely check them out.</p>
<p>On a side note, <strong>WPF (.NET 3.0) provides similar functionality out of the box</strong> and here is a xaml sample (not the coolest, but can be beefed up easily):</p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">Button</span><span style="color: red; background-color: silver"> x</span><span style="color: blue; background-color: silver">:</span><span style="color: red; background-color: silver">Name</span><span style="color: blue; background-color: silver">=&#8221;btn1&#8243;</span><span style="color: red; background-color: silver"> HorizontalAlignment</span><span style="color: blue; background-color: silver">=&#8221;Left&#8221;</span><span style="color: red; background-color: silver"> VerticalAlignment</span><span style="color: blue; background-color: silver">=&#8221;Top&#8221;</span><span style="color: red; background-color: silver"> Content</span><span style="color: blue; background-color: silver">=&#8221;Button&#8221;</span><span style="color: red; background-color: silver"> IsEnabled</span><span style="color: blue; background-color: silver">=&#8221;False&#8221;</span><span style="color: red; background-color: silver"> ToolTipService.ShowOnDisabled</span><span style="color: blue; background-color: silver">=&#8221;True&#8221; &gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">Button.ToolTip</span><span style="color: blue; background-color: silver">&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">ToolTip</span><span style="color: red; background-color: silver"> x</span><span style="color: blue; background-color: silver">:</span><span style="color: red; background-color: silver">Name</span><span style="color: blue; background-color: silver">=&#8221;buttonToolTip&#8221;&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">StackPanel</span><span style="color: blue; background-color: silver">&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">Image</span><span style="color: red; background-color: silver"> Source</span><span style="color: blue; background-color: silver">=&#8221;http://www.muvaudio.com/banner/muv2banner170x77.png&#8221; /&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;</span><span style="color: #a31515; background-color: silver">TextBlock</span><span style="color: red; background-color: silver"> x</span><span style="color: blue; background-color: silver">:</span><span style="color: red; background-color: silver">Name</span><span style="color: blue; background-color: silver">=&#8221;buttonToolTipText&#8221;</span><span style="color: red; background-color: silver"> Text</span><span style="color: blue; background-color: silver">=&#8221;This is a sample tooltip in WPF&#8221;/&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;/</span><span style="color: #a31515; background-color: silver">StackPanel</span><span style="color: blue; background-color: silver">&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;/</span><span style="color: #a31515; background-color: silver">ToolTip</span><span style="color: blue; background-color: silver">&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: #a31515; background-color: silver"></span><span style="color: blue; background-color: silver">&lt;/</span><span style="color: #a31515; background-color: silver">Button.ToolTip</span><span style="color: blue; background-color: silver">&gt;<br />
</span></span></p>
<p><span style="font-size: 8pt; font-family: Monaco"><span style="color: blue; background-color: silver">&lt;/</span><span style="color: #a31515; background-color: silver">Button</span><span style="color: blue"><span style="background-color: silver">&gt;</span><br />
</span></span></p>
<p>The <span style="color: red; background-color: silver">ToolTipService.ShowOnDisabled</span><span style="color: blue"><span style="background-color: silver">=&#8221;True&#8221;</span><br />
</span>attribute makes it so the ToolTip is displayed whether or not the control it is attached to is enabled or disabled. In the below screenshot, the control is disabled and you can see the sample WPF ToolTip.</p>
<p><img src="http://www.systemsabuse.com/wp-content/uploads/2007/09/092207-2355-test1.png" /></p>
<p>ToolTips are an important part of the usability of any application, especially when it helps remove the need of requiring the user to read the manual before beginning use of your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.systemsabuse.com/2007/09/22/upgrade-your-net-tooltips-to-the-office-2007-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

