Binding Colours on MapPolygon

2 posts, 0 answers
  1. ben crinion
    ben crinion avatar
    8 posts
    Member since:
    Nov 2009

    Posted 23 Aug 2013 Link to this post

    
    
    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

  2. ben crinion
    ben crinion avatar
    8 posts
    Member since:
    Nov 2009

    Posted 23 Aug 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top