<esri:MarkerSymbol x:Key="SquareMarkerSymbol"> <esri:MarkerSymbol.ControlTemplate> <ControlTemplate> <Grid HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Border Background="Blue" Grid.RowSpan="3" /> <TextBlock Text="text 1" Grid.Row="0" Foreground="White" HorizontalAlignment="Center" /> <Border Background="Green" Grid.Row="1" Width="48" Height="48" /> <TextBlock Text="text 2" Grid.Row="2" Foreground="White" HorizontalAlignment="Center" /> </Grid> </ControlTemplate> </esri:MarkerSymbol.ControlTemplate> </esri:MarkerSymbol>
Are we missing something obvious?
<esri:MarkerSymbol x:Key="MarkerSymbolWithBubble"> <esri:MarkerSymbol.ControlTemplate> <ControlTemplate> <Canvas> <Grid Canvas.Left="{Binding ActualWidth, ElementName=InfoPopupGrid, Converter={StaticResource PositioningConverter}}" Canvas.Top="{Binding ActualHeight, ElementName=InfoPopupGrid, Converter={StaticResource PositioningConverter2}}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid x:Name="InfoPopupGrid" MaxWidth="300"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Path x:Name="PopupArrow" Data="M363,252 L409,252 L385,278 z" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" Height="20" VerticalAlignment="Bottom" Grid.Row="1" HorizontalAlignment="Center" Width="20"> <Path.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0"/> <GradientStop Color="#FFA5A5A5" Offset="1"/> </LinearGradientBrush> </Path.Fill> </Path> <Border x:Name="PopupContent" BorderBrush="Black" BorderThickness="1" CornerRadius="5"> <Border.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0"/> <GradientStop Color="#FF7A7A7A" Offset="0.536"/> <GradientStop Color="#FF707070" Offset="1"/> <GradientStop Color="#FF6A6A6A" Offset="0.515"/> </LinearGradientBrush> </Border.Background> <Grid> <TextBlock Margin="8,5,45,0" TextWrapping="Wrap" Text="Icon Title" Foreground="White" VerticalAlignment="Top" FontWeight="Bold"/> <TextBlock TextWrapping="Wrap" Text="{Binding Attributes[Description]}" Foreground="White" Margin="8,20,21,0" VerticalAlignment="Top"/> </Grid> </Border> </Grid> <Image Source="pushpin.png" Stretch="None" Height="24" Width="24" HorizontalAlignment="Center" Grid.Row="1"/> </Grid> </Canvas> </ControlTemplate> </esri:MarkerSymbol.ControlTemplate> </esri:MarkerSymbol>
<esri:MarkerSymbol x:Key="labelSymbol" OffsetX="6" OffsetY="6"> <esri:MarkerSymbol.ControlTemplate> <ControlTemplate> <Grid> <!--Marker--> <Ellipse Width="12" Height="12" Fill="Red" HorizontalAlignment="Left" VerticalAlignment="Top" /> <!--Label--> <Grid Margin="8,8,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False"> <!--Text halo using a white blurred text--> <TextBlock Foreground="White" Text="{Binding Attributes[NAME]}" > <TextBlock.Effect> <BlurEffect Radius="5" /> </TextBlock.Effect> </TextBlock> <!--Text--> <TextBlock Foreground="Black" Text="{Binding Attributes[NAME]}" /> </Grid> </Grid> </ControlTemplate> </esri:MarkerSymbol.ControlTemplate> </esri:MarkerSymbol>
<esri:MarkerSymbol x:Key="labelSymbol" OffsetX="6" OffsetY="6"> <esri:MarkerSymbol.ControlTemplate> <ControlTemplate> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="MouseOver"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="labelOnHover" Storyboard.TargetProperty="Visibility" Duration="0"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <DoubleAnimation From="0" To="1" Storyboard.TargetName="labelOnHover" Storyboard.TargetProperty="Opacity" Duration="0:0:.25" /> </Storyboard> </VisualState> <VisualState x:Name="Normal" /> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <!--Marker--> <Ellipse Width="12" Height="12" Fill="Red" HorizontalAlignment="Left" VerticalAlignment="Top" /> <!--Label--> <Grid Margin="-200,-8,-200,0" MaxWidth="400" x:Name="labelOnHover" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Top" IsHitTestVisible="False"> <!--Text halo using a white blurred text--> <TextBlock Foreground="White" FontWeight="Bold" Text="{Binding Attributes[NAME]}" > <TextBlock.Effect> <BlurEffect Radius="5" /> </TextBlock.Effect> </TextBlock> <!--Text--> <TextBlock Foreground="Black" FontWeight="Bold" Text="{Binding Attributes[NAME]}" /> </Grid> </Grid> </ControlTemplate> </esri:MarkerSymbol.ControlTemplate> </esri:MarkerSymbol>
If you wrap the above template in a control, you can get access to the control when its created through its constructor, use the various override methods etc. Note though that the graphic it renders might change from time to time because of the virtualization going on under the covers (ie. if a graphic moves out of the map view, and another later moves in, the control instance might be reused to render this new graphic). Also note that there is no link from within this control back up to the graphic it is representing.