I've been developing a UWP project in my spare time to get a hang of UWP, MVVM and Prism. The project was originally really classic, with no use of MVVM and Prism, and I've been working to get those 2 into the project. I've been relying on https://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40).aspx, https://msdn.microsoft.com/en-us/library/gg405494(v=pandp.40).aspx and https://msdn.microsoft.com/en-us/library/ff921098(v=pandp.40).aspx to work my way through it.
Some background: I originally had a direct function call from my Mainpage.xaml
to the MainPage.xaml.cs
codebehind, but during the conversion to MVVM and a separate usercontrol, I removed that function call so I could later using Command Binding. After I removed that, I got an error that was somewhere in GameRouletteView.g.i.cs that was a remnant of this removed function call, where the g.i.cs file assumed it was still bound. I rebuilt my project and those g.i.cs files apparently got removed.
I added the following lines to my Usercontrol View so my ViewModel gets added:
xmlns:gameRoulette="using:GameRoulette.DesignViewModels"
xmlns:prism="using:Prism.Windows.Mvvm"
d:DataContext="{d:DesignInstance gameRoulette:GameRouletteDesignViewModel, IsDesignTimeCreatable=True}"
prism:ViewModelLocator.AutoWireViewModel="True"
Full Code:
<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>
It gave the following error:
The name "GameRouletteDesignViewModel" does not exist in the namespace "using:GameRoulette.DesignViewModels".
I rebuilt the project, and then it gave the following error for each of my 3 .xaml files: GameRouletteView, App.xaml
andMainPage.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?)
Also, when first opening the project, I get the Intellisense errors:
[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'.
Things I've ruled out:
- My namespaces are correct;
- I've tried https://stackoverflow.com/a/27260580/1770430, didn't work;
- i've deleted the bin, obj folders and the .suo file, didn't fix it;
- I've closed and reopened the solution, did not fix it.
- Repair Visual Studio through the add/repair/remove programs window, no result.
I've googled this error, but I can't really find anything that I haven't tried yet.
I've also noticed that my NuGet Packages have gone missing and that my Package Manager Console does not recognize NuGet anymore. I also get this error:
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.
I got a feeling that all these issues are related, but I can't figure out what's wrong with it. As mentioned above, Google doesn't really provide much assistance, and what it does provide doesn't work.
I'm using Visual Studio 2015 Community Edition with Update 1. The project can be found at https://github.com/nzall/GameRoulette.