";元素未找到”=0x8000490

本文关键字:0x8000490 quot 元素 | 更新日期: 2023-09-27 18:26:46

我现在正在学习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也存在。我怎么才能弄清楚它到底在抱怨什么?

";元素未找到”=0x8000490

现在太晚了,但我遇到了同样的问题,从MS OpenCV示例链接复制代码(https://developer.microsoft.com/en-us/windows/iot/samples/opencv)

问题是在第一个"page"标记的末尾之前需要一个空格"。因此,不用读代码:

mc:Ignorable="d"> <-- missing space after "d"

它应该是:

mc:Ignorable="d" > 

我注意到的第一件事是你的页面标记没有关闭,或者你只是没有复制它。通常,找不到元素可能是由于过早调用某些内容而导致的。。您可以考虑使用On_Loaded。如果问题只是你没有关闭页面标记,请确保在网格标记之后关闭。。