Is there a add text markup tool for silverlight?

3648
10
10-28-2011 02:15 PM
YingLin
New Contributor
I am looking for a tool that can allow user to add custom text to the map and then create custom map in silverlight. I have graphic tools for adding polygon, rectangle, freehand graphics but didn't see one for adding text. Maybe i missed. Any one can point me out where i can find the tool?
THanks very much
0 Kudos
10 Replies
JenniferNery
Esri Regular Contributor
You can use a MarkerSymbol with TextBox. Maybe create a two-way binding on a graphic.Attribute too if you want TextBox.Text saved per graphic.

            <esri:MarkerSymbol x:Key="MySymbol">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <TextBox Text="Type here"/>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>
0 Kudos
YingLin
New Contributor
I have put the marker with the textbox on to the map. DrawMode was set to be point.

problems
1. need to click on the textbox many times to be able to enter text in the box.
2. the text and textbox is added to the graphicLayer but not preserved when creating the custom map. same code was using for adding polygons which works fine.

Thanks very much
0 Kudos
YingLin
New Contributor
here is a screenshot of the second problem. the upper part is the text I entered on the map. the lower part is the custom map. you can see the text box has the default text rather than the one i entered.
Thanks
0 Kudos
YingLin
New Contributor
Trying to add the value from the textbox in code behind when adding the graphics to the custom map. no success.
How can I set the two way binding for the textbox inside the markersymbol control template?
Thanks very much
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Trying to add the value from the textbox in code behind when adding the graphics to the custom map. no success.
How can I set the two way binding for the textbox inside the markersymbol control template?
Thanks very much


Did you try something like ?

<esri:MarkerSymbol x:Key="MySymbol">
      <esri:MarkerSymbol.ControlTemplate>
            <ControlTemplate>
                  <TextBox Text="{Binding Attributes[MyAttribute], Mode=TwoWay, TargetNullValue=Null}"/>
             </ControlTemplate>
       </esri:MarkerSymbol.ControlTemplate>
</esri:MarkerSymbol>


0 Kudos
YingLin
New Contributor
I am not sure how to do this two way binding. how can I set the dynamic text value to the markersymbol and save it in the graphic if not doing it in code behind?
Thanks
0 Kudos
YingLin
New Contributor
I have figured out with code behind. First, get the text value, then add the value to the graphic's attribute when creating the custom map.

clonedGraphic.Attributes.Add(o.key, _mytext)

Thanks for ur help
0 Kudos
TedChapin
Occasional Contributor III
You can use a MarkerSymbol with TextBox. Maybe create a two-way binding on a graphic.Attribute too if you want TextBox.Text saved per graphic.

            <esri:MarkerSymbol x:Key="MySymbol">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <TextBox Text="Type here"/>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>


I can add a graphic with a textbox marker symbol, but it does not respond to the GraphicsLayer.MouseLeftButtonUp event.  I want to allow users to delete the text graphic with GraphicsLayer.Graphics.Remove(e.Graphic) in that event.

Ted Chapin
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I can add a graphic with a textbox marker symbol, but it does not respond to the GraphicsLayer.MouseLeftButtonUp event. I want to allow users to delete the text graphic with GraphicsLayer.Graphics.Remove(e.Graphic) in that event.


LeftButtonDown and Up are used by the TextBox for the editing. So you can reuse them for another purpose.
MouseRightButtonDown event should work.
0 Kudos