Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight Start up life cycle and binding
    text
    copied!<p>This is the first time I have used Silverlight and as such, I am new to the whole xaml markup style. I am building a GIS application using a silverlight library provided by ESRI.</p> <p>From my understanding, when the XAML page is parsed from top to bottom, the objects are created in the order. Is this correct? I have an esri Map object created on line 38 of my mainpage and then on line 247 of my mainpage, I create a DrawControl (a drawing control I made myself).</p> <p>Part of how the objects in drawing tool works is that it is created by passing the map object to the constructor. With my Map object with name x:Name="Map", I have the following for my drawcontrol:</p> <pre><code>&lt;local:DrawRootControl x:Name="DrawRoot" Height="152" Margin="216,10,0,0" Grid.Row="1" VerticalAlignment="Top" Visibility="Collapsed" map="{Binding ElementName=Map}"/&gt; </code></pre> <p>Then in my control, I have this in the code behind:</p> <pre><code>public static readonly DependencyProperty mapProperty = DependencyProperty.Register ( "map", typeof(Map), typeof(DrawRootControl), null ); public Map map { get { return (Map)GetValue(mapProperty); } set { SetValue(mapProperty, value); } } </code></pre> <p>..........</p> <pre><code>public DrawRootControl() { // Required to initialize variables InitializeComponent(); MyDrawObject = new Draw(map) { LineSymbol = CanvasDraw.Resources["DrawLineSymbol"] as LineSymbol, FillSymbol = CanvasDraw.Resources["DrawFillSymbol"] as FillSymbol }; MyDrawObject.DrawComplete += MyDrawObject_DrawComplete; } </code></pre> <p>When I am debugging, my map object in my constructor is null. I thought that if map is created earlier in the mainpage and then passed when I do that binding, it would not be null and would be initialized and created. Maybe I am doing binding incorrectly? I don't really understand the binding thing entirely.</p> <p>Any help would be appreciated. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload