Custom unique value renderer is not showing in Sharepoint

1816
1
03-01-2012 11:40 AM
AzizaParveen2
New Contributor III
Hi,

I developed a custom tool and a custom behaviour using ArcGIS API for Silverlight and I have created a custom unique value renderer
in the behavior.cs file where I also define my feature layer and intialized it but I have created the symbol in the user control.resources in XAML file and I accessed them from the code behind as suggested in the sharepoint Help document, and it works fine when I debug it in using visual studio template, but when I add it to Sharepoint the symbol is not showing.

Here is the code in Behavior.cs

protected override void OnAttached()
        {
            base.OnAttached();


           UniqueValueInfo uValinfoApproved = new UniqueValueInfo();
           uValinfoApproved.Symbol = locateAddDialog.Resources["GreenStickPinSymbol"] as Symbol;
           uValinfoApproved.Value = "Approved";

           UniqueValueInfo uValInfoDenied = new UniqueValueInfo();
           uValInfoDenied.Symbol = locateAddDialog.Resources["RedStickPinSymbol"] as Symbol;
           uValInfoDenied.Value = "Denied";

           UniqueValueInfo uValInfoPending = new UniqueValueInfo();
           uValInfoPending.Symbol = locateAddDialog.Resources["YellowStickPinSymbol"] as Symbol;
           uValInfoPending.Value = "Pending";

           UniqueValueRenderer PlanStatusRenderer = new UniqueValueRenderer()
           {
               Field = "PLAN_STATUS",
               DefaultSymbol = locateAddDialog.Resources["YellowStickPinSymbol"] as Symbol
              
           };
          
            PlanStatusRenderer.Infos.Add(uValinfoApproved);
            PlanStatusRenderer.Infos.Add(uValInfoDenied);
            PlanStatusRenderer.Infos.Add(uValInfoPending);

            if (locateAddDialog == null)
                locateAddDialog = new LocateAddressDialog();
            Map currentMap = MapApplication.Current.Map;
            if (currentMap != null)
            {
                if (prePlanfs == null)
                {
                    prePlanfs = currentMap.Layers["prePlanAdd"] as FeatureLayer;

                    if (currentMap.Layers["prePlanAdd"] == null)
                    {
                        prePlanfs = new FeatureLayer();
                        prePlanfs.Url = "http://rrugisprod-w1/RRUArcGIS/rest/services/test_preplan/FeatureServer/0";
                        prePlanfs.OutFields.AddRange(new string[] { "OBJECTID_1", "OBJECTID", "BATT", "PRA", "XCOORD", "YCOORD", "STREET_ADD", "JPEGS", "PLAN_STATUS" });
                        prePlanfs.ID = "prePlanAdd";
                        prePlanfs.Renderer = PlanStatusRenderer;

                        //SimpleRenderer simpleRenderer = new SimpleRenderer();
                        //simpleRenderer.Symbol = locateAddDialog.Resources["SelectedMarkerSymbol"] as Symbol;
                        //prePlanfs.Renderer = simpleRenderer;

                        prePlanfs.Initialize();
                        prePlanfs.InitializationFailed += new EventHandler<EventArgs>(prePlanfs_InitializationFailed);
                        currentMap.Layers.Add(prePlanfs);
                       
                    }
                 
                }

             //MapApplication.Current.ShowWindow("Locate Address", locateAddDialog, false);
             prePlanfs.MouseLeftButtonUp += new GraphicsLayer.MouseButtonEventHandler(prePlanfs_MouseLeftButtonUp);
            }
        }

Code in XAML file


<UserControl.Resources>
        <!-- Yellow Symbol for Pending Status-->
        <esri:PictureMarkerSymbol x:Key="YellowStickPinSymbol">
            <esri:PictureMarkerSymbol.ControlTemplate>
                <ControlTemplate>
                    <Canvas>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <!--Will show the ellipse-->
                            <vsm:VisualStateGroup x:Name="SelectionStates">
                                <vsm:VisualState x:Name="Selected">
                                    <Storyboard RepeatBehavior="ForEver">
                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="3" Duration="00:00:01" />
                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="3" Duration="00:00:01" />
                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unselected">
                                 </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <!--Will not show the ellipse-->
                                <vsm:VisualState x:Name="Normal">
                                    <!--<Storyboard RepeatBehavior="ForEver">
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ellipse" Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>-->
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Mouseover">
                                    </vsm:VisualState>
                            </vsm:VisualStateGroup>

                        </vsm:VisualStateManager.VisualStateGroups>


                        <Ellipse Height="20" Width="20" Canvas.Left="-5" Canvas.Top="-5" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" IsHitTestVisible="False" Opacity="0">
                            <Ellipse.RenderTransform>
                                <ScaleTransform />
                            </Ellipse.RenderTransform>
                            <Ellipse.Fill>
                                <RadialGradientBrush>
                                    <GradientStop Color="#FFFFA07A" />
                                    <GradientStop Color="#FFFFFFE0" Offset="0.25" />
                                    <GradientStop Color="#FFFFA07A" Offset="0.5" />
                                    <GradientStop Color="#FFFFFFE0" Offset="0.75" />
                                    <GradientStop Color="#FFFFA07A" Offset="1" />
                                </RadialGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>
                        <Image Height="20" Width="20" Canvas.Left="-5" Canvas.Top="-5" x:Name="YellowStickPin" Source="/PrePlan_012412.AddIns;component/Images/YellowStickpin_bgtp.png"></Image>
                      </Canvas>
                </ControlTemplate>
            </esri:PictureMarkerSymbol.ControlTemplate>
        </esri:PictureMarkerSymbol>

            </UserControl.Resources>

I just find out that our SharePoint site is running on .Net Framework 2.0, if it helps.
I will really appreciate any help.
Thanks so much.
0 Kudos
1 Reply
by Anonymous User
Not applicable
You certainly can access symbols from control.resources.  Where are you defining the red and green stick pin symbol within your XAML, as I don't see that in your sample?

Regards,
Doug C.
Esri Support Services
0 Kudos