Showing posts with label telerik. Show all posts
Showing posts with label telerik. Show all posts

Wednesday, 24 April 2013

Detect the screen resolution for Windows Phone OS 7.1 applications

    As you probably know Windows Phone 7.1 applications run perfectly on Windows Phone 8 devices. This means that your application/s could run on multiple display resolutions (which are the resolutions supported by Windows Phone 8 devices). If you want to take advantage of the new resolutions (for example downloading higher quality images for higher resolutions devices, fix some minor UI anomalies on higher resolutions) you will need to know the ScaleFactor of the device. The property is only available in the Windows Phone 8.0 SDK, but the good news is that you can access it using reflection.

Solution:
We retrieve the Get method of the ScaleFactor property and invoke it only if the application is running on an Windows Phone 8 device.

Here is the source code:
  public static Size DisplayResolution  
{
get
{
if (Environment.OSVersion.Version.Major<8)
return new Size(480,800);
int scaleFactor=(int) GetProperty(Application.Current.Host.Content, "ScaleFactor");
switch (scaleFactor)
{
case 100:
return new Size(480, 800);
case 150:
return new Size(720, 1280);
case 160:
return new Size(768, 1280);
}
return new Size(480, 800);
}
}
private static object GetProperty(object instance, string name)
{
var getMethod= instance.GetType().GetProperty(name).GetGetMethod();
return getMethod.Invoke(instance, null);
}

I am also attaching a small sample Windows Phone OS 7.1 test project.


SOURCE CODE

P.S. I think Telerik could use this method to fix this RadToolTip visual anomaly (the 1 pixel width lines that I have filled with blue for contrast) :


NAMASTE

Tuesday, 9 November 2010

Telerik RadControls for Windows Phone 7

     I am really happy that Telerik decided to develop controls for WP7. I have been using their silverlight controls since 2007 and they always added great controls. You can already download and try the CTP from the following this link . Even if it's just a CTP there are already many useful controls (Animation, DatePicker, DockPanel, PhoneApplicationFrame, DockPanel, TimePicker, Transition Control, UniformGrid, Window, WrapPanel, LayoutTransform, PickerBox, InfiniteListBox) . I would love to see a ProgressIndicator also and a decent MessageBox (I really don't like the default one). Also if you present a friend that downloads the tools you have the opportunity to win one of the 5 Windows Phone 7.  

   As always it's been a crazy period and I have little (no) time for writing code for the blog. Anyway when I find some spare time (usually from 1 o'clock in the morning till 3) I work on a DropBox library for WP7 (My Greatest Work Almost Completed) that I hope to publish soon along with an updated version of the IsolatedStorage Backup/Restore solution using DropBox. Everything works great: upload, download , create/delete folders and I am pretty excited. It could be a good alternative to Skydrive support that won't be available till early 2011. 

     I've also added a PayPal donation link at the blog this way if you find the source code on this blog useful feel free to donate (the donation will be invested in a brand new Windows Phone 7).

P.S. Wish I could have attended TechEd Europe. I really envy all of you that are attending.

NAMASTE