Archive for November, 2010

Highlight search result in WPF

Wouldn’t it be nice to easily see where in the search result that the search criteria are found? In the same way as most of today’s browsers do when you search for strings on the page, highlight all matches with yellow background.

I want to achieve the following result in WPF:

To be able to achieve the same effect in WPF, I thought I should implement my own TextBlock that has some extensions to it, dependency properties that you can bind to the search textbox. I thought my first attempt would be a custom control and then perhaps later see if it is possible to achieve the same effect with attached properties.

Continue reading

Advertisements

WP7 Application Bar

The Application Bar is very easy to use and very useful. I’ll try to summaries some general considerations for using an Application Bar in you WP7 application.

Menu
Whenever you need a menu in your application, consider using the Application Bar instead of creating your own menu system. This really helps creating a consistent user experience across all applications on the device. The Application Bar provides nice animations and rotation support out of the box.

Opacity and Size
You can adjust the opacity of the Application Bar, but Microsoft has recommended that you only use opacity values of 0, 0.5 and 1 to maximize display quality and visual effects.
By default the opacity is set to 1, which means that the Application Bar when visible will take space from the display. So the page will be resized to be the area of the screen not covered by the Application Bar. However if you set opacity to less than 1, the displayed page will be the size of the screen and the Application Bar overlaid on top of it. This was somewhat strange to me that there was no property on the Application Bar that specified if the Application Bar should be overlaid or not, instead you have to fiddle with opacity. Good at least that it is possible to have it “hoover” the screen anyway.

Colors
Try to sure to use the default system theme colors for the Application Bar if you do not have a specific case/reason to use customized colors. Just make sure you test the application in both light and dark theme when using custom colors since using custom colors for the Application Bar can affect the display quality of icons and some unwanted, unusual visual effects in the menu animations. I actually read in some post that custom colors on the Application Bar can even influence power consumption on some display types. Whether this is true or not I don’t know, but the general suggestion is to use the default system theme colors.

Localization
It is important that you are aware of that the Application Bar is not a Silverlight control and does not support data binding. So the string values used for the button labels needs to be hardcoded in the XAML code and cannot be localized. However you can also add an Application Bar to a page in C# which enables the possibility to localize the strings and you can of course programmatically modify the label values at runtime if you specify the Application Bar in XAML.

Code Sample
If you have Expression Blend, then it is extremly easy to add an Application Bar to your page.
Simply click the New button next to Application Bar in the Common Properties panel.

In the expanded section click on Buttons collection to add buttons to your Application Bar. Add one or more Microsoft.Phone.Shell.ApplicationBarIconButton items to your button collection and specify icon to use. In the common properties for the application bar icon button you can by using the IconUri drop down menu select on of the built in icons, or specify a Uri to your own icon.
In the same way as adding Application Bar buttons you can add Menu items through the Menu Item collection.

In XAML the code for adding an Application Bar will look something like the following


	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar>
			<shell:ApplicationBar.MenuItems>
				<shell:ApplicationBarMenuItem Text="menu item"/>
			</shell:ApplicationBar.MenuItems>
			<shell:ApplicationBarIconButton IconUri="/icons/appbar.add.rest.png" Text="Add"/>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>

Customers first questions on WP7 solution

The first few questions I got when proposing a WP7 solution for a customer was:

  1. How long does it take to create a PoC (proof of concept) application
  2. Security, how do we assure a secure connection to our network, since the application is intended for the companies employees only, is it secure? and how do we make it secure?
  3. Can we somehow deploy our application to our employees mobile phones only or do we need to use the public marketplace?
  4. What happens if an employee looses his/her phone, do we then have a possible security breach?

Below you have a short summary on my answers to the customer.

  1. PoC.
    So development time when introducing a new platform is of course something the customer is always keen on knowing. It all depends on how many integration points you have, how many screens etc. But to give the customer a hunch of what it takes in development effort in WP7 compared to other platforms I refered to the WP7 application called TrueCaller.How long did it take to implement TrueCaller application on different platforms?

    • iPhone: 4 months
    • Android: 3 months
    • Windows Phone 7: 3 weeks!!!
    • Symbian: 4 months

    Conclusion, it is a lot faster to develop WP7 application  compared to other platforms and the development tools are very good and you use same technologies that the developers already know. (Original post where I found this)

  2. Security.
    In this case the customer wants to run the application only on employee phones. To make this as secure as possible you should use company specific certificates so that it will only be possible to access the company specific environments if you have the correct certificate. This common authentication works in conjunction with the Microsoft Exchange ActiveSync (EAS) protocol. We talked about chambers, capabilities, sandbox and application deployment. This is a large topic so I think I will write a separate blog about Windows Phone Security later on.
  3. Deployment.
    As for now, the only way to deploy a WP7 application on a phone is through the public marketplace. Enterprises will probably not like this since they want the possibility to deploy their applications on employee phones only and not make them accessible to the whole world. So hopefully Microsoft will make a change to this soon, there are rumors out there (as usual) that Microsoft is already on this and will later give companies the possibility to install their applications on their employees phones without going through the marketplace. Companies will have the possibility to use a Private Marketplace. But if this is true we just need to wait and see.
  4. Lost phone.
    If you lose your phone, you can actually remotely access it and ring, lock, erase or show your lost phone on a map! All this on the windowsphone.live.com site.

There are a lot of benefits for customers with existing applications to create WP7 applications, they open a new world of possible revenues. Connect with the customer on the “three screens”, extend their experience from mobile to web or any other screen using “the same source code”. If done right only the UI implementation is different between the screens, and even in the UI it’s possible to create re-usable code.

So what are you all waiting for? Lets start filling the Market Place with good quality apps!

Advertisements
%d bloggers like this: