- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在利用业余时间开发一个 UWP 项目,以熟悉 UWP、MVVM 和 Prism。该项目最初非常经典,没有使用 MVVM 和 Prism,我一直在努力将这 2 个纳入项目。我一直依赖https://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40).aspx , https://msdn.microsoft.com/en-us/library/gg405494(v=pandp.40).aspx和 https://msdn.microsoft.com/en-us/library/ff921098(v=pandp.40).aspx努力解决它。
一些背景:我最初有一个从我的 Mainpage.xaml
到 MainPage.xaml.cs
代码隐藏的直接函数调用,但是在转换为 MVVM 和一个单独的usercontrol,我删除了该函数调用,以便以后可以使用命令绑定(bind)。在我删除它之后,我在 GameRouletteView.g.i.cs 中的某个地方得到了一个错误,这是这个删除的函数调用的残余,g.i.cs 文件假设它仍然是绑定(bind)的。我重建了我的项目,那些 g.i.cs 文件显然被删除了。
我将以下行添加到我的用户控件 View 中,以便添加我的 ViewModel:
xmlns:gameRoulette="using:GameRoulette.DesignViewModels"
xmlns:prism="using:Prism.Windows.Mvvm"
d:DataContext="{d:DesignInstance gameRoulette:GameRouletteDesignViewModel, IsDesignTimeCreatable=True}"
prism:ViewModelLocator.AutoWireViewModel="True"
完整代码:
<UserControl
x:Class="GameRoulette.Views.GameRouletteView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:GameRoulette.Views"
xmlns:gameRoulette="using:GameRoulette.DesignViewModels"
xmlns:prism="using:Prism.Windows.Mvvm"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400"
d:DataContext="{d:DesignInstance gameRoulette:GameRouletteDesignViewModel, IsDesignTimeCreatable=True}"
prism:ViewModelLocator.AutoWireViewModel="True">
<Grid Background="White">
<Button x:Name="btnSelectGames" Content="Click here to select your games"
HorizontalAlignment="Left" Margin="110,50,0,0"
VerticalAlignment="Top" Height="40" Width="240"
Click="{Binding SelectCommand}"/>
<Button x:Name="btnChooseGame" Content=""
HorizontalAlignment="Left" Margin="110,150,0,0"
VerticalAlignment="Top" Width="240" Height="40"
Click="{Binding ChooseCommand}" IsEnabled="True"/>
<ProgressRing HorizontalAlignment="Left" Margin="200,100,0,0"
VerticalAlignment="Top" RenderTransformOrigin="1.05,1.983"
Height="45" Width="45" IsActive="True" Visibility="{Binding }"/>
<Image x:Name="imgFileIcon" HorizontalAlignment="Left"
Height="64" Margin="110,224,0,0"
VerticalAlignment="Top" Width="64" />
<TextBlock x:Name="lblFileName" HorizontalAlignment="Left"
Margin="179,224,0,0" TextWrapping="Wrap"
Text="" VerticalAlignment="Top" Width="171" Height="64"/>
</Grid>
</UserControl>
它给出了以下错误:
The name "GameRouletteDesignViewModel" does not exist in the namespace "using:GameRoulette.DesignViewModels".
我重建了项目,然后它为我的 3 个 .xaml 文件中的每一个都给出了以下错误:GameRouletteView、App.xaml
和MainPage.xaml
:
'GameRouletteView' does not contain a definition for 'InitializeComponent' and no extension method 'InitializeComponent' accepting a first argument of type 'GameRouletteView' could be found (are you missing a using directive or an assembly reference?)
另外,当第一次打开项目时,我得到 Intellisense 错误:
[Failure] Could not find file 'C:\Users\username\Source\Repos\GameRoulette\GameRoulette\GameRoulette\obj\ARM\Debug\MainPage.g.i.cs'.
[Failure] Could not find file 'C:\Users\username\Source\Repos\GameRoulette\GameRoulette\GameRoulette\obj\ARM\Debug\Views\GameRouletteView.g.i.cs'.
[Failure] Could not find file 'C:\Users\username\Source\Repos\GameRoulette\GameRoulette\GameRoulette\obj\ARM\Debug\App.g.i.cs'.
我已经排除的事情:
我用谷歌搜索了这个错误,但我真的找不到任何我还没有尝试过的东西。
我还注意到我的 NuGet 包丢失了,而且我的包管理器控制台不再识别 NuGet。我也收到此错误:
Microsoft.NETCore.Portable.Compatibility 1.0.0 provides a compile-time reference assembly for mscorlib on UAP,Version=v10.0, but there is no run-time assembly compatible with win10.
我感觉所有这些问题都是相关的,但我无法弄清楚它有什么问题。如上所述,Google 并没有真正提供太多帮助,而且它提供的帮助也不起作用。
我正在使用带有更新 1 的 Visual Studio 2015 社区版。可以在 https://github.com/nzall/GameRoulette 找到该项目。 .
最佳答案
我已经为这个问题苦苦挣扎了几天,而且,至少就我而言,我很确定它取决于我在我的 xaml 代码中无意中引入的一些细微错误。或者,更好的是,不完全是错误,而是我们目标平台的 xaml 版本不支持的东西。在这种情况下,xaml 解析器会失败,并且不会按预期生成 g.i.cs 文件(其中包含由解析器生成的部分页面和应用程序类,包括 InitializeComponent 方法)。我为什么这么认为?
关于c# - g.i.cs 文件丢失,类不再包含 InitializeComponent 的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35259603/
我最近更新了 ADT 插件,我的整个 Eclipse-Android 构建系统都停止工作了。从那以后,我尝试了我在互联网上可以找到的所有关于如何解决这个问题的方法。徒然。如果有人有确定的方法来解决此问
我已经知道有类似的话题,但对我来说没有任何帮助...... 这里是信息: 该应用程序始终在模拟器和设备上运行。我最近将该项目重命名为另一个名称。仍然工作得很好。今天我意识到它没有更改文件夹名称,然后它
在装有El Capitan的MacMini上,我无法再进行冲泡了。我收到以下错误: /usr/local/Library/Homebrew/config.rb:34:in `initialize':
是的,所以我不知道发生了什么。我一直在编写一个 AJAX 评论脚本,并且它可以工作,但它不再工作了。我从备份中恢复了它,以防万一我改变了任何东西,但没有运气。它转到表单的“操作”而不是 jQuery,
请原谅我的无能...我正在尝试在全局 var 阶段不再未定义后使用 Proxy 执行一些代码。这是我天真的尝试: ``` var stage = undefined let myObj; let st
我对 segues 了解不多,但我已经开始工作了..但突然间它不再工作了...... 我的代码似乎可以工作,但没有发生 segue: NSLog(@"login started"); if ([use
我已将以下重写规则添加到我的 web.config 中。它运行良好,阻止了所有提及的推荐垃圾邮件站点。然而,今天我突然注意到 social-buttons.com 突然出现在我的 Google Ana
在 C++ 中,可以在翻译单元中使用 static 关键字来影响符号(变量或函数声明)的可见性。 在 n3092 中,这已被弃用: Annex D.2 [depr.static] The use of
升级到 com.crashlytics.sdk.android:crashlytics:2.7.1@aar 后(从 2.6.8 开始),我无法再在 Firebase 应用中禁用 Crashlytics
您好,我遇到了一些障碍,我一直在为我的应用程序重新设计菜单导航。我设法做到了。但现在我的应用程序的一项功能已决定停止运行。 想法是你摇动你的手机,它会随机选择一张图片,与应用程序分开的代码工作正常,就
我有一行(容器)包含三个元素,我想水平显示它们之间的间距相等(并且行的左侧或右侧没有空格)。我正在使用带有 justify-content:space-between 的 flexbox。 这是在 F
直到最近,我才能够在 Windows 上使用 python 3.6.7 时安装 tensorflow 1.5.0 包。现在我不能,从下面的“来自版本”的消息来看,似乎根本没有可用的 tensorflo
不确定是否与最近的更新有关,但我突然无法在 Android Studio 编辑器中获得单行间距。如果我尝试将它更改为 1,它让我设置它,但当我按下“应用”时,它会迅速恢复为 1.5。用不同的字体试过,
我遵循了有关如何在 macOS 上安装 pip 的在线说明(例如 this、this 和 this)。 我看起来很简单,但它不适合我。 我的 python --version 是 2.7.10。 当我
Due to rounding errors, most floating-point numbers end up being slightly imprecise. https://www.flo
我试图让用户从他们在 Android 上的库中选择一张图片。但是当我使用 PictureChooser 插件时,它似乎不再起作用了 我看到这段代码可以工作,但现在不行了,我也不知道为什么。
自 .NET 4.5 起,Exception.HResult 的 setter/getter 现在是 public,但它曾经是 protected。 来自 MSDN: Starting with th
今天去处理一个较旧的 Python2.7 AppEngine 标准项目,但我似乎无法让端点工作。我下载了示例代码,看看我的项目是否是罪魁祸首,但该示例也不起作用。 https://cloud.goog
我是一名优秀的程序员,十分优秀!