<?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>eighty eight percent nerd.</title>
	<atom:link href="http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.eightyeightpercentnerd.dreamhosters.com</link>
	<description>My fumbling through silverlight... blogs are a nice way to jot down thoughts.</description>
	<lastBuildDate>Thu, 29 Oct 2009 23:31:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[Silverlight 2, C#] How to tell if a Storyboard is currently running?</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=333</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=333#comments</comments>
		<pubDate>Thu, 29 Oct 2009 21:30:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[storyboard]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=333</guid>
		<description><![CDATA[To do this you can check the current ClockState of the animation.

bool isRunning = (MyStoryboard.GetCurrentState() == ClockState.Active);

]]></description>
			<content:encoded><![CDATA[<p>To do this you can check the current <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.clockstate.aspx">ClockState </a>of the animation.</p>
<pre class="brush: csharp;">
bool isRunning = (MyStoryboard.GetCurrentState() == ClockState.Active);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=333</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[C# 3.0+] Annonymous Types</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=326</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=326#comments</comments>
		<pubDate>Fri, 09 Oct 2009 16:56:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[annonymous types]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=326</guid>
		<description><![CDATA[What Does it do?
Annonymous Types

var annon = new { name1 = var1, name2 = var2, ... };
// or
obj annon = new { name1 = var1, name2 = var2, ... };

// Example
obj results = new { OriginalRequest = myRequest, Data = foundData, Status = dataStatus };
// Now you can see results.Data!

Limitations
I had originally wanted to use [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What Does it do?</strong></p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb397696.aspx">Annonymous Types</a></p>
<pre class="brush: csharp;">
var annon = new { name1 = var1, name2 = var2, ... };
// or
obj annon = new { name1 = var1, name2 = var2, ... };

// Example
obj results = new { OriginalRequest = myRequest, Data = foundData, Status = dataStatus };
// Now you can see results.Data!
</pre>
<p><strong>Limitations</strong><br />
I had originally wanted to use this to pass a complex, dynamic object back from a function, however, I soon found out that this was not possible [without the use of reflection]:</p>
<blockquote><p><a href="http://www.west-wind.com/weblog/posts/189329.aspx"><strong>From Rick Strahl&#8217;s Blog</strong></a><br />
One very important aspect to understand about anonymous types is that they are a compiler generated construct. The type is a regular .NET type similar to any other but it has one big limitation: Anonymous types are scoped only to the currently executing method. Because the generated type is anonymous there&#8217;s no public name for the type that you can access. In other words you can&#8217;t instantiate the type directly on your own and you can&#8217;t reference the type outside of the method that created it.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=326</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[Javascript] Time, timers and time differences</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=316</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=316#comments</comments>
		<pubDate>Wed, 26 Aug 2009 18:16:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=316</guid>
		<description><![CDATA[This should be easy, and perhaps I&#8217;m making it harder then it should be&#8230; I&#8217;m used to using the DateTime object, which confuses me when I have to switch back to javascript.
Anyhoot&#8230; here is how I have created a pseudo-timer that will spit out the time difference in seconds from when the timer is started [...]]]></description>
			<content:encoded><![CDATA[<p>This should be easy, and perhaps I&#8217;m making it harder then it should be&#8230; I&#8217;m used to using the DateTime object, which confuses me when I have to switch back to javascript.</p>
<p>Anyhoot&#8230; here is how I have created a pseudo-timer that will spit out the time difference in seconds from when the timer is started to when it is stopped.</p>
<p>Obviously this is simple, and can only time one thing at any given time&#8230; but you get the idea.</p>
<pre class="brush: javascript;">
var startTime;

function startTimer()
{
  // Set the global start time to &quot;now&quot;
  startTime = new Date();
}

function findTimeDiff(message)
{
  // Uses the global startTime.
  // valueOf() spits out in milliseconds, so /1000 to get seconds.
  var diffInSeconds = ((new Date()).valueOf() - startTime.valueOf())/1000;
  alert(message + &quot; [&quot; + diffInSeconds + &quot; seconds]&quot;);
}

...

startTimer();
LengthyFunction();
findTimeDiff(&quot;Time to run LengthyFunction&quot;);

startTimer();
LengthyFunction2();
findTimeDiff(&quot;Time to run LengthyFunction2&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=316</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lack of updates :(</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=314</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=314#comments</comments>
		<pubDate>Thu, 30 Jul 2009 20:09:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=314</guid>
		<description><![CDATA[Sorry for my lack of updates&#8230; I&#8217;ve been pulled off my Silverlight projects for the time and have been moved onto other tasks which involve jquery and Ext. Hopefully I&#8217;ll be back on C# track again soon!
]]></description>
			<content:encoded><![CDATA[<p>Sorry for my lack of updates&#8230; I&#8217;ve been pulled off my Silverlight projects for the time and have been moved onto other tasks which involve jquery and Ext. Hopefully I&#8217;ll be back on C# track again soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=314</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Silverlight 2, C#] Datagrid Not Sorting?</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=303</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=303#comments</comments>
		<pubDate>Wed, 10 Jun 2009 16:44:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[ienumerable]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=303</guid>
		<description><![CDATA[So I&#8217;ve been playing around with Siverlight datagrids.  I have an xml page stuffed with data which I read into a custom class I made to store an xml node and it&#8217;s properties&#8230; I then databind a List of myClass to the datagrid itemsource and everything works fine &#8211; sorting worked fine right out [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been playing around with Siverlight datagrids.  I have an xml page stuffed with data which I read into a custom class I made to store an xml node and it&#8217;s properties&#8230; I then databind a List of myClass to the datagrid itemsource and everything works fine &#8211; sorting worked fine right out of the box.</p>
<p>But then I decided to add my own context filtering to my grid, where the datagrid source is filtered based on input from the user in a textbox.  I used a LINQ query on the List of myClass to do my filtering and when I databound the result of my LINQ query to my datagrid, BAM, the auto column sorting stopped working; the arrows on each of the columns just didn&#8217;t show up.  </p>
<p><strong>The Problem:</strong><br />
I was a little confused, but after a quick google search it appears that:<br />
1. You must databind to a class that implements the IList interface [gives access to the Sort method] to get the auto sorting to work on a datagrid.<br />
2. My LINQ query returns <em>System.Collections.Generic.IEnumerable</em>.<br />
3. IEnumerable does NOT implement IList, but List does.</p>
<p><strong>The Solution: </strong><br />
Use the ToList() function on the returned IEnumberable to create List of the results so that we DO have access to the Sort() method.</p>
<pre class="brush: csharp;">
var filteredResults = from x in m_alarmList
  where (x.customProp.Contains(searchVal))
  select x;

_myDataGrid.ItemsSource = filteredResults.ToList();
</pre>
<p>Thanks to <a href="http://blogs.msdn.com/scmorris/archive/2008/06/10/sorting-data-in-the-silverlight-datagrid.aspx">this post</a>: For bringing the difference between IEnumberable and List to my attention.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=303</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[Silverlight 2] Great FAQ Page</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=300</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=300#comments</comments>
		<pubDate>Thu, 04 Jun 2009 17:02:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[faq]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=300</guid>
		<description><![CDATA[I just bumped into this FAQ page on the Silverlight forums and I think it is an excellent read to become familiarized with some of the most common pitfalls people encounter when coding with Silverlight.
Silverlight.net FAQ Page
[This link posted 6/4/2009 and may change in the future.  At time of posting this was based on [...]]]></description>
			<content:encoded><![CDATA[<p>I just bumped into this FAQ page on the Silverlight forums and I think it is an excellent read to become familiarized with some of the most common pitfalls people encounter when coding with Silverlight.</p>
<p><a href="http://silverlight.net/forums/t/95440.aspx">Silverlight.net FAQ Page</a><br />
[This link posted 6/4/2009 and may change in the future.  At time of posting this was based on Silverlight 2]</p>
<p>Some of the topics I found interesting include:</p>
<ul>
<li> XML Namescopes and when new namescopes are created</li>
<li> Cross domain policies </li>
<li> What graphic features are and are NOT included in Silverlight 2</li>
<li> How to properly use Storyboards on multiple elements</li>
<li> Using InitParams to get data into your Silverlight app</li>
<li> How to minimize memory leaks in Silverlight</li>
<li> &#8230; and more &#8230;
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=300</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Silverlight 2, C#] Writing to and Reading from an IsoStorage File at the Same Time!</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=286</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=286#comments</comments>
		<pubDate>Wed, 27 May 2009 18:46:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[isolated storage]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=286</guid>
		<description><![CDATA[As I&#8217;ve mentioned in past posts, I have augmented the Silverlight Unit Test Framework to log errors it finds into a file in IsoStorage.  This file is then read by a python script and results are sent via email if need be.  
I ran into a problem today where my python script was [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve mentioned in past posts, I have augmented the Silverlight Unit Test Framework to log errors it finds into a file in IsoStorage.  This file is then read by a python script and results are sent via email if need be.  </p>
<p>I ran into a problem today where my python script was throwing an exception on me, stating &#8220;Permission Denied&#8221; on the result file.  I was a little confused, and when I tried to open the file myself [note that this was while my test was still running] I was given the alert: </p>
<blockquote><p>&#8220;The process cannot access the file because it is being used by another process&#8221;</p></blockquote>
<p>Turns out that when you open a file [either by File.Open, or by opening a new IsolatedStorageFileStream] you can set a <a href="http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx">FileShare</a> flag which will indicate if other processes are allowed to read and/or write to the file at the same time.</p>
<pre class="brush: csharp;">
private static IsolatedStorageFileStream _resultStream;
private static StreamWriter _resultStreamWriter;

private void OpenResultFile()
{
  // Create an isolated storage file  [make sure to set access to read so that other processes can read this file while it's open for writing].
  IsolatedStorageFile resultStore =
    IsolatedStorageFile.GetUserStoreForApplication();

  // Here I open up my file with ReadWrite access for my test app, and then set Read access for all other processes.
  _resultStream = new IsolatedStorageFileStream(&quot;TestResults.txt&quot;,
    FileMode.Create, FileAccess.ReadWrite, FileShare.Read,
    resultStore);

  _resultStreamWriter = new StreamWriter(_resultStream);
}
</pre>
<p>I had been using a different overload of the constructor which did NOT set this flag and so when other processes [namely my python script] was trying to read the file when it was open during the test execution, I would get a permission error.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/79zhdw37.aspx">MSDN &#8211; IsolatedStorageFileStream Constructor (String, FileMode, FileAccess, FileShare, IsolatedStorageFile)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=286</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[C#] My StreamWriter isn&#8217;t Writing Properly!</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=277</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=277#comments</comments>
		<pubDate>Tue, 26 May 2009 21:37:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[streamwriter]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=277</guid>
		<description><![CDATA[I have a StreamWriter which is responsible for writing out to my test file, however, there is a chance that my test app may be killed before completed.  Whenever this occurred, it seemed that my test file was blank!  Even though I knew that I had written some data to the stream&#8230;
Turns out [...]]]></description>
			<content:encoded><![CDATA[<p>I have a StreamWriter which is responsible for writing out to my test file, however, there is a chance that my test app may be killed before completed.  Whenever this occurred, it seemed that my test file was blank!  Even though I knew that I had written some data to the stream&#8230;</p>
<p>Turns out I misunderstood exactly how the StreamWriter worked.  The data is actually written into a buffer until you explicitly call Flash() or Close().  Because my Close() call was never being called when the app was killed, this data was never actually being flushed from the buffer into the file!  Doh!</p>
<pre class="brush: csharp;">
_resultStreamWriter.WriteLine(&quot;Write me now!!!&quot;);
_resultStreamWriter.Flush();
</pre>
<p><a href="http://msdn.microsoft.com/en-us/library/system.io.streamwriter.flush.aspx">MSDN &#8211; StreamWriter.Flush Method </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=277</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[C#] Using Reflection to Find a Function Name</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=269</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=269#comments</comments>
		<pubDate>Tue, 26 May 2009 21:14:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[reflection]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=269</guid>
		<description><![CDATA[I have a test script which will run and log errors found into a file in isolated storage.  I wanted to be able to also log the name of the function that was being tested, and after a quick search I see that this can easily be found using Reflection.

System.Reflection.MethodBase thisFunction = System.Reflection.MethodBase.GetCurrentMethod();

string functionName [...]]]></description>
			<content:encoded><![CDATA[<p>I have a test script which will run and log errors found into a file in isolated storage.  I wanted to be able to also log the name of the function that was being tested, and after a quick search I see that this can easily be found using Reflection.</p>
<pre class="brush: csharp;">
System.Reflection.MethodBase thisFunction = System.Reflection.MethodBase.GetCurrentMethod();

string functionName = thisFunction.Name;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=269</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Silverlight 2, C#] Implementing an Observable Collection [on a custom class]</title>
		<link>http://www.eightyeightpercentnerd.dreamhosters.com/?p=247</link>
		<comments>http://www.eightyeightpercentnerd.dreamhosters.com/?p=247#comments</comments>
		<pubDate>Mon, 25 May 2009 19:55:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[custom classes]]></category>
		<category><![CDATA[ObservableCollection]]></category>

		<guid isPermaLink="false">http://www.eightyeightpercentnerd.dreamhosters.com/?p=247</guid>
		<description><![CDATA[In order to improve some performance issues we were having, I needed to make a custom class that we were using become observable so that when we changed an item in the class the datagrid that the class was bound to would update automatically.
The datasource we were using was a custom class of ours, so [...]]]></description>
			<content:encoded><![CDATA[<p>In order to improve some performance issues we were having, I needed to make a custom class that we were using become observable so that when we changed an item in the class the datagrid that the class was bound to would update automatically.</p>
<p>The datasource we were using was a custom class of ours, so I therefore had to make it be observable as a collection to allow for this auto updating notification to occur.</p>
<p>Here is how you setup your class to enable it to be part of an observable collection.</p>
<pre class="brush: csharp;">
// 1: Implement the INotifyPropertyChanged interface on your class.
public class MyCustomClass : INotifyPropertyChanged
{
  // 2: Setup member variables; they must implement get;set.
  private string _myProp;
  public string MyProp
  {
    get { return _myProp; }
    set
    {
       // Check to make sure the value is actually changing.
       // [Thank you to Aaron for pointing this out]
       if (_myProp != value)
       {
         _myProp = value;
         // 3: Call the function which will notify subscribers that a property has changed.
         NotifyPropertyChanged(&quot;MyProp&quot;);
       }
    }
  } 

  //...  More member variables if you wish

  // 4: Setup the PropertyChangedEventHandler event on your class which will be responsible for telling subscribers that a property has changed; this is required by the INotifyPropertyChanged interface.
  public event PropertyChangedEventHandler PropertyChanged;

  // 5: Define the function [which is called in all your set functions], which is responsible for firing the PropertyChanged event on your class.  Must check for PropertyChanged != null, to make sure that someone is listening before firing the event.
  private void NotifyPropertyChanged(string propertyName)
  {
    if (PropertyChanged != null)
    {
      PropertyChanged(this, new PropertyChangedEventArgs((propertyName)));
    }
  }

  // ...  The rest of your class.
}

// 6: Now you can create observable collections of your class, which can then be bound as data sources for controls.
public class MyCustomCollection: ObservableCollection&lt;MyCustomClass&gt; { }
</pre>
<p>Then you can use that class as the itemsource [making sure that there are bindings in the XAML for the properties in MyCustomClass] for controls.</p>
<p>Links:<br />
<a href="http://silverlight.net/forums/p/49136/130015.aspx#130015">Silverlight.net forum post</a><br />
<a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(VS.95).aspx">MSDN &#8211; INotifyPropertyChanged Interface</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eightyeightpercentnerd.dreamhosters.com/?feed=rss2&amp;p=247</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
