Archive for May, 2008

[XAML] Using Width and Height of a Polygon/Polyline

So for awhile I was bashing my head against my desk trying to figure out how to get/set the height/width of a polygon so that I could perform a stretch type action on the element.
Originally I was not setting the width and height properties, and I was trying to find the bounding box of the [...]

Continue reading » No comments

[Silverlight] XamlParseException when setting IsChecked flag in XAML

Alrighty, today I made a basic debug log to dump messages and test timings to. I wanted to setup a checkbox on my application to toggle the visibility [and to toggle off the logging/testing] of this debug panel… but when doing so I kept running into the exception:
A first chance exception of type ‘System.Windows.Markup.XamlParseException’ [...]

Continue reading » No comments

[C#] Accessors – get and set cleanliness

While looking at some example code, I bumped into some syntax that looked like a shorthand for declaring get and set methods for a given property – and I thought “well hey, isn’t that cool”.
Turns out that in C#, this is exactly the case…
“The accessor of a property contains the executable [...]

Continue reading » 2 Comments

I hate blogspots WYSIWYG

I apologize for the messy layout of the below posts. I seem to be having disagreements with the WYSIWYG editor, namely when trying to add symbols. Flipping back and forth between HTML and COMPOSE view will seemingly change these for me, even after I’ve hard coded them in the HTML view as “&lt” and [...]

Continue reading » No comments

[C#] Nullable Types

I bumped into this in my web travels today: Nullable types. Introduced in the 2.0 .NET framework was the ability to represent the normal range of values for a given value type PLUS the null value.
Nullable types can only be VALUE types [including structs]. It cannot be applied to reference types. Syntactically they look as [...]

Continue reading » No comments

[C#] More on string concatenation – String.Join

After yesterday’s post about “+=” vs StringBuilder, I did a little more looking around on the topic of string concatenation. It appears that if you can get the strings you wish to concatenate into an array then the String.Join(string, string[], int, int) method is actually faster then the StringBuilder.Append method.
public static string Join(string separator,string[] [...]

Continue reading » No comments

[C#] Efficient String Concatenation – "+=" vs StringBuilder

Again, in my short C# travels, I find myself very very often doing dynamic string concatenations. One major task I have tried to do is create a basic serialization function for XAML elements, so that I can store/save a XAML element to the server in my project. I thus end up doing many, [...]

Continue reading » No comments

[C#] More about Typecasting with ‘as’ and ‘is’

Taken from this CodeGuru article I found by Jay Miller
Often in my programming experiences with C# I want to check if an object is a specific type without throwing a code stopping exception. So I end up writing something very similar to this:
if (myObject.GetType().ToString().Name == “Canvas”){// Wicked code goes here.}
or
Canvas myCanvas = myObject as [...]

Continue reading » No comments

[C#] Parameter Passing – "ref" and "out"

Before I get into parameter passing…
There are two different types in C#
1) Value-Types [http://msdn2.microsoft.com/en-us/library/s1ax56ch(VS.71).aspx]
- Structs
* Built in –> Numeric Types [int, double etc...], Bool.
* User defined
- Enums
- Unlike reference types, it is not possible for a value type to contain [...]

Continue reading » No comments

[C#] Explicit Typecasting – ( ) vs "as"

One thing that confused me when starting out, was the seemingly intangible difference between typecasting via ([type])object and object as [Type]. With a small amount of digging here is what I found.
Two Methods of Explicit Typecasting

(1) “( )” Operator http://msdn2.microsoft.com/en-us/library/0z4503sa.aspx
- Will raise an exception if the typecast is not [...]

Continue reading » No comments