Morten,Nevermind, I was able to figure this out on my own. The missing link for me was the ability to access styles/ControlTemplates for my marker symbols contained within a resource dictionary from the object class. For those of you who are interested, here's how it works.This is a control template for a circle marker symbol that is contained within a resource dictionary:
<ControlTemplate x:Key="CircleMarkerSymbol">
<Ellipse x:Name="ellipse"
Fill="{Binding Symbol.Color}"
Width="{Binding Symbol.Size}"
Height="{Binding Symbol.Size}"
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ellipse"
Storyboard.TargetProperty="Fill">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding Symbol.SelectionColor}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Ellipse>
</ControlTemplate>
This is my object class for the marker symbol. Notice the code in the constructor where I access the CircleMarkerSymbol ControlTemplate within my resource dictionary file. That was the key for me to piece this stuff together.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ESRI.ArcGIS.Client.Symbols;
namespace ESRIEditingTest.SymbolClasses
{
public class SRPDrawMarkerSymbol : MarkerSymbol
{
public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color", typeof(Brush), typeof(SRPDrawMarkerSymbol), null);
public static readonly DependencyProperty SelectionColorProperty = DependencyProperty.Register("SelectionColor", typeof(Brush), typeof(SRPDrawMarkerSymbol), null);
public static readonly DependencyProperty SizeProperty = DependencyProperty.Register("Size", typeof(double), typeof(SRPDrawMarkerSymbol), null);
// Methods
public SRPDrawMarkerSymbol()
{
this.Color = new SolidColorBrush(Colors.Red);
this.SelectionColor = new SolidColorBrush(Colors.Cyan);
ResourceDictionary resDict = new ResourceDictionary();
resDict.Source = new Uri("/ESRIEditingTest;component/Themes/ResDict.xaml", UriKind.Relative);
ControlTemplate = resDict["CircleMarkerSymbol"] as ControlTemplate;
}
public Brush Color
{
get
{
return (Brush)GetValue(ColorProperty);
}
set
{
SetValue(ColorProperty, value);
}
}
public Brush SelectionColor
{
get
{
return (Brush)GetValue(SelectionColorProperty);
}
set
{
SetValue(SelectionColorProperty, value);
}
}
public double Size
{
get
{
return (double)GetValue(SizeProperty);
}
set
{
SetValue(SizeProperty, value);
}
}
}
}
And finally the easy part - working with this in code behind. Here is how you instantiate the marker symbol object and set its properties. Since these properties are set with bindings in the control template, you can change them on the fly and your marker symbol in the map will reflect those changes automatically. This code sits in the DrawComplete event of a Draw object.
SRPDrawMarkerSymbol dms = new SRPDrawMarkerSymbol();
dms.Size = 70;
dms.Color = new SolidColorBrush(Colors.Green);
MapPoint p = e.Geometry as MapPoint;
gr = new Graphic
{
Geometry = p,
Symbol = dms
};