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

Telerik SilverLight 3 PushPin dynamically change Background color

3 Answers 93 Views
Map
This is a migrated thread and some comments may be shown as answers.
Alex VonBrand
Top achievements
Rank 1
Alex VonBrand asked on 04 Nov 2010, 02:40 PM
I am creating a silverlight telerik map application.  Orignally, I developed it with the SilverLight 4 controls, but I needed to bump the version back to the SilverLight 3 so I used the asseblies for Silverlight 3 (RadControls_for_Silverlight_3_2010_2_0924_DEV_hotfix).  I have now got it all working except for one thing.  In the application I add pushpins for locations  each of which  have different statuses.  I want to set the background color of the pin to reflect the status of the location.  I was able to to this in SilverLight 4, but can't get this to work with Silverlight 3.

The code I use is as follows:

Telerik.Windows.Controls.Map.

 

Pushpin pin = new Telerik.Windows.Controls.Map.Pushpin();

 

 

 

FacLocation status = (FacLocation)e.UserState; ;

 

 

 

if (status.Status == "01")

 

{

pin.Background =

 

new SolidColorBrush(Colors.Blue);

 

}

 

 

if (status.Status == "02")

 

{

pin.Background =

 

new SolidColorBrush(Colors.Purple);

 

}

 

 

if (status.Status == "03")

 

{

pin.Background =

 

new SolidColorBrush(Colors.Green);

 

}

 

 

ToolTipService.SetToolTip(pin, tip);

 

Telerik.Windows.Controls.Map.

 

Location loc = new

 

Telerik.Windows.Controls.Map.

 

Location();

 

loc.Latitude = lat;

loc.Longitude = lon;

pin.Loaded +=

 

new RoutedEventHandler(pin_Loaded);

 

 

 

 

MapLayer.SetLocation(pin, loc);

 

layer.Items.Add(pin);

//////////////

This code worked fine with the SilverLight 4 assemblies, but has no effect in Silverlight 3, all the pins just come up with a red background.  I have debugged the code and it seems to be correctly setting each pushpin's background as they are added to the map.  Can anyone tell me how to dynamically reset the background color of the pushpins, using the Silverlight 3 assemblies?

Thanks,
Alec von Brand 

 

 

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Nov 2010, 03:29 PM
Hi Alex VonBrand,

The Silverlight 3 version of DLL doesn’t contain new things (including control templates) added to the RadMap control since 2010.Q1.SP1, but bug fixes only. In the 2010.Q1 Pushpin control template doesn’t support changing of the background color using Background property. To be able to do it in your application you should redefine default control template for Pushpin so it bind Background property of the pushpin to the correspondent property in the control template. For example:

<LinearGradientBrush x:Key="MapPushpinStroke" 
        EndPoint="0.5,1" 
        StartPoint="0.5,0" 
        MappingMode="RelativeToBoundingBox">
        <GradientStop Color="White"/>
        <GradientStop Color="Black" Offset="0.853"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="MapPushpinBackground" 
        EndPoint="0.5,1" 
        StartPoint="0.5,0">
        <GradientStop Color="#FFFF6E6E" Offset="1"/>
        <GradientStop Color="#FFAB0000"/>
</LinearGradientBrush>
  
<Style TargetType="maps:Pushpin">
        <Setter Property="Background" Value="{StaticResource MapPushpinBackground}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="maps:Pushpin">
                <Border>
                    <maps:MapLayer.HotSpot>
                        <maps:HotSpot X="0.5" Y="1" XUnits="Fraction" YUnits="Fraction" />
                    </maps:MapLayer.HotSpot>
                    <Path Stretch="Fill" 
                        Stroke="{StaticResource MapPushpinStroke}" 
                        StrokeThickness="6"     
                        Data="M12,26.083 L16,26.083 13.916667,32.083 z M14,3 C20.075132,3 25,7.9248676 25,14 25,20.075132 20.075132,25 14,25 7.9248677,25 3,20.075132 3,14 3,7.9248676 7.9248677,3 14,3 z"
                        Fill="{TemplateBinding Background}">
                        <Path.Effect>
                            <DropShadowEffect BlurRadius="7" ShadowDepth="1" />
                                        </Path.Effect>
                    </Path>
                </Border>
            </ControlTemplate>  
        </Setter.Value>
    </Setter>
</Style>


Regards,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex VonBrand
Top achievements
Rank 1
answered on 09 Nov 2010, 04:09 PM
Thanks Andrey.  That all makes sense.  I will look into the default Template.

In the meantime, I have swithced the pushpin from the Telerik assembly to the one from System.Windows.Controls and it seems to work well enough with Radmap.
0
Andrey
Telerik team
answered on 11 Nov 2010, 11:16 AM
Hi Alex VonBrand,

You can use any FrameworkElement in information layer. It is allowed by design. You can create your own DataTemplate and use it to show locations over the map. You can find example here:

http://demos.telerik.com/silverlight/#Map/DataBinding

Sincerely yours,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Map
Asked by
Alex VonBrand
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Alex VonBrand
Top achievements
Rank 1
Share this question
or