-
Archives
- March 2013
- February 2012
- January 2012
- September 2011
- May 2011
- April 2011
- September 2010
- May 2010
- April 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- December 2007
- July 2007
- June 2007
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- April 2005
- March 2005
- February 2005
- January 2005
- December 2004
- October 2004
- August 2004
- July 2004
- June 2004
- December 1969
-
Meta
Category Archives: C# Snippets
WP7 Navigation Gotcha
Navigating to a page, passing a key defined by a third party can present problems, but taking a little care over the way you pass the parameters can save a world of pain later. Continue reading
Posted in .NET, C# Snippets, Windows Phone, WP7
Comments Off
Silverlight Toolkit ExpanderView – Flat Objects
Just one of many ways in which you can bind an ExpanderView control to a collection of simple objects. Continue reading
Posted in .NET, C# Snippets, Windows Phone
Comments Off
Alter a Pivot controls header template the easy way (WP7)
If you want to alter the template for a Windows Phone 7 pivot control’s header, the simplest way is as follows… Of course, all this example does is specifically set the colour used for the title and headers to black, … Continue reading
Posted in .NET, C# Snippets, Mango, Windows Phone, WP7
Comments Off
Alternating ListBox item background colours in WP7
I had a requirement today to implement alternating row colours in a Windows Phone 7 ListBox. After a bit of frustration with searching and only finding answers tht said “You can’t do it”, or that you need to add a … Continue reading
Posted in .NET, C# Snippets, Mango, Windows Phone, WP7
Comments Off
Using LINQ to randomise a list.
This afternoon I needed to select some random items from a collection, and my searching ran into this idea. I modified it a little to do what I needed (Select 4 items at random from a list), and this is … Continue reading
Posted in C# Snippets, Linq
Comments Off
Split a Camel-Cased word into its components
I needed to split a camel-cased word into it’s component parts, and found the following extension method to help out. It works pretty well.
Posted in .NET, C# Snippets, Extension Methods, Uncategorized
Comments Off
Apostrophe In RowFilter
According to ASP.NET Resources, there is a problem when using apostrophes in a RowFilter expression in a DataView. The fix seems to be to double the apostrophes (“O”Mally”) rather than escaping them (“O\’Mally”)
Posted in C# Snippets
Comments Off
Iterate through enum values
A quick example of how to iterate through the values in an enum… enum myEnum { one, two, three, four, five, }; foreach (int i in Enum.GetValues(typeof(myEnum ))) { myEnum myItem = (myEnum )Enum.ToObject(typeof(myEnum ), i); System.Diagnostics.Debug.WriteLine(myItem.ToString()); }
Posted in .NET, C# Snippets, General, Software
Comments Off
Determine if an assembly is a debug or release build
*This code originally came from another blog, although it was written in VB over there. It has lost some elegance in the translation, but I needed a very quick solution this afternoon, and I needed it in C#, so here … Continue reading
Posted in .NET, C# Snippets, Software
1 Comment
Sending an HTTP POST request to a web server
ASCIIEncoding encoding = new ASCIIEncoding(); string post_url = “http://172.16.24.44/postdata.php”; string poststring = “monkeys=blue\&trousers=black”; byte[] data = encoding.GetBytes(poststring); HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(post_url); httpRequest.Method = “POST”; httpRequest.ContentType=”application/x-www-form-urlencoded”; httpRequest.ContentLength = data.Length; Stream newStream=httpRequest.GetRequestStream(); newStream.Write(data,0,data.Length); newStream.Close(); HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse (); Stream receiveStream = … Continue reading
Posted in C# Snippets
Comments Off