Wednesday, September 26, 2012

Windows Phone and Silverlight FAQ

Recently I was encouraged by the people at work to venture into building Windows Phone (WP) native application.

The enticement was in the form of a Windows Phone; the Nokia Lumia 710, to be exact.

So the following were some caveats that I found that I thought would be interesting to post here just in case someone else also happen to encounter the same issues.

Issue 1
Displaying images dynamically; threading issue.

First of all, I understood the way to retrieve images dynamically from say somewhere in the world wide web. That was not my problem and should you have troubles with that, this is not the place to look.

WP works on threads. My XAML had a image tag with a name of "imgOne" for simplicity purposes and I need to change the source based on some user input.


In the code behind, the XAML.cs file, you will have access to the image tag should you type "imgOne." and Visual Studio intellisense should bring up the available properties for "imgOne".

However, if you attempt to set the source there; imgOne.Source = someBitmapObject
You will encounter the UnhandledAccessException similar to something like this

 

To fix this problem, you would have to use the Dispatcher.BeginInvoke function. Something similar to this



Issue 2
DataContext.

My application is a very small one, so the route I took with it was to not implement MVVM, although it would have been easier to have done so.

So, if you would like to go down this path, here goes.

Each item in the XAML has a DataContext and by default, each of these data context works in a "One Way" mode. So once you set it, the DataContext won't change unless you reset it but here comes the wacky part.

You will have to set the DataContext to null before resetting it to another object.

Tuesday, August 7, 2012

Recently, I upgraded to Mountain Lion for my Mac and guess what happened?

My lovely trackpad failed to work.

So after some painful searching through the goog, I manage to find the solution.

I am posting here so you (and I) will know what to do in the future.

1 - Hit "Command + Option + Esc" or if you are on a PC-keyboard like me, it is "Win + Alt + Esc"

2 - Terminate all processes and relaunch Finder

3 - Put your Mac into sleep mode by clicking on the Apple icon on the top left hand corner

4 - Wake your Mac by using the keyboard

5 - Restart your Mac by clicking on the Apple icon once again and select "Restart"

6 - Shut down your Mac by clicking on the Apple icon once again and then hit the power button.

This should make your trackpad work with gestures again.

Wednesday, July 18, 2012

iOS post 1

In my educational land, there was the massive beast of a library called DotNet and then now, there is a new creature that appeared.

I've taken the initiative to check out GHUnit, OCUnit and OCMock.

All of which I think is paramount to get any form of iOS going.

Infact, for work, we need to get it going for DotNet too but I will let that take shape whenever that is possible.

From this point forward for this article, I will be just be pasting article snips found all over the internet to assist my learning and also to compile my own library of tutorials. 
ViewController.xib (XIB file for short) is the interface layout file. You visually create/design the screen that’s displayed on the iPhone device using this file.
ViewController.m is the interface controller class. The interface layout file is linked to this class. This happens automatically, so at this stage you don’t need to think about it other than to know that any objects or events you set up in your interface class can be linked to your interface layout very easily. This is the file that will contain the Objective-C code you’re about to create.
ViewController.h is the interface controller class header file, where you’ll declare the instance variables, as well as the objects and events that you need to access from the interface screen.
The IBOutlet keyword means that quote_text is an object that can be linked to an interface element on the XIB file so that the view controller can access (or change) properties of the interface element. In this case, we’ll be setting the displayed text for the UITextView control but we could just as easily change the color, font, size, etc.
The IBAction keyword indicates that quote_btn_touch is an action that can be linked to an event for a UI control on the screen. In this case, we will be connecting to the quote button touched event.
In case you’re wondering, id means “any object that derives from NSObject”. Usually when you set up callbacks that buttons and other controls will call, they pass whatever button/control is sending the callback as the first parameter. Since we don’t necessarily know what type it is, we put id here.
 

Excerpts from here


Sunday, May 20, 2012

Venturing into native application development

I have been playing around with a new development tool.

I realized that when creating an Android or iOS application, the Application Id and Project name is very important.

If you happen to use camel casing, you will have to ensure that the Application ID is exactly the same name as the project name.

For example, when you create a project name and name it FirstApplication, the Application ID must be something like com.somedomain.FirstApplication