C#

Programmatically hiding the keyboard in Windows Phone 7 (WP7)

I was looking for a way to programmatically hide the keyboard in WP7 and was searching for some WP7 API method, but couldn’t find one. Then it dawn on me that the keyboard automatically hides when the TextBox control looses focus. So I decided to give it a try by setting the focus on another control and it worked: 1: //focus the current page 2: this.Focus(); 3: //or focus another control ...

posted @ Wednesday, February 16, 2011 8:17 PM | Feedback (2)

My Windows Phone 7 App failed… Requirement 5.2.4.c

So I submitted my third app, Shapes, into the WP7 Marketplace and 48 hours later I get an email saying it failed. I read the details and it failed because of requirement 5.2.4.c: If the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and cancel the backward navigation to the previous page. The expected result: Test Process Required: ...

posted @ Thursday, December 16, 2010 9:36 AM | Feedback (0)

Sample Code for Getting the User Location based on the IP Address

Yesterday I introduced a free service to get the location of the IP Address. If you haven’t read it, go on read that first (it’s very short, I promise). So here I am today, showing you my small .NET API to abstract the XML returned by the service. First we need an object to hold the data. I called it UserLocation. 1: public class UserLocation 2: { 3: public string City...

posted @ Thursday, September 03, 2009 2:01 PM | Feedback (3)

Get Location of the IP Address

I wanted to share with all of you a free service that provides you an approximation of your user’s IP Address. You can read about it here: http://www.hostip.info/use.html. If you are looking for a more sophisticated solution that is maintained more often than the free solution you can also use this service: http://www.maxmind.com As of this writing you can get the response in 2 different forms: XML or plain text. I like the more structure formats so I will be using the XML option. Stay tune… I will post a C# API for retrieving the information. UPDATE:...

posted @ Wednesday, September 02, 2009 3:00 PM | Feedback (3)

Generic CreateRange Extension

I was in need of a CreateRange method, similar to the Enumerable.Range(1, 10), that return an Enumerable of Dates. Doing a search I stumble along this blog post, which contains a generic CreateRange method. I then went ahead and converted the code to use extensions. Here’s the end result: 1: public static IEnumerable<t> CreateRange<t>(this t sender, t end, Func<t, t> func) where t : IComparable 2: { 3: if (sender.CompareTo(end) ==...

posted @ Wednesday, January 21, 2009 9:39 AM | Feedback (0)

ObservableDictionary Object

I was in need of an ObservableDictionary object for .NET 2.0 and there was no CLR object that met my requirements. All I needed was a Dictionary object that would notify me when a value was changed. I created a CodePlex project where you can download the code.   Happy Programming!

posted @ Wednesday, December 03, 2008 2:19 PM | Feedback (0)

Serializing Objects with Enums

Take into consideration the following entity: public class CompositeType { public bool BoolValue { get; set; } public string StringValue { get; set; } public EnumType VehicleType { get; set; } }   public enum EnumType { Car = 0, ...

posted @ Thursday, August 28, 2008 4:11 PM | Feedback (0)

DateTime.ToString(string)

This is more of a "mental" note for me than anything else, but I would like to share it with everyone as well. The DateTime.ToString method has 2 overloads, one with no parameters and the other with a string parameter. I would like to talk about the second one (hence the title of this post). You can pass a custom format pattern as the parameter to show the date anyway you want. Here are some of the possible values: Pattern Description Example yyyy Full Year 2008 yy Year 08 MM Month 05 MMM...

posted @ Thursday, May 22, 2008 3:30 PM | Feedback (1)

Behavior of Default Constructors and Base Classes

A client of mine requires us to use ReSharper. I usually don't like to use any of those tools because if I get used to then and I go crazy when I do not have them, but I think I will give ReSharper a chance at my own dev machine. One of the cool features about ReSharper is that it marks the state of the current class with a green, yellow, or red indicator specifying whether the class is not compileable, compileable with warnings, or compileable without warnings. While working on a class ReSharper was marking it with yellow and specifying that I...

posted @ Wednesday, February 27, 2008 3:15 PM | Feedback (1)

Container.DataItem. What exactly is this?

Recently I had to bind to an array of strings and I wasn't sure how to show the value of the current item. After a little bit of help from the DevTheo and a little bit of thinking I figured out the solution was very simple. All i had to do was bind it like this: <%# Container.DataItem %> So what is this expression exactly? The <%# %> means this is a DataBinding expression and Container.DataItem is an alias for the current item in the datasource. In other words, if you are binding to a collection of objects Container.DataItem is the current...

posted @ Tuesday, November 13, 2007 3:24 PM | Feedback (25)

Full C# Archive