Select to view content in your preferred language

Add Label to a FillSymbol

492
1
09-10-2013 12:37 PM
CW
by
Emerging Contributor
Sorry if this is a bit ignorant but I'm still pretty new to the API. I'm trying to figure out how I can put a label (TextBlock) on a FillSymbol?

I need it to show in the center of the dynamic FillSymbol while still being able to utilize VisualStateManager etc. I tried something like shown below (which will at least show you the concept) and it works, except when I do then my VisualStateManager gets ignored. I've also tried incorporating a TextSymbol with no luck. I'm sure there's something simple I'm missing, just needing another pair of eyes to identify my folly and point me in the right direction please. Attempt as follows.;

<esri:FillSymbol x:Key="TheFill"  Fill="{Binding TheColor}">
            <esri:FillSymbol.ControlTemplate>
                <ControlTemplate>
<Canvas>
                    <Path x:Name="Element"
                Stroke="Gold"
                StrokeThickness="2"
    StrokeDashArray="2,1"
    StrokeDashOffset="0"
                Fill="{Binding Symbol.Fill}"       
                StrokeStartLineCap="Round"
                StrokeEndLineCap="Round"
                StrokeLineJoin="Round" Cursor="Hand">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation BeginTime="00:00:00"
                                      Storyboard.TargetName="Element"
                                      Storyboard.TargetProperty="Opacity"
                                      To=".3"
                                      Duration="0:0:0.25" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation BeginTime="00:00:00"
                                      Storyboard.TargetName="Element"
                                      Storyboard.TargetProperty="Opacity"
                                      To=".5"
                                      Duration="0:0:0.25" />
                                        <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="Element" Storyboard.TargetProperty="StrokeDashOffset" To="1000" Duration="0:5:0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation BeginTime="00:00:00"
                                      Storyboard.TargetName="Element"
                                      Storyboard.TargetProperty="Opacity"
                                      To=".5"
                                      Duration="0:0:0.25" />                                   
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Path>
<!-- My un-clever attempt -->
<TextBlock Text="HEY! HEY! HEY!"/>
</Canvas>              
                </ControlTemplate>
            </esri:FillSymbol.ControlTemplate>
        </esri:FillSymbol>
0 Kudos
1 Reply
CW
by
Emerging Contributor
I'm sorry I'll likely be deleting this thread since I answered myself. I must be getting tired, I just moved the VSM from the PATH to the Parent CANVAS and it works like a charm. Thanks to anyone who may have looked.
0 Kudos