【发布时间】:2016-12-22 22:45:14
【问题描述】:
我目前正在学习 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 也存在。我怎样才能弄清楚它到底在抱怨什么?
【问题讨论】:
-
您所说的 WPF 是什么意思,您的目标是 UWP? (这是两个不同的东西)。也许您的意思是 XAML?正如我所尝试的,在 UWP 中你的代码应该可以工作。
-
如有疑问,请将所有 C# 和 xaml 代码移至另一个项目。
-
是的,两者都有 XAML。抱歉,我应该说 XAML。
-
很奇怪,如果创建空白的新项目 - 你能构建它吗?如果不是同一种情况也可以试试like here.
-
看起来它可能是微软的错误...我刚刚更新了消除错误的 nuget 包 Microsoft.ApplicationInsights、Microsoft.ApplicationInsights.PersistenceChannel 和 Microsoft.ApplicationInsights.WindowsApps。
标签: c# xaml win-universal-app uwp