Click here to Skip to main content
15,065,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I am trying to create a style that is to be applied to a Bing Map PushPin control. But I need to set the location of the Pushpin from the page where the control is implemented (like templateBinding) and not in the style. The control template in the style will be applied on an infobox which will be bound to the location which the pushpin is placed in the main page.
When I am not creating a style and adding the template in the mainpage itself, I am getting the bound values i.e the Latitude and Longitude. But when I am putting it in a style in a resource dictionary, I am not getting the bound fields. What should be the correction made here in the resource dictionary file. PFB the style :-
<!--Style for PushPin-->
<Style x:Key="myPushpinStyle" TargetType="m:Pushpin">
    <Setter Property="Template">
                <m:Pushpin Name="myPin" Background="{TemplateBinding Property=Background}">
                    <ToolTip Focusable="True" Opacity="50">

                                <Border CornerRadius="5" Width="180" Height="auto" MinHeight="60" Opacity="50" ToolTipService.ShowDuration="12000">
                                            <GradientStop Color="#DAFDA7" Offset="0"/>
                                            <GradientStop Color="Green" Offset="1"/>
                                            <RowDefinition Height="20"></RowDefinition>
                                            <RowDefinition Height="20"></RowDefinition>
                                            <RowDefinition Height="20"></RowDefinition>
                                            <RowDefinition Height="30*"></RowDefinition>

                                        <TextBlock Grid.Row="0" FontSize="12" FontWeight="Bold">Information</TextBlock>
                                        <TextBlock Grid.Row="1" VerticalAlignment="Top">Latitude</TextBlock>
                                        <TextBlock Grid.Row="2" VerticalAlignment="Top">Longitude</TextBlock>
                                        <TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Top">
                                                    <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type m:Pushpin}}" Path="Location.Latitude">
                                        <TextBlock Grid.Row="2" Grid.Column="1" VerticalAlignment="Top">
                                                <Binding Path="Location.Longitude">
                                                        <RelativeSource Mode="Self"/>
stibee 24-Jun-13 12:12pm
Does only the binding didn't run? Does the rest of the style run?
Jashobanta 25-Jun-13 1:21am
The rest of style runs. But the binding is showing blank text.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900