小编S. *_*ews的帖子

Xamarin 表单 - 图像到/从 IRandomAccessStreamReference

对于个人需要,对于Xamarin.Forms.Map控件,我需要创建一个CustomPin扩展。UWP 部分(PCL 项目)

我创建了一个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)
});
Run Code Online (Sandbox Code Playgroud)

但是,通过这种方式,我无法设置Image的大小。

然后我想使用Image我的 PCL 部分中的 ,调整它的大小并将其转换为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? …
Run Code Online (Sandbox Code Playgroud)

bing-maps marker xamarin.forms uwp uwp-maps

3
推荐指数
1
解决办法
440
查看次数

使用UWP MapItemsControl的多个DataTemplates

我有一个MapControlUWP:

<maps:MapControl x:Name="BikeMap" ZoomLevel="17" Center="{Binding CenterPoint, Mode=TwoWay}">
    <maps:MapItemsControl x:Name="MapItems" ItemsSource="{Binding BikePoints}"
                        ItemTemplate="{StaticResource BikePointTemplate}"/>
</maps:MapControl>
Run Code Online (Sandbox Code Playgroud)

我正在使用XAML数据模板添加MapElements,我的ItemsSource是一个简单对象列表.

但是,UWP似乎并没有提供一种方式来指定DataTypeDataTemplateMapItemsControl没有设置一个属性DataTemplateSelector.

有谁知道我如何使用MapItemsControl的多个数据模板,并根据ItemsSource中的对象类型选择相关的数据模板?

xaml uwp windows-10-universal uwp-xaml uwp-maps

1
推荐指数
1
解决办法
898
查看次数