Strobe Symbol Migration from Silverlight 4 to WPF

1497
3
02-23-2011 05:44 AM
JoshuaCorcoran
New Contributor II
Hello,

I have migrated my Silverlight 4 WbeMapping application to WPF. I am having trouble migrating my Strobe symbol. The xaml works but when the strobes are flashing it slows down the application to a crawl. I am trying to convert the strobe symbol from XAML to C# to see if that will help. The code I have so far will display the point but the animations are not working. I have attached the screen shots of the code. Any help would be much appriciated.

Page1 & Page2.png - Code Files
Page3 - XAML File

Thanks.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
You can download WPF Interactive SDK from http://help.arcgis.com/en/webapi/silverlight/help/index.html#/Sample_Interactive_SDK/01660000000v000...

You will notice that SL and WPF are not very much alike with their Storyboard, specifically how they define their TargetProperty.
  <esri:MarkerSymbol x:Key="StrobeMarkerSymbol">
        <esri:MarkerSymbol.ControlTemplate>
          <ControlTemplate>
            <Canvas>
              <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                  <VisualState x:Name="MouseOver">
                    <Storyboard RepeatBehavior="Forever">
                      <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)" From="1" To="10" Duration="00:00:01" />
                      <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)" From="1" To="10" Duration="00:00:01" />
                      <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" />
                    </Storyboard>
                  </VisualState>
                  <!--If normal state is not specified, the animation will keep going until a mouse out. Keep it empty to transition back to original symbol. -->
                  <VisualState x:Name="Normal" />
                </VisualStateGroup>
              </VisualStateManager.VisualStateGroups>
              <!--Strobe ellipse-->
              <!--Note that IsHitTestVisible="False" on the strobe symbol, so only the static ellipse will trigger mouse over/mouse out-->
              <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" IsHitTestVisible="False">
                <Ellipse.RenderTransform>
                  <ScaleTransform />
                </Ellipse.RenderTransform>
                <Ellipse.Fill>
                  <RadialGradientBrush>
                    <GradientStop Color="#00FF0000" />
                    <GradientStop Color="#FFFF0000" Offset="0.25"/>
                    <GradientStop Color="#00FF0000" Offset="0.5"/>
                    <GradientStop Color="#FFFF0000" Offset="0.75"/>
                    <GradientStop Color="#00FF0000" Offset="1"/>
                  </RadialGradientBrush>
                </Ellipse.Fill>
              </Ellipse>
              <!--Static symbol on top-->
              <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" Fill="#FFFF0000" x:Name="ellipse1"/>
            </Canvas>
          </ControlTemplate>
        </esri:MarkerSymbol.ControlTemplate>
      </esri:MarkerSymbol>
0 Kudos
by Anonymous User
Not applicable
Original User: joshua.corcoran

Jennifer,

Thanks for the code. What I was looking for was using the Selected attribute not so much the MouseOver. I switch the VisualState to Selected and that works fine. The issue I am having is if I place 2000 points on the map and have them all flash at the same time the application slows down to a crawl. Is this a known WPF or ESRI bug or should the app be able to handle 2000 flashing points at a time?

V/R,

Josh
0 Kudos
JenniferNery
Esri Regular Contributor
You can look at the following Microsoft documentation about animation in WPF http://msdn.microsoft.com/en-us/library/bb613592.aspx. Animating 2000 features is expected to slow down your application. You can google about Hardware Acceleration for WPF, this might help improve performance.
0 Kudos