Почему бы не попробовать Custom Control
с пользовательским шаблоном. Используйте
`{TemplateBinding Content}`
для связывания Content
с контролем Map
.
Пример:
<Style TargetType="local:MVVMMapControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MVVMMapControl">
<Grid x:Name="LayoutRoot"
Background="White">
<m:Map CredentialsProvider="Al_H1LepP6chseYMu31RK76El6k4SUkx2KVrxeqobE3rTXooFPieuEJ6qiuA211I"
CopyrightVisibility="Collapsed"
LogoVisibility="Collapsed"
ScaleVisibility="Visible"
NavigationVisibility="Visible"
x:Name="MyMap"
Content="{TemplateBinding ContentControl.Content}"></m:Map>
<ComboBox x:Name="c_MapTypes"
HorizontalAlignment="Right"
VerticalAlignment="Top"
SelectedIndex="0"
Height="30"
SelectionChanged="MapTypes_SelectionChanged">
<ComboBoxItem>Google Roads</ComboBoxItem>
<ComboBoxItem>Google Aerial</ComboBoxItem>
<ComboBoxItem>Bing Maps Roads</ComboBoxItem>
<ComboBoxItem>Bing Maps Aerial</ComboBoxItem>
<ComboBoxItem>Open Street Maps</ComboBoxItem>
<ComboBoxItem>Yahoo Street</ComboBoxItem>
<ComboBoxItem>Yahoo Aerial</ComboBoxItem>
<ComboBoxItem>Blank Map</ComboBoxItem>
</ComboBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Класс:
public class MVVMMapControl : ContentControl // Notice this inherits from ContentControl for its Content Property
{
public MVVMMapControl()
{
this.DefaultStyleKey = typeof(MVVMMapControl);
}
}