Archive for c#

[Silverlight 2, C#] How to tell if a Storyboard is currently running?

Tags: ,

To do this you can check the current ClockState of the animation.

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

Continue reading » 2 Comments

[C# 3.0+] Annonymous Types

Tags:

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 [...]

Continue reading » 2 Comments

[Silverlight 2, C#] Datagrid Not Sorting?

Tags: , , ,

So I’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’s properties… I then databind a List of myClass to the datagrid itemsource and everything works fine – sorting worked fine right out [...]

Continue reading » 1 Comment

[Silverlight 2, C#] Writing to and Reading from an IsoStorage File at the Same Time!

Tags:

As I’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 [...]

Continue reading » 2 Comments

[C#] My StreamWriter isn’t Writing Properly!

Tags:

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…
Turns out [...]

Continue reading » No comments

[C#] Using Reflection to Find a Function Name

Tags:

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 [...]

Continue reading » No comments

[Silverlight 2, C#] Implementing an Observable Collection [on a custom class]

Tags: ,

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 [...]

Continue reading » 3 Comments

[Silverlight 2, C#] Creating Custom Events

Tags:

I’d just like to say, that figuring out how to create custom events has completely opened my eyes. For awhile I was struggling with having multiple classes that seemed to need information from each other, but something seemed wrong with having to keep [or pass in reference to] the “other” class.
Enter events… by creating [...]

Continue reading » 3 Comments

[Silverlight 2, C#] Animating a GridLength

Tags: , ,

It’s been awhile I’m afraid and my topics to post on have been piling up!  My work hard drive crashed on me and I’ve spent a lot of time just getting things back up to speed.  Anyhoot… feels good to be back.
This last timebox at work I shifted onto a different project – but still [...]

Continue reading » No comments

[C#] Creating Custom Exceptions

Tags:

I’ve found it useful in the past to create my own custom exceptions for my application to throw and catch – especially if I want to handle that exact exception in a specific manner. Figured I’d jot down the syntax used to set one up here since I’ve looked it up once or twice.

// [...]

Continue reading » No comments