"element not found" = 0x8000490
"element not found" = 0x8000490
我目前正在学习 XAML 和通用 windows 应用程序。我遇到了一个问题,我找不到一个元素(来自 HRESULT:0x80070490 的异常),而且我似乎无法弄清楚该错误到底指的是哪里。如果我双击它,VS 会打开 MainPage.xaml,其中 <Page
带有下划线并带有错误。
没什么特别的...只是几个控件的集合。
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/320x480-1.jpg"/>
</Grid.Background>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="77,23,68,24">
<TextBox x:Name="HelloMessage" Text="Hello, World!" Margin="10" IsReadOnly="True"/>
<Button x:Name="ClickMe2" Content="Click Me!" Margin="10" HorizontalAlignment="Center" Click="ClickMe2_Click"/>
<Slider x:Name="slider" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Top" Width="100" BorderThickness="0,50,0,0"/>
</StackPanel>
</Grid>
这是从 VS 复制的准确错误。
Severity Code Description Project File Line Suppression State
Error Element not found. (Exception from HRESULT: 0x80070490) Control D:\Dev\TestUW\App1\App1\MainPage.xaml 1
我尝试删除网格,但错误仍然存在。我还验证了 App1.MainPage 也存在。我怎样才能弄清楚它到底在抱怨什么?
嗯,我注意到的第一件事是你的页面标签没有关闭或者你只是没有复制 that.Usually 找不到元素可能是由于过早调用某些东西造成的。你可以考虑使用 On_Loaded。如果问题只是您没有关闭 Page 标签,请确保在 Grid 标签之后关闭 ..
现在太晚了,但我 运行 遇到了同样的问题,从 MS OpenCV 示例中复制代码 link (https://developer.microsoft.com/en-us/windows/iot/samples/opencv)
问题是您需要在第一个 "page" 标记结束前添加一个 space " "。所以不是代码阅读:
mc:Ignorable="d"> <-- missing space after "d"
它应该是:
mc:Ignorable="d" >
我目前正在学习 XAML 和通用 windows 应用程序。我遇到了一个问题,我找不到一个元素(来自 HRESULT:0x80070490 的异常),而且我似乎无法弄清楚该错误到底指的是哪里。如果我双击它,VS 会打开 MainPage.xaml,其中 <Page
带有下划线并带有错误。
没什么特别的...只是几个控件的集合。
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/320x480-1.jpg"/>
</Grid.Background>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="77,23,68,24">
<TextBox x:Name="HelloMessage" Text="Hello, World!" Margin="10" IsReadOnly="True"/>
<Button x:Name="ClickMe2" Content="Click Me!" Margin="10" HorizontalAlignment="Center" Click="ClickMe2_Click"/>
<Slider x:Name="slider" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Top" Width="100" BorderThickness="0,50,0,0"/>
</StackPanel>
</Grid>
这是从 VS 复制的准确错误。
Severity Code Description Project File Line Suppression State
Error Element not found. (Exception from HRESULT: 0x80070490) Control D:\Dev\TestUW\App1\App1\MainPage.xaml 1
我尝试删除网格,但错误仍然存在。我还验证了 App1.MainPage 也存在。我怎样才能弄清楚它到底在抱怨什么?
嗯,我注意到的第一件事是你的页面标签没有关闭或者你只是没有复制 that.Usually 找不到元素可能是由于过早调用某些东西造成的。你可以考虑使用 On_Loaded。如果问题只是您没有关闭 Page 标签,请确保在 Grid 标签之后关闭 ..
现在太晚了,但我 运行 遇到了同样的问题,从 MS OpenCV 示例中复制代码 link (https://developer.microsoft.com/en-us/windows/iot/samples/opencv)
问题是您需要在第一个 "page" 标记结束前添加一个 space " "。所以不是代码阅读:
mc:Ignorable="d"> <-- missing space after "d"
它应该是:
mc:Ignorable="d" >