I am trying to create a custom control in Xamarin.Forms
and expose a property correctly. I'm sure the same principals apply to WPF
My Control
public class ExtendedMap : Map
{
public ExtendedMap()
{
}
private IList<Pin> _staticPins;
public IList<Pin> StaticPins
{
get { return _staticPins; }
set { _staticPins = value;}
}
}
And in Xaml I am currently using it like so:
<custom:ExtendedMap x:Name="map" Grid.Row="2" HorizontalOptions="Fill" VerticalOptions="Fill" IsVisible="{Binding CustomerSearchControlViewModel.MapIsDisplayed}">
<custom:ExtendedMap.StaticPins>
<x:Array Type="{x:Type maps:Pin}">
<maps:Pin Label="Hello" Address="{Binding CustomerSearchControlViewModel.SelectedCustomer.Address, Converter={StaticResource AddressToStringConverter}" Position="{Binding CustomerSearchControlViewModel.SelectedCustomer.Position}" Type="Place"/>
</x:Array>
</custom:ExtendedMap.StaticPins>
</custom:ExtendedMap>
If I take the <x:Array>
part out I get an error:
Sequence is not IEnumerable
but I would like to use it like:
<custom:ExtendedMap.StaticPins>
<maps:Pin Label="Hello" Address="{Binding CustomerSearchControlViewModel.SelectedCustomer.Address, Converter={StaticResource AddressToStringConverter}" Position="{Binding CustomerSearchControlViewModel.SelectedCustomer.Position}" Type="Place"/>
</custom:ExtendedMap.StaticPins>
Is this possible? What is the correct way to do this?