AE xaml中定义的控件,在xaml.cs中无法用名称调用
这是页面的代码:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Loaded="Window Loaded"
Title="MainWindow" Height="350" Width="525">
<Grid>
<my:WindowsFormsHost Margin="2" x:Name="TocControlHost" />
<my:WindowsFormsHost Grid.Column="1" x:Name="MapControlHost" Margin="308,6,299,33" >
<my:WindowsFormsHost x:Name="ToolControlHost" Margin="2" />
</Grid>
</Window>
后台代码:
AxMapControl mapControl;
AxToolbarControl toolbarControl;
AxTOCControl tocControl;
public MainWindow()
{
InitializeComponent();
CreateEngineControls();
}
private void CreateEngineControls()
{
mapControl = new AxMapControl();
this.MapControlHost.Child = mapControl;
}
this.MapControlHost.Child = mapControl; 这句提MapControlHost不存在,可是在上面的代码中我已经定义了啊,求各位帮我解答。