mstiso

where to put the "Code Behind C#" code?

Discussion created by mstiso on Aug 14, 2012
Latest reply on Aug 15, 2012 by mstiso
Hi. I'm using Microsoft Expression Blend to work with the ArcGIS SDK for WPF, and I'm a bit new to both. I have been trying to integrate some of the interactive samples in the "ArcGIS API for Silverlight" section into my code, and I am a bit confused about where to put the code in the "Code Behind C#" tab of those samples.

More specifically, I know how to find the code-behind files for MainWindow and App (and my various user controls), but I'm not sure in which of those I should put the code-behind from the sample.

For example, this is the code-behind for the ElementLayer sample (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ElementLayer):


[INDENT]using System.Windows;
using System.Windows.Controls;

namespace ArcGISSilverlightSDK
{
[INDENT] public partial class ElementLayer : UserControl
{
[INDENT]  public ElementLayer()
  {
   [INDENT]InitializeComponent();[/INDENT]
  }

  private void RedlandsButton_Click(object sender, RoutedEventArgs e)
  {
   [INDENT]MessageBox.Show("You found Redlands");[/INDENT]
  }
[/INDENT] }
[/INDENT]}
[/INDENT]


I've found through trial and error that I don't put all of that in MainWindow.xaml.cs. Rather, it seems that I need to include just the RedlandsButton_Click method to get things to work. But does that mean I can ignore the rest of the C# code, or do I need to put it elsewhere?

Any tips, or a point toward some relevant documentation, would be appreciated. Thanks much.

Outcomes