<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>dotUpdate()</title>
	<atom:link href="http://dotupdate.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotupdate.wordpress.com</link>
	<description>Useful information about C# and .Net</description>
	<lastBuildDate>Sun, 06 Nov 2011 15:46:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dotupdate.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>dotUpdate()</title>
		<link>http://dotupdate.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dotupdate.wordpress.com/osd.xml" title="dotUpdate()" />
	<atom:link rel='hub' href='http://dotupdate.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using WMP and Quicktime in Silverlight (Revisited)</title>
		<link>http://dotupdate.wordpress.com/2011/11/06/using-wmp-and-quicktime-in-silverlight-revisited/</link>
		<comments>http://dotupdate.wordpress.com/2011/11/06/using-wmp-and-quicktime-in-silverlight-revisited/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 15:34:30 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/?p=63</guid>
		<description><![CDATA[In 2007, I was working on a Silverlight application in which I wanted to change the rate of speech playback without affecting the pitch.  At that time, the media element available to Silverlight did not have a rate control while Windows Media Player works wonderfully for mp3 files.  I found that I could actually use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=63&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In 2007, I was working on a Silverlight application in which I wanted to change the rate of speech playback without affecting the pitch.  At that time, the media element available to Silverlight did not have a rate control while Windows Media Player works wonderfully for mp3 files.  I found that I could actually use WMP in a Silverlight application by embedding the player in the HTML file that hosted the Silverlight control and then controlling the player by using a bridge between managed C# and JavaScript.  <a href="http://dotupdate.wordpress.com/2007/08/15/using-wmp-and-quicktime-with-silverlight/">The technique was documented in this blog post.</a></p>
<p>Since then, changes to Silverlight and browsers that have broken this code.</p>
<p>I resurrected the old code base and ported it to Silverlight 4.  The code can be tested <a href="http://dl.dropbox.com/u/11809820/MediaDemo4.Web/MediaDemoTestPage.html">here</a>.  And you can download a zip file of the web project <a href="http://dl.dropbox.com/u/11809820/MediaDemo4.zip">here</a>.  The code is still a bit dated and &#8216;hackish&#8217; but has been tested on IE9, Chrome 15 and Firefox 3.6 with the WMP plug-in installed.  For some reason, the volume control does not work in Chrome.  I also forced Chrome to use the Quicktime player instead of WMP.  It works, but Quicktime does not preserve the pitch when the rate is changed so it will sound weird at slow speeds.  I did not test on a Mac.</p>
<p>Silverlight 5 is supposed to have a new media element that has a rate control function.  If it works as well as WMP, then this approach will no longer be necessary.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=63&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2011/11/06/using-wmp-and-quicktime-in-silverlight-revisited/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>Using maps in a Windows 8 Metro application</title>
		<link>http://dotupdate.wordpress.com/2011/10/29/using-maps-in-a-windows-8-metro-application/</link>
		<comments>http://dotupdate.wordpress.com/2011/10/29/using-maps-in-a-windows-8-metro-application/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 19:46:07 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[HTML/JavaScript]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Windows 8]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/?p=49</guid>
		<description><![CDATA[There are many uses for detailed, interactive maps in mobile and desktop applications.  The basic and advanced mapping functionality can be supplied by Google or Bing map APIs.  This post will show how to integrate these maps into a Windows 8 Developer Preview application. Currently, there is no map control for Metro development so one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=49&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://dotupdate.files.wordpress.com/2011/10/mapimage.jpg"><img src="http://dotupdate.files.wordpress.com/2011/10/mapimage.jpg?w=550&#038;h=343" alt="" title="Screen shot of app" width="550" height="343" class="alignnone size-full wp-image-59" /></a>There are many uses for detailed, interactive maps in mobile and desktop applications.  The basic and advanced mapping functionality can be supplied by Google or Bing map APIs.  This post will show how to integrate these maps into a Windows 8 Developer Preview application.</p>
<p>Currently, there is no map control for Metro development so one solution is to use a JavaScript map API in an element that can be hosted in the application.  Security restrictions make this approach tricky and, as far as I know, it is only possible to do this using the HTML/JavaScript programming environment.</p>
<p>The security issue is that the main application in the <em>local context </em>may not load scripts that are external to the host.  Of course, for both Google and Bing map APIs require an external script load.  The solution is to use an iframe element in the body of the main app that refers to a local html page that operates in a <em>web context </em>and is able to load foreign scripts.  The <strong>postMessage() </strong>method is used to communicate between the two pages.</p>
<p>In the following example a simple application displays a map, a button and a status output.  The Google map API is used but it could easily be converted to use the Bing map API.  The map displays two markers: one on Paris and the other, Rouen, France.  Clicking the button sends a command to the map page.  The command is to zoom to a set of coordinates (for Paris).  If you click on one of the markers on the map, the city name is set back to the parent page (the main app) and is displayed in the status output.</p>
<p>For purposes of this example, the messaging system is very simple.  It would be possible to create a more generalized function that could be used for a variety of such applications.</p>
<p>Here are the main files:</p>
<p>First, the <strong>default.html</strong> containing the main display.  There is an iframe element which refers to another local file, map.html.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
    &lt;title&gt;Map Help Example&lt;/title&gt;
    &lt;!-- WinJS references --&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;/winjs/css/ui-dark.css&quot; /&gt;
    &lt;script src=&quot;/winjs/js/base.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;/winjs/js/ui.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;winjs/js/binding.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;/winjs/js/animations.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;/winjs/js/uicollections.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;/winjs/js/wwaapp.js&quot;&gt;&lt;/script&gt;
    &lt;!-- WinWebApp2 references --&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;/css/default.css&quot; /&gt;
    &lt;script src=&quot;/js/default.js&quot;&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;appBody&quot;&gt;
        &lt;h1 id=&quot;head_title&quot; class = &quot;win-title&quot;&gt;
            Map Example&lt;/h1&gt;
        &lt;div id=&quot;status&quot;&gt;
            Hello&lt;/div&gt;
        &lt;button type=&quot;submit&quot; id=&quot;paris&quot;&gt;Paris&lt;/button&gt;
        &lt;div id=&quot;mapSection&quot;&gt;
            &lt;iframe id=&quot;mapIframe&quot; src=&quot;ms-wwa-web:///map.html&quot;&gt;&lt;/iframe&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This is the <strong>map.html</strong> which holds the container for the actual map.  In addition to the map.js script, it loads the Google map API.</p>
<pre class="brush: xml;">
&lt;!--This file is used to render the map API and will be included in an iFrame of the main html.--&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;

    &lt;title&gt;Map&lt;/title&gt;
    &lt;link href=&quot;winjs/css/ui-light.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;!-- We can include remote scripts because it is rendered in the web context (ms-wwa-web:///map.html)  --&gt;
    &lt;script src=&quot;http://maps.googleapis.com/maps/api/js?sensor=false&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/map.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;style type=&quot;text/css&quot;&gt;

        #map
        {
          position:absolute;
          width:100%;
          height:100%;
        }

    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;map&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Here is the <strong>default.js</strong> which manages the main program UI.  Note that the command is an object that is serialized to a string so that it can be transmitted to the map using postMessage().  There is also a function to receive a simple message from the map page to display on the status line.</p>
<pre class="brush: jscript;">

(function () {
    'use strict';

    Debug.enableFirstChanceException(true);

    function id(elementId) {
        return document.getElementById(elementId);
    }

    WinJS.Application.onmainwindowactivated = function (e) {
        if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {

            WinJS.UI.processAll();

            //Button event listener
            paris.addEventListener(&quot;click&quot;, changeLocation, false);
        }
    }

    WinJS.Application.start();

    //Button event handler which sends a command to the map to zoom to Paris.
    function changeLocation(e) {

        id(&quot;status&quot;).innerText = &quot;Zooming to Paris&quot;;

        //Construct a message to send
        var msg = {
            command: 'zoomTo',
            latitude: 48.863811,
            longitude: 2.351761,
            zoom: 8
        };

        //Convert message object to string and send to the map control.
        var msgS = JSON.stringify(msg);
        document.frames['mapIframe'].postMessage(msgS, &quot;ms-wwa-web://&quot; + document.location.host);
    }

    //Receive message from map and displays to status output
    window.addEventListener(&quot;message&quot;, receiveMessage, false);
    function receiveMessage(event) {
        if (event.origin === &quot;ms-wwa-web://&quot; + document.location.host) {
            id(&quot;status&quot;).innerText = &quot;Hello from &quot; + event.data;
        }
    }
})();
</pre>
<p>Here is the <strong>map.js</strong> which controls the map.  It receives the string message and converts it back to an object where it is interpreted and operated on.  Map events such as the clicking of a marker are handled by sending a message back to the parent page.</p>
<pre class="brush: jscript;">

//This script handles all of the controls to the map API
(function () {
    'use strict';

    var map;

    //Process messages from main script
    window.addEventListener(&quot;message&quot;, receiveMessage, false);
    function receiveMessage(event) {
        if (event.origin === &quot;ms-wwa://&quot; + document.location.host) {

            //Return the message string to an object
            var messageObject = JSON.parse(event.data);

            //If message is to zoom, change the location and zoom level
            if (messageObject.command == &quot;zoomTo&quot;) {
                var newCenter = new google.maps.LatLng(messageObject.latitude, messageObject.longitude);
                var newOptions = {
                    zoom: messageObject.zoom,
                    center: newCenter,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                map.setOptions(newOptions);
            }
        }
    }

    //This function sends a message back to the parent window.
    function sendMessageBack(city) {
        window.parent.postMessage(city, &quot;ms-wwa://&quot; + document.location.host);
    }

    function initialize() {
        //initialize the map
        var latlng = new google.maps.LatLng(38.96, -96.78);
        var myOptions = {
            zoom: 4,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById(&quot;map&quot;),
        myOptions);

        //Add a couple of pushpins with event handlers
        var parisLocation = new google.maps.LatLng(48.863811, 2.351761);
        var marker1 = new google.maps.Marker({
            position: parisLocation,
            map: map,
            title: &quot;This is Paris&quot;
        });
        google.maps.event.addListener(marker1, 'click', function () {
            sendMessageBack(&quot;Paris&quot;);
        });

        var rouenLocation = new google.maps.LatLng(49.4467, 1.085889);
        var marker2 = new google.maps.Marker({
            position: rouenLocation,
            map: map,
            title: &quot;This is Rouen&quot;
        });
        google.maps.event.addListener(marker2, 'click', function () {
            sendMessageBack(&quot;Rouen&quot;);
        });
    }

    document.addEventListener(&quot;DOMContentLoaded&quot;, initialize, false);
})();
</pre>
<p>Finally, here is the <strong>default.css</strong> file which defines the layout of the main application elements.</p>
<pre class="brush: css;">

#appBody
{
    width: 100%;
    height: 100%;
    display: -ms-grid;
    -ms-grid-rows: 100px 85px 520fr 60px;
    -ms-grid-columns: 42px 405px 9px 846fr 64px;
}

#head_title
{
    margin-bottom: -8px;
    margin-top: 0px;
    -ms-grid-column: 2;
    -ms-grid-row-align: end;
    -ms-grid-column-span: 5;
}

#mapSection
{
    -ms-grid-column: 4;
    -ms-grid-row: 1;
    -ms-grid-row-span: 4;
    -ms-grid-column-span: 2;
}

#mapIframe
{
    width: 100%;
    height: 100%;
}

#status
{
    -ms-grid-column: 2;
    -ms-grid-row: 2;
    -ms-grid-row-align: center;
}

#paris
{
    -ms-grid-column: 2;
    -ms-grid-row: 3;
    width: 59px;
    height: 35px;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=49&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2011/10/29/using-maps-in-a-windows-8-metro-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>

		<media:content url="http://dotupdate.files.wordpress.com/2011/10/mapimage.jpg" medium="image">
			<media:title type="html">Screen shot of app</media:title>
		</media:content>
	</item>
		<item>
		<title>Data binding made simple</title>
		<link>http://dotupdate.wordpress.com/2011/09/01/data-binding-made-simple/</link>
		<comments>http://dotupdate.wordpress.com/2011/09/01/data-binding-made-simple/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 02:51:36 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/?p=32</guid>
		<description><![CDATA[Data binding is a very important topic for WPF and Silverlight applications and Microsoft has created a very rich set of functionality in the frameworks to make it work in a variety of ways.  The problem is there are so many ways of doing things that I find the documentation from different sources to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=32&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Data binding is a very important topic for WPF and Silverlight applications and Microsoft has created a very rich set of functionality in the frameworks to make it work in a variety of ways.  The problem is there are so many ways of doing things that I find the documentation from different sources to be quite confusing.</p>
<p>Today, I was working on a little application which should be very amenable to the use of data binding UI controls (listboxes and textboxes) to data objects.  After being away from WPF for a time, I was struggling to relearn exactly the best way to do it.  The MSDN documentation is thorough but is TMI at times.</p>
<p>I finally ran across a tutorial that captures the essence of what I needed to do in this application as well as others that I have worked on in the past.  If you want a clear example of how to implement data binding for either Silverlight or WPF, I recommend you check out <a href="http://www.singingeels.com/Articles/Silverlight_DataBinding_Basics.aspx">this post. </a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=32&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2011/09/01/data-binding-made-simple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>Synchronizing media with animation in Silverlight</title>
		<link>http://dotupdate.wordpress.com/2010/11/04/synchronizing-media-with-animation-in-silverlight/</link>
		<comments>http://dotupdate.wordpress.com/2010/11/04/synchronizing-media-with-animation-in-silverlight/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 14:22:47 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/?p=28</guid>
		<description><![CDATA[I am working on a project which consists of several rather long animations that I am building in Blend.  I ran into a problem in adding sound clips that should be played in specific points in the timeline.  Since storyboard only has one event (the end), there was no clear way of starting MediaElement at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=28&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am working on a project which consists of several rather long animations that I am building in Blend.  I ran into a problem in adding sound clips that should be played in specific points in the timeline.  Since storyboard only has one event (the end), there was no clear way of starting MediaElement at any specific point in a timeline.</p>
<p>I was directed to a couple of sites for solutions to this problem:</p>
<p><a href="http://social.expression.microsoft.com/Forums/en/blend/thread/87edfec5-d5a2-4b62-abc6-f68b6e583090">Solution 1</a></p>
<p><a href="http://live.visitmix.com/Sessions#?term=ex21">Solution 2</a></p>
<p>But I came up with a variation that fits my application a little better.</p>
<p>1. Add a textbox to the artboard with an opacity of zero.</p>
<p>2. Add a TextChanged handler for this textbox.</p>
<p>3. In the handler set up &#8216;if else&#8217; constructs that launch media playback if a specific string is detected in the Text property.</p>
<p>4. In the timeline add keyframes on the textbox that change the Text property to your trigger strings at any point in the animation.</p>
<p>5. For the MediaElement, I set the AutoPlay to true.  Then whenever I change the media source property (in the TextChanged handler), the sound is played.</p>
<p>With this technique, a storyboard is started with various animations.  One of the items animated is the invisible textbox Text field.  When the animation changes the text to a specific keyword, the event handler for the textbox fires and the text field is compared with a list of keywords that trigger the loading of a corresponding media source to the MediaElement which then plays it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=28&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2010/11/04/synchronizing-media-with-animation-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>Find the color of a point in a LinearGradientBrush</title>
		<link>http://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/</link>
		<comments>http://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 12:54:22 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/</guid>
		<description><![CDATA[I became intrigued by the problem of finding the color at any point of a rectangle that has been filled with a LinearGradientBrush.&#160; There is are techniques for doing this by essentially sampling the pixel at a rendered point but I wanted to approach the problem algorithmically. I developed the following method which receives a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=24&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I became intrigued by the problem of finding the color at any point of a rectangle that has been filled with a LinearGradientBrush.&nbsp; There is are techniques for doing this by essentially sampling the pixel at a rendered point but I wanted to approach the problem algorithmically.</p>
<p>I developed the following method which receives a rectangle object that has been filled with a LinearGradientBrush and a point relative to the upper left corner of the rectangle and returns the calculated color at that point.&nbsp; There are no restrictions on the Start/Stop Points or the number of GradientStops.&nbsp; The ColorInterpolationMode can be either SRgbLinearInterpolation (default) or ScRgbLinearInterpolation.&nbsp; The GradientSpreadMethod is required to be the default (Pad).</p>
<p>There are two methods below:</p>
<p>Color GetColorAtPoint(Rectangle r, Point p) &#8211; finds the color at any point of a LinearGradientBrush filled rectangle.</p>
<p>private Double dist(Point px, Point po, Point pf) &#8211; helper method for GetColorAtPoint.</p>
<p>To use, copy both methods to your class and call GetColorAtPoint() with a rectangle and point.</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//Calculates the color of a point in a rectangle that is filled</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//with a LinearGradientBrush.</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> Color GetColorAtPoint(Rectangle theRec, Point thePoint)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">{</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//Get properties</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    LinearGradientBrush br = (LinearGradientBrush)theRec.Fill;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> y3 = thePoint.Y;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> x3 = thePoint.X;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> x1 = br.StartPoint.X * theRec.ActualWidth;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> y1 = br.StartPoint.Y * theRec.ActualHeight;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    Point p1 = <span style="color:#0000ff;">new</span> Point(x1, y1); <span style="color:#008000;">//Starting point</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> x2 = br.EndPoint.X * theRec.ActualWidth;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> y2 = br.EndPoint.Y * theRec.ActualHeight;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    Point p2 = <span style="color:#0000ff;">new</span> Point(x2, y2);  <span style="color:#008000;">//End point</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//Calculate intersecting points </span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    Point p4 = <span style="color:#0000ff;">new</span> Point(); <span style="color:#008000;">//with tangent</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">if</span> (y1 == y2) <span style="color:#008000;">//Horizontal case</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        p4 = <span style="color:#0000ff;">new</span> Point(x3, y1);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (x1 == x2) <span style="color:#008000;">//Vertical case</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        p4 = <span style="color:#0000ff;">new</span> Point(x1, y3);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">else</span> <span style="color:#008000;">//Diagnonal case</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">double</span> m = (y2 - y1) / (x2 - x1);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">double</span> m2 = -1 / m;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">double</span> b = y1 - m * x1;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">double</span> c = y3 - m2 * x3;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">double</span> x4 = (c - b) / (m - m2);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">double</span> y4 = m * x4 + b;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        p4 = <span style="color:#0000ff;">new</span> Point(x4, y4);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//Calculate distances relative to the vector start</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> d4 = dist(p4, p1, p2);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> d2 = dist(p2, p1, p2);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> x = d4 / d2;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//Clip the input if before or after the max/min offset values</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> max = br.GradientStops.Max(n =&gt; n.Offset);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">if</span> (x &gt; max)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        x = max;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> min = br.GradientStops.Min(n =&gt; n.Offset);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">if</span> (x &lt; min)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        x = min;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//Find gradient stops that surround the input value</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    GradientStop gs0 = br.GradientStops.Where(n =&gt; n.Offset &lt;= x).OrderBy(n =&gt; n.Offset).Last();</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    GradientStop gs1 = br.GradientStops.Where(n =&gt; n.Offset &gt;= x).OrderBy(n =&gt; n.Offset).First();</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">float</span> y = 0f;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">if</span> (gs0.Offset != gs1.Offset)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        y = (<span style="color:#0000ff;">float</span>)((x - gs0.Offset) / (gs1.Offset - gs0.Offset));</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//Interpolate color channels</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    Color cx = <span style="color:#0000ff;">new</span> Color();</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">if</span> (br.ColorInterpolationMode == ColorInterpolationMode.ScRgbLinearInterpolation)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">float</span> aVal = (gs1.Color.ScA - gs0.Color.ScA) * y + gs0.Color.ScA;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">float</span> rVal = (gs1.Color.ScR - gs0.Color.ScR) * y + gs0.Color.ScR;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">float</span> gVal = (gs1.Color.ScG - gs0.Color.ScG) * y + gs0.Color.ScG;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">float</span> bVal = (gs1.Color.ScB - gs0.Color.ScB) * y + gs0.Color.ScB;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        cx = Color.FromScRgb(aVal, rVal, gVal, bVal);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">else</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">byte</span> aVal = (<span style="color:#0000ff;">byte</span>)((gs1.Color.A - gs0.Color.A) * y + gs0.Color.A);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">byte</span> rVal = (<span style="color:#0000ff;">byte</span>)((gs1.Color.R - gs0.Color.R) * y + gs0.Color.R);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">byte</span> gVal = (<span style="color:#0000ff;">byte</span>)((gs1.Color.G - gs0.Color.G) * y + gs0.Color.G);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">byte</span> bVal = (<span style="color:#0000ff;">byte</span>)((gs1.Color.B - gs0.Color.B) * y + gs0.Color.B);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        cx = Color.FromArgb(aVal, rVal, gVal, bVal);</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">return</span> cx;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">}</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">&nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//Helper method for GetColorAtPoint</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//Returns the signed magnitude of a point on a vector with origin po and pointing to pf</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">double</span> dist(Point px, Point po, Point pf)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">{</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">double</span> d = Math.Sqrt((px.Y - po.Y) * (px.Y - po.Y) + (px.X - po.X) * (px.X - po.X));</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">if</span> (((px.Y &lt; po.Y) &amp;&amp; (pf.Y &gt; po.Y)) ||</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        ((px.Y &gt; po.Y) &amp;&amp; (pf.Y &lt; po.Y)) ||</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">        ((px.Y == po.Y) &amp;&amp; (px.X &lt; po.X) &amp;&amp; (pf.X &gt; po.X)) ||</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        ((px.Y == po.Y) &amp;&amp; (px.X &gt; po.X) &amp;&amp; (pf.X &lt; po.X)))</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">        d = -d;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">return</span> d;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">}</pre>
</div>
</div>
<p>The method works by projecting the input point onto the vector that is described by the LinearGradientBrush Start/Stop points.&nbsp; There are special cases for horizontal and vertical lines.&nbsp; The width of the line is calculated as well as the relative distance of the projected point from the StartPoint (using the dist() method).&nbsp; The GradientStops are ordered and two stops are found that are the closest the projected point.&nbsp; The color channel values are interpolated based on the relative position of the projected point and these two stops.&nbsp; The values are assembled into a color and returned.</p>
<p>You can download a demo of this method <a href="http://home.comcast.net/~boddie/HelpWithColorPick.zip">here.</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotupdate.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotupdate.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=24&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>No Events Tab in WPF Designer &#8212; No Problem!</title>
		<link>http://dotupdate.wordpress.com/2008/01/12/no-events-tab-in-wpf-designer-no-problem/</link>
		<comments>http://dotupdate.wordpress.com/2008/01/12/no-events-tab-in-wpf-designer-no-problem/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 16:52:05 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[Cider]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/2008/01/12/no-events-tab-in-wpf-designer-no-problem/</guid>
		<description><![CDATA[When I first encountered &#8216;Cider&#8217;, the designer for WPF, I was somewhat shocked and disappointed that the Properties window did not have an Events tab as in the Windows Forms designer where one can easily browse the available events and simply double-click to hook one up to an automatically generated event handler stub.  Was I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=23&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I first encountered &#8216;Cider&#8217;, the designer for WPF, I was somewhat shocked and disappointed that the Properties window did not have an Events tab as in the Windows Forms designer where one can easily browse the available events and simply double-click to hook one up to an automatically generated event handler stub.  Was I going to have to now rely on the documentation to find the events and carefully type in the connection code and handler?</p>
<p>I said,<strong> &#8220;Very</strong> inconvenient!  Too much work.  I&#8217;ll stick to Forms!&#8221;  From the forums, I see that I was not alone.</p>
<p>Fortunately, Intellisense makes this a non-issue.  Just know the technique:</p>
<p>In Xaml, put your cursor after the control&#8217;s tag (Button, Ellipse, Grid etc) and press the spacebar.  Intellisense will list all of the properties and events that are available.  Note the events are marked with the lightning bolt.  Select an event from the list and hit the tab key twice.  This will add the event to the control&#8217;s attribute list and add an event handler stub in your code behind. </p>
<p>Simple.</p>
<p>Note that the effort is almost identical to using the Events tab in Windows Forms.  The only difference is that you have to scroll through a combined list of properties and events and instead of double clicking, you &#8216;double tab&#8217;.</p>
<p>Or, if you wish, in the code behind, in the window (or page) constructor, type the name of the control (button1 for example) then a &#8216;.&#8217;.  Intellisense will list all properties, methods and events.  Select the event.  Then type &#8216;+=&#8217; and hit the tab key twice.  Your event will be hooked up along with an event handler stub.  (This is the same as designing with Forms.)</p>
<p>Of course there are some common default events that can be hooked up just by double clicking on the object in the designer.  That is, if you double click on a button in the designer, you get a Button_Click event hookup.</p>
<p>The only thing that is really lacking is the little synopsis of what the event does that is provided by the Properties/Events window in the Forms designer; however, the event names are usually pretty self explanatory.</p>
<p>Hooking up events in the WPF designer are no big deal thanks to the Intellisense support and a little knowledge of how to use it.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotupdate.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotupdate.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=23&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2008/01/12/no-events-tab-in-wpf-designer-no-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>Kaxaml: The XAML editor for me</title>
		<link>http://dotupdate.wordpress.com/2008/01/11/kaxaml-the-xaml-editor-for-me/</link>
		<comments>http://dotupdate.wordpress.com/2008/01/11/kaxaml-the-xaml-editor-for-me/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 13:38:36 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/2008/01/11/kaxaml-the-xaml-editor-for-me/</guid>
		<description><![CDATA[I highly recommend Kaxaml for your XAML editor.&#160; Not only does it look and work great but it also has some very useful features not found on other XAML editors. I won&#8217;t bother listing all of the features that you can read about here, but my favorites are Intellisense support (with code completion!), snippets including [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=22&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I highly recommend Kaxaml for your XAML editor.&nbsp; Not only does it look and work great but it also has some very useful features not found on other XAML editors.</p>
<p>I won&#8217;t bother listing all of the features that you can read about <a href="http://notstatic.com/archives/121">here</a>, but my favorites are Intellisense support (with code completion!), snippets including a generous collection of simple control styles and the ability to create and save your own, drag and drop, a beautiful color picker, and a XAML scrubber.</p>
<p>With other XAML editors, I thought, &#8220;what&#8217;s the point? Just use the designer in Visual Studio.&#8221;&nbsp; But Kaxaml is one tool that I will use <em>first</em> to build and customize my UIs&#8211;largely due to its snippets, colorpicker and ease of use.&nbsp; (I don&#8217;t use Blend.)</p>
<p>Download Kaxaml here: <a href="http://www.kaxaml.com">www.kaxaml.com</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotupdate.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotupdate.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=22&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2008/01/11/kaxaml-the-xaml-editor-for-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>Generating Reports in Visual C# 2008 Express Edition</title>
		<link>http://dotupdate.wordpress.com/2008/01/03/generating-reports-in-visual-c-2008-express-edition/</link>
		<comments>http://dotupdate.wordpress.com/2008/01/03/generating-reports-in-visual-c-2008-express-edition/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 00:18:15 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/2008/01/03/generating-reports-in-visual-c-2008-express-edition/</guid>
		<description><![CDATA[A common question on the MSDN C# Express forum is how do I generate reports?&#160; That is, how does one get a printout of data?&#160; The Standard and higher editions of Visual Studio have reporting services that allow reports to be easily designed in a WYSIWYG way.&#160; But Express users must either buy a third [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=21&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A common question on the MSDN C# Express forum is how do I generate reports?&nbsp; That is, how does one get a printout of data?&nbsp; The Standard and higher editions of Visual Studio have reporting services that allow reports to be easily designed in a WYSIWYG way.&nbsp; But Express users must either buy a third party application (à la Crystal Reports&#8211;about $300 USD) or programmatically create the report using C# and GDI+ Classes.</p>
<p>Now with Visual C# 2008 Express Edition, there is a new option.&nbsp; Windows Presentation Foundation (WPF) provides a set of classes for converting markup (XAML) to Microsoft&#8217;s XML Page Specification (XPS).&nbsp; XPS documents can then be printed directly from your application or saved an viewed and printed by other applications and platforms.</p>
<p>With this system, there are a couple of options:&nbsp; First, you can specify the report document directly in C# code much like you would using GDI+.&nbsp; That is, you could place a textBlock or graphic at a specific x,y coordinate on a page using the properties of these elements.&nbsp; The second option is almost as good as having a report designer like in the higher Visual Studio editions.&nbsp; You can use the designer in Visual Studio to layout your report in a WPF grid so you can see exactly how your report should look when it is rendered.&nbsp; Then it is a very simple matter to pass the name of this grid to XPS generating classes for printing or saving.</p>
<p>Printing and XPS in WPF are covered thoroughly in Chapter 15 of <a href="http://www.oreilly.com/catalog/9780596510374/">Sells &amp; Griffiths, Programming WPF, O&#8221;Reilly.</a></p>
<p>The following example shows the routine for saving a grid1 (and all that it contains) to an XPS file.</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> button1_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e)
{
    Microsoft.Win32.SaveFileDialog dialog = <span style="color:#0000ff;">new</span> Microsoft.Win32.SaveFileDialog();
    <span style="color:#0000ff;">if</span> (dialog.ShowDialog() == <span style="color:#0000ff;">true</span>)
    {
        <span style="color:#0000ff;">string</span> xpsOutputPath = dialog.FileName;
        <span style="color:#0000ff;">using</span> (XpsDocument xpsFile = <span style="color:#0000ff;">new</span> XpsDocument(xpsOutputPath, FileAccess.Write))
        {
            XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(xpsFile);
            xpsdw.Write(grid1);
        }
    }

}</pre>
</div>
<p>&nbsp;</p>
<p>This routine requires adding a couple of references to the solution: ReachFramework and System.Printing.&nbsp; You will need to also add some namespace references:</p>
<p>using System.Windows.Xps;<br />using System.IO;<br />using Microsoft.Win32;<br />using System.Windows.Xps.Packaging;</p>
<p>The code for printing directly is not much more complex and is described in the book.</p>
<p>With WPF one should be able to quickly and easily create a rich looking data report that can be printed or saved.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotupdate.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotupdate.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=21&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2008/01/03/generating-reports-in-visual-c-2008-express-edition/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>Using custom controls in WPF applications</title>
		<link>http://dotupdate.wordpress.com/2007/12/06/using-custom-controls-in-wpf-applications/</link>
		<comments>http://dotupdate.wordpress.com/2007/12/06/using-custom-controls-in-wpf-applications/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 15:43:23 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/2007/12/06/using-custom-controls-in-wpf-applications/</guid>
		<description><![CDATA[One thing that has frustrated me in both Silverlight and WPF applications is the use of custom controls&#8211;not their creation but how to add them to my project.  With all of the namespaces, assemblies, references that have to be used just right, my success rate has been about 50-50.  Every time I think I know [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=20&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One thing that has frustrated me in both Silverlight and WPF applications is the use of custom controls&#8211;not their creation but how to add them to my project.  With all of the namespaces, assemblies, references that have to be used just right, my success rate has been about 50-50.  Every time I think I know the technique, I get floored by some mysterious error.  And God help you if you try to change the namespace of something!  I can easily get my solution in an unrecoverable state!</p>
<p>Google to the rescue?  Hardly. While there are many sites with examples of custom controls, they usually go into great detail about the creation but not how to successfully add it to your project.  This piece of magic is assumed to be obvious.  When the application is shown, the namespaces and assembly names are often the same as the project or other names in the solution so it was not so clear which name is the important reference.</p>
<p>So this post is my attempt to help anyone else who might have this problem by documenting the rules (that seem to work for me) for adding a custom (or user) control to your project.</p>
<h4>Scenario 1: Add new User Control</h4>
<p>This should be the easiest to do.</p>
<ol>
<li>1. Project &gt; Add User Control</li>
<li>2. In the dialog box now is the time to name the control.  In my example it will be <strong>LocalUserControl</strong> .  This will add the .xaml and .cs files for the control which can be used to create the control</li>
<li>3. In the .xaml file for the application that is going to use the control, add a reference to the namespace that is used by the UserControl like this:  xmlns:local=&#8221;clr-namespace:AddingControls&#8221;  Unless you have made namespace changes to the UserControl, this will be the same namespace as your application. </li>
<li>4. Refer to the UserControl in your xaml file with the local tag: &lt;local:LocalUserControl /&gt; (The designer may not show the control immediately.  You may have to run the application one time.)</li>
<li>5. If you add an x:Name attribute to the control in the .xaml, you can reference it in the .cs file.</li>
</ol>
<h4>Scenario 2: Add existing User Control to your solution</h4>
<p>Suppose you have an application with a local UserControl that you would like to use and possibly modify in a new application.  You want to add the source code of this control to your project.</p>
<ol>
<li>1. Project &gt; Add Existing Item</li>
<li>2. Browse to the solution folder that you are going to get the control from and select both the .xaml and .cs files for the control.  These should be added to your new solution.</li>
<li>3. In the .xaml file for the application that is going to use the control, add a reference to the namespace that is used by the UserControl like this:  &lt;xmlns:local=&#8221;clr-namespace:AnotherUserControlProj&#8221;/&gt;  Note that this will probably be different than the namespace for the application you are creating. </li>
<li>4. Refer to the UserControl in your xaml file with the local tag: &lt;local:AnExistingControl /&gt; (The designer may not show the control immediately.  You may have to run the application one time.)</li>
<li>5. If you add an x:Name attribute to the control in the .xaml, you can reference it in the .cs file.</li>
</ol>
<h4>Scenario 3: Using an externally referenced control (.dll)</h4>
<p>User controls may be supplied in .dll form.  This is how you will get third party controls, most likely.</p>
<ol>
<li>1. Project &gt; Add Reference&#8230;</li>
<li>2. Browse to the .dll to be used and add it.</li>
<li>3. In the .xaml file for the application that is going to use the control, add a reference to the namespace of the control and to its assembly like this: &lt;xmlns:local3=&#8221;clr-namespace:Microsoft.Samples.CustomControls;assembly=ColorPicker&#8221; /&gt; Both of these items will have to be provided in order to use the control.</li>
<li>4. Refer to the UserControl in your xaml file with the local tag: &lt;local:ColorThumb /&gt;</li>
<li>5. If you add an x:Name attribute to the control in the .xaml, you can reference it in the .cs file.</li>
</ol>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotupdate.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotupdate.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=20&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2007/12/06/using-custom-controls-in-wpf-applications/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
		<item>
		<title>How to add a WPF control library template to Visual C# Express 2008</title>
		<link>http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/</link>
		<comments>http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 14:05:48 +0000</pubDate>
		<dc:creator>dotupdate</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/</guid>
		<description><![CDATA[Visual C# Express 2008 does not come with a project template for creating custom controls (.dll files).&#160; You can create your own template by following these steps: 1. Open Visual C# Express 2008. 2. Create New WPF Application with name: MyLibrary 3. Project &#62; Add User Control 4. In Solution Explorer, Delete Window1.xaml and App.xaml [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=19&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Visual C# Express 2008 does not come with a project template for creating custom controls (.dll files).&nbsp; You can create your own template by following these steps:</p>
<ol>
<li>1. Open Visual C# Express 2008. </li>
<li>2. Create New WPF Application with name: MyLibrary </li>
<li>3. Project &gt; Add User Control </li>
<li>4. In Solution Explorer, Delete Window1.xaml and App.xaml (the corresponding .cs files should be deleted by this step) </li>
<li>5. Project &gt; MyLibrary Properties &gt; Application &gt; Output Type = Class Library </li>
<li>6. Build Solution.&nbsp; There should be no errors and the bin/Release folder should have a MyLibrary.dll file </li>
<li>7. File &gt; Export Template </li>
<li>8. Select Project Template then Next </li>
<li>9. Under Template Options change name to: WPF Control Library and Description: Create WPF Control .dll</li>
</ol>
<p>The next time you open VS, you will find your newly created template ready to use.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotupdate.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotupdate.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotupdate.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotupdate.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotupdate.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotupdate.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotupdate.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotupdate.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotupdate.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotupdate.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotupdate.wordpress.com&amp;blog=1510168&amp;post=19&amp;subd=dotupdate&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37b04d480ecd15e5890aa8cd26eb184a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dotupdate</media:title>
		</media:content>
	</item>
	</channel>
</rss>
