c# - InitializeComponent "doesn't exist" and "no definition" for XAML map controls -
i working on simple map app zoom , follow location using geocoordinatewatcher. problem is, whenever finish putting place, initializecomponents() throws exception , c# code won`t recognize xaml map controls. kind of bug or total fool?
code sample:
public mainpage() { this.initializecomponent(); // whole line underlined red this.navigationcachemode = navigationcachemode.required; } public void centeruserlocation() { // center mymap on user location this.mymap.center = mypoint; //mymap underlined red this.mymap.zoomlevel = 10; //mymap underlined red } update: (class definitions c#)
namespace mapapp{ public sealed partial class mainpage : page { geocoordinatewatcher watcher; private geopoint mypoint; update: (xaml)
<page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:mapapp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:maps="using:windows.ui.xaml.controls.maps" x:class="mapapp.mainpage" mc:ignorable="d" background="{themeresource applicationpagebackgroundthemebrush}"> <page.bottomappbar> <commandbar> <!-- location button --> <appbarbutton x:uid="locateappbarbutton" x:name="locateappbarbutton" label="location" icon="map" click="locateappbarbutton_click" /> </commandbar> </page.bottomappbar> <grid> <maps:mapcontrol x:name="mymap" horizontalalignment="left" verticalalignment="top" height="580" width="400"/> </grid> </page>
your xaml , code-behind should this:
xaml:
<page x:class="mynamespace.mycanvascodeinline"> ... code-behind:
namespace mynamespace { public partial class mycanvascodeinline // : page - not needed implied ... things should check:
- the code-behind class defined
partial - the code-behind class qualified name (namespace + class name) same
x:classproperty of xaml root node - the xaml root node class implements icomponentconnector (page, window, usercontrol, etc.)
another way checking xaml.cs file gets generated "under" xaml file, , compare partial class definition code-behind class. should match types, name , namespace.
Comments
Post a Comment