<?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>Ben Dewey - Web, XAML, and Cloud &#187; WPF</title>
	<atom:link href="http://www.bendewey.com/index.php/tag/wpf/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bendewey.com</link>
	<description>Father, Developer, Microsoft MVP, Speaker, and Author</description>
	<lastBuildDate>Sat, 22 Mar 2025 05:04:02 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.41</generator>
	<item>
		<title>Extending the SampleData Strings in Expression Blend</title>
		<link>http://www.bendewey.com/index.php/254/extending-the-sampledata-strings-in-expression-blend</link>
		<comments>http://www.bendewey.com/index.php/254/extending-the-sampledata-strings-in-expression-blend#comments</comments>
		<pubDate>Wed, 02 Jun 2010 14:59:15 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Expression Blend]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/blog/?p=254</guid>
		<description><![CDATA[I was working today on a WPF project in Expression Blend that used Sample Data heavily.  I needed to create my own custom sample data format, after searching.]]></description>
				<content:encoded><![CDATA[<p>I was working today on a WPF project in Expression Blend that used Sample Data heavily.  I needed to create my own custom sample data format, after searching a bit for a way to extend the Expression Sample Data string formats and not having any luck I decided to dig around on my own.  To my suprise this was extremely easy to accomplish so I wanted to post this so that others might be able to benefit from this.</p>
<p>I was building a testing application and I wanted to create sample data for Duration (eg: 00:00:00.0135098).  The closest sample I found was Time, but that actually produced an AM/PM time (eg: 12:00:00 AM).</p>
<a href="http://www.bendewey.com/blog/wp-content/uploads/2010/06/before-extending.png"><img class="alignnone size-medium wp-image-255" title="before-extending" src="http://www.bendewey.com/blog/wp-content/uploads/2010/06/before-extending-300x244.png" alt="" width="300" height="244" /></a>
<p>If you open up &#8216;C:\Program Files\Microsoft Expression\Blend 3\SampleDataResources\en&#8217; on your computer you will see a Data and Images folder inside the Data folder is a CSV file called SampleStrings.csv. </p>
<a href="http://www.bendewey.com/blog/wp-content/uploads/2010/06/data-folder.png"><img class="alignnone size-medium wp-image-256" title="data-folder" src="http://www.bendewey.com/blog/wp-content/uploads/2010/06/data-folder-300x232.png" alt="" width="300" height="232" /></a>
<p>I created a backup first (as you should) and then opened the file in Excel.  From there I simply added my new field for Duration and saved the file.  After closing Expression Blend and restarting it I opened my sample data and found the new values that I added ready for my use.</p>
<a href="http://www.bendewey.com/blog/wp-content/uploads/2010/06/after-extending.png"><img class="alignnone size-medium wp-image-257" title="after-extending" src="http://www.bendewey.com/blog/wp-content/uploads/2010/06/after-extending-300x253.png" alt="" width="300" height="253" /></a>
<p>In my scenario I had 10 rows of sample data, but I only entered 5 rows of data into the SampleStrings.csv file.  The data simple repeated just as I expected.</p>
<a href="http://www.bendewey.com/blog/wp-content/uploads/2010/06/sample-data.png"><img class="alignnone size-medium wp-image-258" title="sample-data" src="http://www.bendewey.com/blog/wp-content/uploads/2010/06/sample-data-300x204.png" alt="" width="300" height="204" /></a>
<p>Thank you to the Expression Blend Team for creating such and easy extension model and I hope this helps someone else along the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/254/extending-the-sampledata-strings-in-expression-blend/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to Live Search using the HttpClient</title>
		<link>http://www.bendewey.com/index.php/79/connecting-to-live-search-using-the-httpclient</link>
		<comments>http://www.bendewey.com/index.php/79/connecting-to-live-search-using-the-httpclient#comments</comments>
		<pubDate>Sat, 14 Mar 2009 15:46:50 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bendewey.wordpress.com/?p=79</guid>
		<description><![CDATA[Preview 2 of the WCF REST Starter Kit has been posted to CodePlex. Check it out at http://tinyurl.com/wcf-rest-kit2. Included in this latest release of the.]]></description>
				<content:encoded><![CDATA[<p>Preview 2 of the WCF REST Starter Kit has been posted to CodePlex. Check it out at <a href="http://tinyurl.com/wcf-rest-kit2" target="_blank">http://tinyurl.com/wcf-rest-kit2</a>. Included in this latest release of the WCF REST Starter Kit are a great new set of client connection tools that make consumption of RESTful services a breeze.</p>
<p>At the forefront of these client connection tools is the HttpClient. This class allows quick and easy access to download any content from a url. I&#8217;ve created a simple WPF Application that demonstrates using the HttpClient and the Live Search API.  For more information on the LiveSearch API or to get your LiveSearch API Key goto <a href="http://dev.live.com/getstarted/">http://dev.live.com/getstarted/</a></p>
<a href="http://www.bendewey.com/code/LiveSearch.png"><img class="alignnone" title="LiveSearch Demo Screenshot" src="http://www.bendewey.com/code/LiveSearchThumbnail.png" alt="" width="200" height="131" /></a>
<p>Click here to <a title="LiveSearchUsingRest.zip (15KB)" href="http://www.bendewey.com/code/LiveSearchUsingRest.zip">Download the Full Source Code</a></p>
<h3>Windows Live Search WPF Application</h3>
<p>This WPF Application consists of a Window with some code-behind,  and a LiveSearch.cs file that was created using the <a href="http://social.msdn.microsoft.com/content/en-us/msft/netframework/wcf/rest/ReleaseNotes" target="_blank">Paste as XML Type</a> feature of the WCF REST Starter Kit.  Before you can serialize your results from the Live Search API you need to run the query in your browser and copy the xml results into your clipboard.  After that you can go into Visual Studio and create a file in your project called LiveSearch.cs and then go to Edit-&gt; Paste as XML Type.  As for the WPF Window it has a Grid with 2 rows and 3 columns.  In the top row is a search textbox and two buttons.  In the second row is a ScrollViewer that contains an ItemsControl. </p>
<p>The first button does a single threaded search call to the Live Api and sets the ItemsSource of the ItemsControl.  As you can see by the code below its very simple, first we construct the uri, then we call .Get on that uri.  The Get call returns an HttpResponseMessage.  The response message has a number of different chaining methods and extension methods,  we are using the EnsureStatusIsSuccess, which is equivalent to the EnsureStatusIs(HttpStatusCode.OK).  After we call EnsureStatusIsSuccessful (which returns the original message or an exception) we can read the content.  In this case we are reading the content as a xml serialized response of the type created above using the Paste as XML Type feature.</p>
<pre class="brush: csharp; title: ; notranslate">
private void Search_Click(object sender, RoutedEventArgs e)
{
      string liveApi = &quot;Your Live Api&quot;;
      string uriFormat = &quot;http://api.search.live.net/xml.aspx?AppId={0}&amp;Market=en-US&amp;Query={1}&amp;Sources=web&amp;Web.Count=25&quot;;

      using (var client = new HttpClient())
      {
          string uri = string.Format(uriFormat, liveApi, this.SearchText.Text);

          var response = client.Get(uri).EnsureStatusIsSuccessful()
              .Content.ReadAsXmlSerializable&lt;searchResponse&gt;();

          this.Results.ItemsSource = response.Web.Results;
      }
}
</pre>
<p>Since its not recommended to run potentially long running operation on the UI thread.  I created a second button to demonstate the Live Search feature using the SendAsync method.  Below is the code for that.</p>
<pre class="brush: csharp; title: ; notranslate">
private void SearchAsync_Click(object sender, RoutedEventArgs e)
{
      string liveApi = &quot;Your Live Api&quot;;
      string uriFormat = &quot;http://api.search.live.net/xml.aspx?AppId={0}&amp;Market=en-US&amp;Query={1}&amp;Sources=web&amp;Web.Count=25&quot;;

      var client = new HttpClient();
      string uri = string.Format(uriFormat, liveApi, this.SearchText.Text);

      client.SendCompleted += client_SendCompleted;
      client.SendAsync(new HttpRequestMessage(HttpMethod.GET.ToString(), uri));
}

void client_SendCompleted(object sender, SendCompletedEventArgs e)
{
      var response = e.Response.EnsureStatusIsSuccessful()
              .Content.ReadAsXmlSerializable&lt;searchResponse&gt;();

      this.Results.ItemsSource = response.Web.Results;
}
</pre>
<p>Feel free to download the full demo using the link above, I hope you enjoy it. The new client connect features of the WCF REST Starter Kit create a really simple way of communicating with third party REST services.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/79/connecting-to-live-search-using-the-httpclient/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NativeFileTypeViewer : FileIconImageConverter &#8211; Convert a filename to the file system icon.</title>
		<link>http://www.bendewey.com/index.php/7/nativefiletypeviewer-fileiconimageconverter-convert-a-filename-to-the-file-system-icon</link>
		<comments>http://www.bendewey.com/index.php/7/nativefiletypeviewer-fileiconimageconverter-convert-a-filename-to-the-file-system-icon#comments</comments>
		<pubDate>Sat, 23 Feb 2008 02:44:20 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Binding Converter]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bendewey.wordpress.com/?p=7</guid>
		<description><![CDATA[I&#8217;ve recently been creating more desktop applications and I often needed to print out the system icons for standard files.  In the past I had used Photoshop.]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve recently been creating more desktop applications and I often needed to print out the system icons for standard files.  In the past I had used Photoshop to crop out the icons and I ended up only supportting a limited number of file icons.  And as I was writing this post I also found a shell32 <a title="How to use the SHGetFileInfo function to get the icons that are associated with files in Visual C# .NET" href="http://support.microsoft.com/kb/319350" target="_blank">tatic</a>  used to create ImageLists in WinForms.</p>
<p>In order to load the system file icons and descriptions for my WPF applications, I built this Binding Converter.  The FileIconImageConverter.cs file is an IValueConverter that accepts  a filename or full file path.  The Converter supports caching and both 32-pixel and 16-pixel icons.  With the exception of the cache checking functionality, this converter has 4 main parts. First it creates a blank 0kb text file the the same extension as the source filename.  Second it loads a <a title="SHFILEINFO" href="http://msdn2.microsoft.com/en-us/library/bb759792(VS.85).aspx" target="_blank">SHFILEINFO</a> Struct using Win32.<a title="SHGetFileInfo" href="http://msdn2.microsoft.com/en-us/library/bb762179(VS.85).aspx" target="_blank">SHGetFileInfo</a> and creates an Icon from the handle. Third it creates Bitmap from the Icon and saves it to a MemoryStream as a PNG.  Finally it loads the ImageSource using a PngBitmapDecoder from the previous Memory Stream.</p>
<p>I would love to give credit to <a title="WPF - Assigning Icon to Image control" href="http://infosysblogs.com/microsoft/2007/04/wpf_assigning_icon_to_image_co.html" target="_blank">Atul Gupta&#8217;s Blog</a>, which help me out a lot with this.  I haven&#8217;t tried it in Silverlight, please let me know if you try it.  Please see my website for the full code.</p>
<p><a href="http://www.bendewey.com/code/FilenameIconImageConverter.html">http://www.bendewey.com/code/FilenameIconImageConverter.html</a></p>
<p>This little application, called the <a title="Full Code" href="http://www.bendewey.com/code/FilenameIconImageConverter.html" target="_blank">NativeFileTypeViewer</a> (<a title="Download Source Code" href="http://www.bendewey.com/code/NativeFileTypeViewer.zip" target="_blank">source code</a>), loads a directory and converts the filenames into the filename descriptions and the file icon, to demonstrate the use of the binding converters.</p>
<img src="http://www.bendewey.com/code/NativeFileTypeViewer.gif" border="0" alt="Native FileType Viewer" width="379" height="345" />
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/7/nativefiletypeviewer-fileiconimageconverter-convert-a-filename-to-the-file-system-icon/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Swoosh Button</title>
		<link>http://www.bendewey.com/index.php/4/swoosh-button</link>
		<comments>http://www.bendewey.com/index.php/4/swoosh-button#comments</comments>
		<pubDate>Thu, 14 Feb 2008 15:21:18 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Controls]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bendewey.wordpress.com/?p=4</guid>
		<description><![CDATA[I created this little swoosh button, as I call it, as my main button design for most of my apps. There are three colors for.]]></description>
				<content:encoded><![CDATA[<p>I created this little swoosh button, as I call it, as my main button design for most of my apps.  There are three colors for now but it can easily be adapted to support multiple more. There is a standard blue color, a red color (i used for the cancel buttons), and a green color (I used for the OK and Next Buttons) .  I also think the button looks really good with all caps text.</p>
<p>I keep trying to come up with a good way to pass the color in without creating a custom control.  If anyone has any thought please feel free to share.</p>
<p><a href="http://www.bendewey.name/code/swooshButton.html" title="Code" target="_blank"></a>Enjoy</p>
<img src="http://bendewey.files.wordpress.com/2008/02/button.jpg" alt="SwooshButton" /><img src="http://bendewey.files.wordpress.com/2008/02/buttonover.thumbnail.jpg" alt="BlueSwoosh" />
<h3>Usage</h3>
<p class="MsoNormal"><span style="font-size:10pt;font-family:'Courier New';color:blue;">&lt;</span><span style="font-size:10pt;font-family:'Courier New';color:#a31515;">Button</span><span style="font-size:10pt;font-family:'Courier New';color:red;"> Width</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">=&#8221;60&#8243;</span><span style="font-size:10pt;font-family:'Courier New';color:red;"> x</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">:</span><span style="font-size:10pt;font-family:'Courier New';color:red;">Name</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">=&#8221;browse&#8221;</span><span style="font-size:10pt;font-family:'Courier New';color:red;"> Style</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">=&#8221;{</span><span style="font-size:10pt;font-family:'Courier New';color:#a31515;">StaticResource</span><span style="font-size:10pt;font-family:'Courier New';color:red;"> SwooshButton</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">}&#8221;&gt;</span><span style="font-size:10pt;font-family:'Courier New';color:#a31515;">Browse</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">&lt;/</span><span style="font-size:10pt;font-family:'Courier New';color:#a31515;">Button</span><span style="font-size:10pt;font-family:'Courier New';color:blue;">&gt;</span></p>
<h3>Code</h3>
<p><a href="http://www.bendewey.name/code/swooshButton.html" title="Code" target="_blank">http://www.bendewey.name/code/swooshButton.html</a></p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/4/swoosh-button/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
