How can I use the Pushpin?

Feb 3, 2009 at 9:20 PM
If I add this to the Page contructor in the prototype project

GeometryLayer myLayer = new GeometryLayer(map) { UpdateMode = GeometryLayer.UpdateModes.PanOnlyUpdate };


Style pinStyle = Application.Current.Resources["RoadWarriorPinStyle"] as Style;
DevPin devPin = new DevPin { Point = new Point(-122.791, 45.45) };
devPin.Style = pinStyle;


I get a DevPin where I work. Nice.
I'm not really a RoadWarrior so I try something else for the last four lines:

Style pinStyle1 = Application.Current.Resources["PushpinStyle"] as Style;
Pushpin pushPin = new Pushpin { Point = new Point(-122.791, 45.45) };
pushPin.Style = pinStyle1;     
// Catastrophic failure


I get an error:

{System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
   at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)
   at System.Windows.FrameworkElement.set_Style(Style value)
   at DeepEarthPrototype.Page..ctor()}

Is that intended? How can I use the Pushpin? Can I find this somewhere in a tutorial or help file/site (I tried DeepEarth.chm, no luck)?

Feb 4, 2009 at 12:28 AM
In your style, make sure that there's something along the lines of:

    <ScaleTransform x:Name="_ScaleTransform" ScaleX="1" ScaleY="1" />

Of course changing the type of the element you're attaching the transform to.

I found with DeepEarth 1.1 the new Pushpin/Devpin rely on this existing, if you do not directly override the OnApplyTemplate() in your own inherited classes.
Feb 4, 2009 at 2:56 AM
That's okay Marc.  There can only be so many RoadWarriors. 

Try just doing this:

            Pushpin pushPin = new Pushpin { Point = new Point(-122.791, 45.45) };

PushPin happens to apply it's template in it's constructor.  So essentially, your prior code was applying the same Template for the second time.
Feb 4, 2009 at 3:26 AM
Why didn't I think of that?

Thank you!