【发布时间】:2018-06-06 01:07:04
【问题描述】:
每当我尝试使用 XAML+CS 创建页面时,我的 Xamarin.Forms 项目都会出现此错误。
我已使用自定义工具 MSBuild:UpdateDesignTimeXaml 将 XAML 页面的构建操作设置为 EmbeddedResource。
我检查了 .csproj 并正确设置了构建操作:
<ItemGroup>
<EmbeddedResource Include="AppCore\Pages\SettingsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
还有:
<Compile Include="AppCore\Pages\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
清理解决方案并删除 obj/bin 文件夹没有帮助,也没有通过 update-package -project Travlendar.Core -reinstall 重新安装软件包。
这是设置页面:
using Travlendar.Core.AppCore.ViewModels;
using Xamarin.Forms;
namespace Travlendar.Core.AppCore.Pages
{
public partial class SettingsPage : ContentPage
{
public SettingsPage (INavigation navigation)
{
InitializeComponent ();
BindingContext = new SettingsViewModel (this, navigation);
}
}
}
【问题讨论】:
-
您的
SettingsPage.xaml.cs包含什么内容? -
在构建之前尝试关闭 settingspage.xaml.cs。不知道为什么它会有所帮助,但确实如此。
-
@SushiHangover 将代码添加到问题中,但没有什么特别之处..
-
@KenTucker 行为与以前相同..
标签: c# .net xaml xamarin xamarin.forms