Wrap Text Symbol on Map Area

3498
7
07-17-2012 04:07 AM
SaurabhDasgupta
New Contributor II
Hi,
   I have developed a application where I am putting text symbol using child window. I am able to wrap the text in the text box area by setting TextWrapping="Wrap" which is one of the property for the Text Box in Silverlight xaml page. Now when I click ok to put the text as a text symbol on the Map area, it puts as a straight line text. I want to wrap this text symbol to show it as a paragraph. Is it possible to do this or there are some limitations on this. Attached screen shots of the same.
Using Silverlight 4 with ArcGIS 10 & VS 2010.

Any ideas will greatly help

~Saurabh.
0 Kudos
7 Replies
DominiqueBroux
Esri Frequent Contributor
Setting a Width to your TextBox should force the Text to wrap to multi lines when the text length is greater than the textbox width.
0 Kudos
by Anonymous User
Not applicable
Original User: e_saurabh

Hi Domique,
               Thanks a lot for your reply. I am able to wrap the Text in the text box using TextWrapping="Wrap", but this does not effect the text on the map. This puts the text on the map as straight line. Need to know any idea if the Text Symbol can be broken to multilines on the map. I have set the width as something like as Width = "50", but with no effect for the text symbol on the map portion.

~Saurabh.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Not sure how you set the width. I think you have to set it in the control template of the text symbol.
Something like:
<ControlTemplate x:Key="TextSymbol">
  <TextBlock Width="50" TextWrapping="Wrap" Text="{Binding Symbol.Text}"
       FontFamily="{Binding Symbol.FontFamily}"
       FontSize="{Binding Symbol.FontSize}"
       Foreground="{Binding Symbol.Foreground}" />
</ControlTemplate>


But I didn't test so that might not work.
0 Kudos
by Anonymous User
Not applicable
Original User: e_saurabh

Hi Domique,
              Thanks again for your reply. I tried with your code but failed again. I am using something like this.

<Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel>
            <TextBlock Text="Text" />
            <TextBox x:Name="nameBox" Height="100" TextWrapping="Wrap" MaxLength="100"/>           
        </StackPanel>
        <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>


Let me know if anyone has some idea on this.

~Saurabh.
0 Kudos
JoeHershman
MVP Regular Contributor
Your sample code does not show how you are defining the TextSymbol in XAML or setting the TextSymbol in code so it is pretty hard to know what is happening.
Thanks,
-Joe
0 Kudos
by Anonymous User
Not applicable
Original User: dbroux

I don't see in your sample where you set the textbox width ?
0 Kudos
SaurabhDasgupta
New Contributor II
Hi
   I am setting the Text Symbol through code. Below is my code deatils for that..
ESRI.ArcGIS.Client.Symbols.TextSymbol textAnnotation = new TextSymbol();
                            string[] symbolDetails = redLineGeoExtent.GeometryData.Split('|');                                                     
                            textAnnotation.FontSize = Convert.ToDouble(13);
                            textAnnotation.Foreground = new SolidColorBrush
                            {                               
                                Color = Colors.Red
                            };
                            textAnnotation.OffsetX = Convert.ToDouble(symbolDetails[0]);
                            textAnnotation.OffsetY = Convert.ToDouble(symbolDetails[1]);
                            textAnnotation.Text = symbolDetails[2];
                            geometryString = geometryHelper.SplitGeometryCoordinates(symbolDetails[3]);
                            geometry = geometryHelper.GetPointGeometry(geometryString);
                            graphic.Geometry = geometry;
                            graphic.Symbol = textAnnotation;
                            graphicsLayer.Graphics.Add(graphic);


I am using a child window where I have put my text box and whatever I write to my text box is put on the map. I have put the width to my xaml page as

<Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel>
            <TextBlock Text="Text" Width = "50"/>
            <TextBox x:Name="nameBox" Height="100" TextWrapping="Wrap" MaxLength="100"/>           
        </StackPanel>
        <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
I am still n dark to get this text symbol broken into multilines on my map.
Let me know if anything else is required for my code.

~Saurabh.
0 Kudos