Terry, Sorry for all the post I think I have the bool but still running into a empty error so I'm wondering if you are binding the text somehow. I figured I would paste my code and maybe you would have time to take a look.It is failing at the line (_activeSymbol as TextSymbol).Text = txtText.Text; and stating object null but i have text in my textbox so I'm wonding what I"m missing.XAML
<StackPanel Orientation="Vertical" Margin="3">
<StackPanel x:Name="MyStackPanel" Orientation="Horizontal">
<Button Tag="DrawPoint" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a point">
<Image Source="images/DrawPoint.png" Margin="2" />
</Button>
<Button Tag="DrawPolyline" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a polyline">
<Image Source="images/DrawPolyline.png" Margin="2" />
</Button>
<Button Tag="DrawPolygon" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a polygon">
<Image Source="images/DrawPolygon.png" Margin="2" />
</Button>
<Button Tag="DrawRectangle" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a rectangle">
<Image Source="images/DrawRectangle.png" Margin="2" />
</Button>
<Button Tag="DrawFreehand" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a freehand line">
<Image Source="images/DrawFreehand.png" Margin="2" />
</Button>
<Button Tag="DrawArrow" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add an arrow">
<Image Source="images/DrawArrow2.png" Margin="2" />
</Button>
<Button Tag="DrawTriangle" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a triangle">
<Image Source="images/DrawTriangle2.png" Margin="2" />
</Button>
<Button Tag="DrawCircle" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add a circle">
<Image Source="images/DrawCircle2.png" Margin="2" />
</Button>
<Button Tag="DrawEllipse" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add an ellipse">
<Image Source="images/DrawEllipse2.png" Margin="2" />
</Button>
<Button Tag="EnterText" Margin="5" Click="Tool_Click"
ToolTipService.ToolTip="Add text">
<Image Source="images/text.png" Margin="2" />
</Button>
<Button Tag="DrawNothing" Margin="5" Click="Tool_Click"
Style="{x:Null}"
ToolTipService.ToolTip="Unselect Current Tool">
<Image Source="images/dismiss.png" Margin="2" />
</Button>
<Button Tag="ClearStopDraw" Margin="5" Click="Tool_Click"
Style="{x:Null}"
ToolTipService.ToolTip="Clear graphics">
<Image Source="images/StopDraw.png" Margin="2" />
</Button>
</StackPanel>
<CheckBox x:Name="EnableEditVerticesScaleRotate" Content="Click on geometry to edit"
IsChecked="False" Foreground="Black" FontWeight="Bold" Margin="10,5,5,5" />
<TextBox x:Name="txtText" Text="" />
</StackPanel>
CODE BEHIND
private void MyDrawObjectGraphic_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
if (_bolText) //if user selected text from drawing options
{
(_activeSymbol as TextSymbol).Text = txtText.Text; //FAILING HERE STATING NULL
txtText.Text = string.Empty;
// spText.Visibility = Visibility.Collapsed;
}
ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = args.Geometry,
Symbol = _activeSymbol,
};
graphicsLayer.Graphics.Add(graphic);
graphicsLayer.Refresh();
}
private void GraphicsLayerG_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
{
if (EnableEditVerticesScaleRotate.IsChecked.Value)
{
MyDrawObjectGraphic.DrawMode = DrawMode.None;
UnSelectTools();
Editor editor = LayoutRoot.Resources["MyGraphicEditor"] as Editor;
if (e.Graphic != null && !(e.Graphic.Geometry is ESRI.ArcGIS.Client.Geometry.MapPoint))
editor.EditVertices.Execute(e.Graphic);
}
}
private void UnSelectTools()
{
foreach (UIElement element in MyStackPanel.Children)
if (element is Button)
VisualStateManager.GoToState((element as Button), "UnSelected", false);
}
private void Tool_Click(object sender, RoutedEventArgs e)
{
UnSelectTools();
VisualStateManager.GoToState(sender as Button, "Selected", false);
switch ((sender as Button).Tag as string)
{
case "DrawPoint":
MyDrawObjectGraphic.DrawMode = DrawMode.Point;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicMarkerSymbol"] as Symbol;
break;
case "DrawPolyline":
MyDrawObjectGraphic.DrawMode = DrawMode.Polyline;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicLineSymbol"] as Symbol;
break;
case "DrawPolygon":
MyDrawObjectGraphic.DrawMode = DrawMode.Polygon;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawRectangle":
MyDrawObjectGraphic.DrawMode = DrawMode.Rectangle;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawFreehand":
MyDrawObjectGraphic.DrawMode = DrawMode.Freehand;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicLineSymbol"] as Symbol;
break;
case "DrawArrow":
MyDrawObjectGraphic.DrawMode = DrawMode.Arrow;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawTriangle":
MyDrawObjectGraphic.DrawMode = DrawMode.Triangle;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawCircle":
MyDrawObjectGraphic.DrawMode = DrawMode.Circle;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "DrawEllipse":
MyDrawObjectGraphic.DrawMode = DrawMode.Ellipse;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicFillSymbol"] as Symbol;
break;
case "EnterText":
MyDrawObjectGraphic.DrawMode = DrawMode.Point;
_activeSymbol = LayoutRoot.Resources["DefaultGraphicMarkerSymbol"] as Symbol;
_bolText = true;
break;
case "DrawNothing":
MyDrawObjectGraphic.DrawMode = DrawMode.None;
break;
default:
MyDrawObjectGraphic.DrawMode = DrawMode.None;
graphicsLayer.ClearGraphics();
break;
}
MyDrawObjectGraphic.IsEnabled = (MyDrawObjectGraphic.DrawMode != DrawMode.None);
}