ENC with <Checkbox> items

I was able to run down my problem with the Checkbox items in the ENC OWS example.

Fig 1 – ENC WMS over WPF XAML TIN model using Checkbox tree for WMS layers


I was using an XmlDataProvider to populate a TreeView
with a Hierarchical DataTemplate like this:

<TreeView Name=”ENCGetCapabilities”
   Width=”Auto” Height=”500″ BorderThickness=”0″
   SelectedValuePath=”{Binding XPath=Name}”
   Background=”{DynamicResource {x:Static SystemColors.ControlBrushKey}}”

   <Binding Source=”{StaticResource ENCWMS}”
   XPath=”Capability/Layer/Layer[(ScaleHint/@max = 0.0033645577994830035) and
    (ScaleHint/@min >= 0.0) and
    not(starts-with(./Name,'1')) and
    not(starts-with(./Name,'2')) and
   <HierarchicalDataTemplate DataType=”Layer” ItemsSource =”{Binding XPath=Layer}”>
    <CheckBox Checked=”CheckBoxChange” Unchecked=”CheckBoxChange” Margin=”2,2,2,2″    Tag=”{Binding XPath=Name}” Content=”{Binding XPath=Name}” FontSize=”9″>


This works very well providing the GetCapabilities layers in a tree of checkboxes. The problem
was when the Checked event fired, the CheckBoxChange callback was having trouble determining the layer.

   void CheckBoxChange(object sender, RoutedEventArgs args)


      CheckBox checkedBox = args.Source as CheckBox;

      string layer = checkedBox.Content.toString()

checkedBox.Content.toString() returned an object label instead of a string. I finally noticed that the object
returned was a System.Xml.XmlElement.
I was then able to cast checkedBox.Tag as an XmlElement and access its InnerText.

string layer = ((XmlElement)checkedBox.Tag).InnerText;

Now the layers from the ENC WMS service can be additive and overlay the base textures
from the toolbox selection list.

Comments are closed.