對於個人需求,對於Xamarin.Forms.Map控制,我需要創建一個CustomPin
擴展名。 UWP部分(PCL項目)Xamarin表單 - 圖像到/從IRandomAccessStreamReference
我創建了一個MapIcon
喜歡它:
nativeMap.MapElements.Add(new MapIcon()
{
Title = pin.Name,
Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Pin/customicon.png")),
Location = new Geopoint(new BasicGeoposition() { Latitude = pin.Position.Latitude, Longitude = pin.Position.Longitude }),
NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0)
});
然而,通過這種方式,我不能設置Image
的大小。
然後我想從我的PCL部分使用Image
,調整它的大小並將其轉換爲IRandomAccessStreamReference
。爲了實現它,我需要我的Image
轉換成流,但我找不到,使其作品的功能> <
實例所需要的方式:
private IRandomAccessStreamReference ImageToIRandomAccessStreamReference(Image image)
{
//Here I can set the size of my Image
//I convert it into a stream
IRandomAccessStreamReference irasr = RandomAccessStreamReference.CreateFromStream(/* img? */);
//irasr is then created from img
//I return the IRandomAccessStreamReference needed by the MapIcon element
return irasr;
}
注:的Image
放慢參數IMG是Xamarin.Forms.Image
因此,首先,這可能嗎?如果是的話,那麼謝謝任何可以幫助我的幫助..我已經搜索瞭如何調整MapIcon的大小,並且它不可能直接從班級[MapIcon]中獲得(https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.maps.mapicon.aspx)
感謝您的幫助!
嗨!何神,我正在尋找這麼久!我今晚會試一試,謝謝! :) – Emixam23
@ Emixam23嗨,任何更新?如果我的回答沒有解決您的問題,請隨時通知我。 –
它完美的作品,謝謝:) – Emixam23