Thursday, 2 August 2012

Post/Email-3: Events in .NET

Today, a friend of mine asked a question on facebook:
Any body knows why wouldn't the selectionChanged event be fired?
I'm trying to change the text of a textBlock once I scroll to the next item in a pivot page
When I came into the scene, so to speak, another person had supplied the fix for the issue like so:
hmm in xaml u have to call your function SelectionChanged="thisPivot_SelectionChanged" and your textblock gets changed...
<controls:Pivot
 Title="MY APPLICATION"
 SelectionChanged="thisPivot_SelectionChanged"
 Name="pivot">

Then I started talking to my friend, and here’s how our conversation went:

Saturday, 9 June 2012

Post/Email-2: Views, ViewModels and Composition


Recently a friend of mine asked me the following question on Facebook:

brother, hope i am not disturbing you. had a question. if i have mutliple tab items in one page in y silverlight app, while each tab serves different functionalities, would it be all right if i write separate view models for all of the tab items, and i expose this view models as properties from one view model and bind the page's datacontext to that main viewmodel?

Thursday, 7 June 2012

Post/Email–1: MVVM Light messaging, order of register and send is important

 
Recently a friend of mine asked me the following question on Facebook. I started writing a few sentences, which turned into a few paragraphs and before I knew it I was writing a very long reply. Then, something Scott Hanselman said on twitter came to mind:
"Every email you send is a blog post you didn't write. Stop writing emails.”
Because of this, I intend to write these “Post/Email” (or “Post over Email”) blog posts whenever someone asks me a question, so that other people would benefit from them :)
Here we go, with this question from my friend Saad Galib on facebook:
...is it at all possible to pass data between ViewModels using MVVM light messaging without ViewModelLocator? Because in a blog i read that that some class needs to register for a message before it is sent to receive it. Right now i have no locator. i send a message from ViewModel-1 bound to page 1 and then navigate to page 2 which in turn creates viewmodel 2 and in that viewmodel's constructor i register for that kind of messages(broadcasted from viewmodel1)....but its not working....:(
and this i definitely not satisfying the condition i read as i mentioned above. is there any work around?
The short answer is: no. The "no" here isn't because of the ViewModelLocator itself, but rather because of what you mentioned later about the order in which the subscription and broadcast are done.
The Messenger implementation in MVVM Light is simple and straightforward. When you register an object to some event, it adds it to a dictionary; and when that particular event is sent, it goes through the corresponding objects in the dictionary and notifies them (by calling the corresponding registered action). Therefore, when an object subscribes to a certain event, it only gets notified of those instances of the event which occur after it has subscribed. Which is the logical thing to do.
I'm not aware of anything in MVVM Light that would help with your particular situation, but there are other, maybe not so elegant, methods to transmit data between objects in a loosely coupled way. One of them, which I used myself but I'm not sure whether it's a good practice or not, is to have some sort of "buffer" where an object can put some data for other objects to take out at some point in time (in my particular scenario, I used a class "Pipe" with a static member "Data" that I set in one VM and consume in the other).
Hope this helps

Tuesday, 21 February 2012

What are Generics in .NET?

A little while ago, a friend of mine on Facebook asked me to explain to him what generics in .NET were. As I thought this might interest more than one friend, which it did, I decided to put it in a "note" on Facebook. That was before I started this blog, so now I decided to post it here, hopefully so that more people would find it useful.

Generics in the .NET Framework is a programming technique that allows you to create a "generic" (meaning that it's not tied to a specific type) class, structure or method. The type, which is in this case "an argument", is specified when that element is used. What's interesting, and this is another advantage of Generics in .NET, is that you can restrict that type by specifying, for example, that it has to implement a certain interface or have a parameterless constructor.

This concept allows for more type safety (the type is known when the generic element is being used), while promoting reuse (you create an element that's not tied to a specific type).

Sunday, 19 February 2012

Is Silverlight Dead?


"To Silverlight or Not to Silverlight!" That my dear reader is a question I've grown accustomed to hear! Here's part of a little chat I had with a friend on Messenger a couple of days ago:
 
"Friend" says:
yes that's exactly what i meant !
btw , is Silverlight dying?
"Me" says:
nah, it's having a headache that’s all
(from all the people who are saying it's dying )
"Friend" says:
haha, i see 

Thursday, 22 December 2011

Microsoft gives YOU an opportunity you shouldn’t miss!

I have great news! It seems my series is going to be put to work at last! It’s rather fortunate that I got it done just in time for this AWESOME opportunity ;)

Are you a student from the MEA region who’s graduating this year (well, even if you’ve recently graduated, I think you should go for it. Worked for me ;) )? Are you ready to have the exact same opportunity I had? DO YOU WANT TO WORK FOR MICROSOFT?! Of course YOU DO ;)

Anyways, enough with me rambling, and let’s cut to the chase. Here’s the announcement:

What fuels your passion?

Deciding where to start your career can be as nerve-wracking as it is exciting. Maybe you don’t know exactly what you want to do. Maybe you don’t even have a technology background. Fortunately, Microsoft will help you to build a career that evolves along with your interests and passions.

Jump right in to the deep end

That’s a phrase we hear a lot from people during their first week at Microsoft. And with good reason. From day one, you’ll plunge headfirst into engaging, meaningful projects. Your team members and managers will help you get up-to-speed in no time. It’s a thrilling way to start your career—and it’s only the beginning. Now take the first step.
Visit our website at www.microsoft.com/university
to learn more about our
Full-Time & Internship Software Development and Software Development in Test Positions
Apply by January 15 to be considered for our
Dubai Interview Event
March 5-8, 2012
 

Important information:

  • Information on applying, Microsoft Benefits, including complete relocation, US work visa sponsorship and other perks are available at www.microsoft.com/university
  • University recruiters at Microsoft review resumes with the following topical areas in mind:
    1. Academic Record, 
    2. Relevant Work Experience,
    3. Leadership 
  • Please note we are seeking Software Development Full Time & Intern candidates. NOTE:Full Time candidates must be graduating Dec. 2011 – August 2012. Candidates with graduation dates after August 2012 would be considered for internships.
  • Travel & Accommodations will be covered by Microsoft

Update:

So, many people keep asking the same question: “How do we apply?!”, which, I have to admit, is a very valid question. Here’s the answer:
  1. Go to the website: http://www.microsoft.com/university
  2. Explore the opportunities under
  3. Click “>> APPLY NOW” which is in the “orange box” in the left side.
  4. Follow the steps to complete your application.

Wednesday, 21 December 2011

Landing a Job At Microsoft, Part3: The In-Person Interview, Impress Them!

I know it’s been a while since the first 2 posts, but I’m finally getting around to writing the 3rd part of this series, which I hope is helping you, dear reader, to prepare yourself to get your dream job ;)

So, after writing your rock star resume, and after making a great first impression in your phone interview, you should be asked to do an in-person interview, or rather in-person interviews (as I had 4 of them ;) ). This is what you’ve been working for in the first two steps of the process. An opportunity to tell your story in your own words, to demonstrate your skills, to meet the people involved and to ask any questions YOU have.