My WPF program uses a third party map package which has a WPF map control. My program needs to be able to run on a system which does not have this software installed, and it needs to be smart enough to recognize when the software is installed and use it. This means that I can't include any XAML for the map control in my form's XAML file or XAML parse exceptions are thrown.
I have a technique for determining if the software is installed. In my program's initialization code, I set a property of the Application object called MapsAreInstalled
to true if the mapping software is installed, and I set it to false if it is not.
In my form, which is a UserControl, I've added an override of the OnApplyTemplate method. This checks the value of the MapsAreInstalled
property and creates a new map control if the value is true. Here's the XAML that I was using to create this control before it became obvious that I had to change my approach:
<telogis:MapControl ButtonBase.Click="CarImage_Click"
Canvas.Left="0"
Canvas.Top="0"
Center="41.366674544084,-73.6112966322899"
DragBehavior="None"
Heading="0"
Height="{Binding ElementName=ChannelCanvas, Path=ActualHeight}"
MapQuality="Perfect"
Name="ReadMap"
Perspective="TwoD"
RenderLabels="True"
UiEnable="True"
Width="{Binding ElementName=ChannelCanvas, Path=ActualWidth}"
Zoom="50" />
I know how to initialize all of these properties in the code behind EXCEPT the ButtonBase.Click
event handler. How do I set this up in the code-behind?
Tony