Reputation: 1521
I'm creating (yet another) ruler app for wp7.
I know the res. is always 480x800, but devices have different screen sizes.
I tried searching around, but i couldn't find out how to get the ppi, so i can map the pixels to the physical dimension.
so how do i get the ppi of the current device, or the physical screen size ?
Upvotes: 0
Views: 800
Reputation: 1270
There is no way to retrieve the PPI on the device, you best shot would be to maintain a list of devices and their respective PPI. You can use this helper method to access device properties:
Using Microsoft.Phone.Info;
...
private static string GetDeviceProperty(string propertyName)
{
object propertyValue;
if (!DeviceExtendedProperties.TryGetValue(propertyName, out propertyValue))
return String.Empty;
return propertyValue as string ?? String.Empty;
}
Now the relevant properties would be:
string manufacturer = GetDeviceProperty("DeviceManufacturer");
string devicename = GetDeviceProperty("DeviceName");
Hope this helps! More information about DeviceExtendedProperties can be found on MSDN
Upvotes: 2