This is a migrated thread and some comments may be shown as answers.

Binding Colours on MapPolygon

1 Answer 116 Views
Map
This is a migrated thread and some comments may be shown as answers.
ben crinion
Top achievements
Rank 1
ben crinion asked on 23 Aug 2013, 03:57 PM

My MVVM app loads user defined polygons from a DB and then databinds the information layer (after the map is initialised, as suggested in the documentation).

When I explicitly declare the colours in the data template the binding works perfectly. But when I data bind the colours (using a converter to convert them to a SolidColorBrush) it doesn't display the shapes at all.

Here's the XAML...

<
telerik:RadMap x:Name="mapControl" Center="53.54245,-2.298817" ZoomLevel="7">
    <telerik:InformationLayer x:Name="shapeLayer" Visibility="Visible">
        <telerik:InformationLayer.ItemTemplate>
            <DataTemplate>
                <telerik:MapPolyline Fill="{Binding Fill, Converter={StaticResource converter}}" Opacity="0.5"  Points="{Binding Points}" Stroke="{Binding Stroke, Converter={StaticResource converter}}" StrokeThickness="2" />
            </DataTemplate>
        </telerik:InformationLayer.ItemTemplate>
    </telerik:InformationLayer>
</telerik:RadMap>

Here's the view model that I'm using for each shape.

    public class ShapeViewModel : ViewModelBase
    {
        private LocationCollection _points;
        private Color _stroke;
        private Color _fill;
 
        public LocationCollection Points
        {
            get { return _points; }
            set
            {
                if (_points != value)
                {
                    _points = value;
                    OnPropertyChanged(() => Points);
                }
            }
        }
 
        public Color Fill
        {
            get { return _fill; }
            set
            {
                if (_fill != value)
                {
                    _fill = value;
                    OnPropertyChanged(() => Fill);
                }
            }
        }
 
        public Color Stroke
        {
            get { return _stroke; }
            set
            {
                if (_stroke != value)
                {
                    _stroke = value;
                    OnPropertyChanged(() => Stroke);
                }
            }
        }
    }

I don't see any binding errors in my output window.

Thanks
Ben

1 Answer, 1 is accepted

Sort by
0
ben crinion
Top achievements
Rank 1
answered on 23 Aug 2013, 05:04 PM
And I've answered my own post on the Telerik forum again.

I was setting the alpha value on the colours I was binding to 0, totally transparent. Setting it to 255 fixed the issue straight away.

Tags
Map
Asked by
ben crinion
Top achievements
Rank 1
Answers by
ben crinion
Top achievements
Rank 1
Share this question
or