I have a third party usercontrol that I have to use to display a Map, unfortunately this third party control does not support data binding but the framework I have to use it in can only pass data via binding.
Example code:-
As things stand I can add the third party control to a page's XAML file like this:-
<ViewerControl:Viewer x:Name="Viewer"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
MouseMove="OnMouseMove">
</ViewerControl:Viewer>
Then I can define a map layer and add it to the map in the codebehind like this:-
var layerDefinition = new WMSLayerDefinition("AFG_AGS_1M_MFS",
new Extent(59.7812, 26.9152, 75.5985, 40.9476),
"EPSG:4326") { IsSelectable = true };
var wmsLayer = new WMSLayer(Viewer.GetViewController(),
layerDefinition,
"http://ogc.bgs.ac.uk/cgi-bin/BGS_AGS_EN_Bedrock_and_Structural_Geology/wms/");
Viewer.GetLayerManager().GetLayerGroup(layerGroupName).AddLayer(wmsLayer);
What I would like to be able to do is bind an ObservableCollection
of WMSLayer (or my own model that is a little more generic than the one used by the viewer) to the viewer, however as I don't have access to the viewer code I'm assuming that I would need to write a wrapper
control.
As far as I can see the wrapper
control would need to contain an instance of the third party usercontrol and a DependencyProperty
to allow me to bind a ObservableCollection
of Map Layer data so that I can use it as the parameters for the methods on the third party usercontrol.
I have read so many examples of binding in custom usercontrols that my head is spinning, unfortunately they all deal with presenting the bound data in the UI. What I want to do is pass the bound data on to another control that will take care of the presentation, I know that this is not really the correct way for Silverlight controls to work but as I have no influence over the design of the third party usercontrol I can't see any other way around this.
Can anyone help me to understand how I can access the bound data in my wrapper
usercontrol and pass it into the methods exposed by the third party usercontrol please?
Thanks in advance :o)