This is just another small but helpful tip for Windows Phone 7 developers. Imagine that you want your user to type in some input, that you need to proceed. One can handle the precessing by offering a “confirm”-Button or something like it or you can just react on the Enter-Key of the softkeyboard.which is presented, when a user clicks in a textbox.

So, how is this accomplished? The Textbox-Control does not provide a OnEnter-event, all one can be found is something called KeyDown-event. This event is what we will use for our need.

In the XAML of your appropriate TextBox you can add a method to the KeyDown which will be fired if a key enters the TextBoxControl.

I called mine OnEnter and you can easily check, which key of the softkeyboard was “entered” 🙂

It`s that simple 🙂

Advertisements

This blogpost is more like a little hint or tip, if you want to develop your application with the MVVM – design pattern. Within Windows Phone 7 apps you can easily navigate through PhoneApplicationPages in the code-behind of your views with the NavigationService – Class.

But what if you handle some logic/calculation within a ViewModel and you want to navigate to another View on the basis of the result, you cannot access the NavigationService in this static context.

The solution for this is very simple! All you have to do is the following:

  • In the appropiate ViewModel, just create a property of type NavigationService, like so



  • using the NavService like you do in code-behind

  • and don`t forget to set the Property in the code-behind of the approriate view, so that the NavService is valid and to avoid a NullReferenceException 🙂 You can do this in the constructor or any other initialization method.

I hope, that this little tip is useful for someone.

 

So with the new update of the Silverlight tookit for WP7 there came along  a few new controls for us developers to play around! I chose the DatePicker-Control for this blogpost, cause it`s not that easy to implement it correctly in some ways and to give some answers for beginners.

Step-by-Step:

  • First of all, download the toolkit from CodePlex and place it on your harddrive. 🙂
  • Don`t forget to add a reference to Microsoft.Phone.Controls.Toolkit for your WP7-Project.
  • Open up your XAML of the appropriate PhoneApplicationPage in VisualStudio, where you want to implement the DatePicker-Control
  • Add the Namespace to your Page…

  • Using the Control on the page…

  • Now start your project for a first test. After clicking of the control, you you should see the following…

  • You will be presented a page for picking the date, like in the calendar-app, BUT this is no PhoneApplicationPage one hast access to!! I marked the buttons in the ApplicationBar. To fix this issue, so you have a “check” and a “cancel”-icon, you have to add a folder to your project called Toolkit.Content!
  • Now you have to add from your icons the ApplicationBar.Cancel.png and the ApplicationBar.Check.png to the folder.
  • The DatePicker control searches for exact this Folder with these two files!
  • After this, you`re done and it should look like this…

Have fun 🙂

Silverlight Windowless-Mode?

3. November 2010

When you want to embed HTML or something like that in a IFrame wihtin a Silverlight application and you come across an error which says that you have to change the windowless parameter to true  and one don`t know where to do this. Just open up your …TestPage.aspx or …TestPage.html file, which hosts your Silverlight  application.

Scroll down until you find <div id=”silverlightControlHost”> and simply add the windowless parameter like so:

Est voila, that`s all one got to do…

If you`re using your WP7 within a WLAN like me ( is there anyone who doesn`t? 🙂 ) and think about security, you might want to add your WP7 to the MAC-Address filter in your router configuration. What first comes to mind is, where the heck am I able to find the MAC-Address of my Phone?? There is no info the phone settings or anywhere else.

So here`s the solution for that!

  • connect your phone to your WLAN
  • open up a browser and navigate to your routers configuration site (e.g. 192.168.0.1)
  • search for a tab or menupoint called status or logs
  • click on “network clients” or similar

After this steps, you should see something like this

In the above screeshot you see my actual network clients connect to my WLAN. One is my laptop and the other one should be my Windows Phone 7. To check this, just open up the command prompt and use ipconfig /all to look up the MAC-Address of the machine. So you know that the other MAC-Address in the router config is the WP7!

Est voila 🙂 now you`re able to add your WP7 device to your MAC-Address filter.