Select to view content in your preferred language

Modifying symbol properties at runtime

665
3
08-01-2010 08:02 PM
linusang
Emerging Contributor
Hi, I would like the user to be able to change color and width of the LineSymbol class

i tried this in my resource dictionary...

<esri:LineSymbol x:Key="DefaultLineSymbol">
        <esri:LineSymbol.ControlTemplate>
            <ControlTemplate>
                <Path x:Name="Element" Stroke="{TemplateBinding Color}" StrokeThickness="{TemplateBinding Width}" />
            </ControlTemplate>
        </esri:LineSymbol.ControlTemplate>
    </esri:LineSymbol>


but there is a compile error saying ColorProperty is not in Control type

Any suggestions?
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
Try binding to the symbol:


<esri:LineSymbol x:Key="DefaultLineSymbol">
        <esri:LineSymbol.ControlTemplate>
            <ControlTemplate>
                <Path x:Name="Element" Stroke="{Binding Symbol.Color}" StrokeThickness="{Binding Symbol.Width}" />
            </ControlTemplate>
        </esri:LineSymbol.ControlTemplate>
    </esri:LineSymbol>
0 Kudos
MartenLiebster
Deactivated User
Not sure if it's the preferred way or not, but I did this in my symbol and it works fine:

(I realize the context is a bit different, in that I did inside of a MarkerSymbol instead)
<Ellipse 
  Fill="{Binding Attributes, 
         Converter={StaticResource DictionaryConverter}, 
         ConverterParameter=EllipseFill, 
         Mode=OneWay}"
                                     Height="10"
                                     HorizontalAlignment="Left"
                                     Margin="-5,-5,0,0"
                                     VerticalAlignment="Top"
                                     Width="10" />


The EllipseFill value comes from the graphic's attribute collection.

*** EDIT ****

Looking over the blogs and changes for 2.0, looks like the converter is no longer needed.

An updated way might be like this:

<Ellipse 
  Fill="{Binding Attributes[EllipseFill], Mode=OneWay}"
                                     Height="10"
                                     HorizontalAlignment="Left"
                                     Margin="-5,-5,0,0"
                                     VerticalAlignment="Top"
                                     Width="10" />
0 Kudos
linusang
Emerging Contributor
Try binding to the symbol:


Thanks this works great...
0 Kudos