I have followed the Telerik sample, which are great by the way, and I'm trying to set the Style of the MapPinPoint to a style defined in the XAML file but I keep getting an error:
System.Windows.Markup.XamlParseException occurred
Message=" [Line: 0 Position: 0]"
LineNumber=0
LinePosition=0
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)
at System.Windows.FrameworkElement.set_Style(Style value)
at MapApplication.MainPage.DisplayKMLFileUsingTelerikLoad()
InnerException:
The XAML style is defined as:
<Style x:Key="bridgeStyle" TargetType="ContentControl"> |
<Setter Property="FontWeight" Value="ExtraBold"/> |
<Setter Property="FontSize" Value="14"/> |
<Setter Property="Background" Value="White"/> |
</Style> |
and it is part of the RapMap.Resources section:
<map:RadMap Grid.Row="0" Margin="0,5,0,0" x:Name="RadMap1" UseDefaultLayout="True" |
UseSpringAnimations="False" |
MouseClickMode="None" |
MapMouseClick="radMap_MapMouseClick" |
MapMouseDoubleClick="radMap_MapMouseDoubleClick"> |
<map:RadMap.Resources> |
<ControlTemplate x:Key="callerTemplate" TargetType="ContentControl"> |
<Ellipse Width="10" Height="10" Fill="Orange" Stroke="White" StrokeThickness="1"/> |
</ControlTemplate> |
<Style x:Key="callerStyle" TargetType="ContentControl"> |
<Setter Property="VerticalAlignment" Value="Center" /> |
<Setter Property="HorizontalAlignment" Value="Center" /> |
<Setter Property="Template" Value="{StaticResource callerTemplate}" /> |
</Style> |
<Style x:Key="bridgeStyle" TargetType="ContentControl"> |
<Setter Property="FontWeight" Value="ExtraBold"/> |
<Setter Property="FontSize" Value="14"/> |
<Setter Property="Background" Value="White"/> |
</Style> |
</map:RadMap.Resources> |
<maps:InformationLayer x:Name="informationLayer"> |
</maps:InformationLayer> |
</map:RadMap> |
The code is based on the Telerik samples where a KML file is loaded using the KmlReader and the items are looped over via FrameworkElement objects. Here is the part where MapPinPoints are being set with the Style and where the error occurs:
List<FrameworkElement> list = KmlReader.Read(streamInfo.Stream); |
foreach (FrameworkElement element in list) |
{ |
//Label Text is not picking up the KML style so use a Silverlight one |
MapPinPoint pinPoint = element as MapPinPoint; |
if (pinPoint != null) |
{ |
//set the Silverlight style, using an inline style defined in the RadMap section |
ContentControl tempControl = new ContentControl(); |
tempControl.Style = RadMap1.Resources[defaultStyle] as Style; |
pinPoint.Style = tempControl.Style; //ERROR HERE |
} |
} |
Anything I try gives me an error but if the set the MapPinPoint properties directly it works: e.g.
pinPoint.FontSize = 14;
....
This this just an issue with CTP or am I doing something wrong?
EDIT: I found this sample but it doesn't show the "code" version of how you would do the same thing in the code-behind and thats what I am looking for. http://http//www.telerik.com/help/silverlight/map-adding-pin-points.html
Thanks,
Leo