2011-10-22 73 views
0

我正在爲wp7創建(又一個)尺子應用程序。如何獲得wp7 ppi或物理屏幕大小?

我知道水庫。總是480x800,但設備具有不同的屏幕尺寸。

我試着四處搜尋,但我找不到如何獲得ppi,所以我可以將像素映射到物理尺寸。

那麼如何獲得當前設備的ppi或物理屏幕大小?

回答

2

有沒有辦法檢索設備上的PPI,你最好的辦法是保持設備列表和它們各自的PPI。您可以使用此helper方法來訪問設備屬性:

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; 
    } 

現在相關屬性是:

string manufacturer = GetDeviceProperty("DeviceManufacturer"); 
string devicename = GetDeviceProperty("DeviceName"); 

希望這有助於!有關DeviceExtendedProperties的更多信息,請參閱MSDN

+0

這就是我要做的。只是很高興有沒有像Android手機那麼多的Windows手機! ;) –

+0

我擔心這將是唯一的方法。不幸的是,這不能很好地擴展。不管怎麼說,還是要謝謝你。 –

+4

不使用電話應用程序作爲標尺的另一個原因... –

相關問題