1

Closed

Design Data Issue in MVVM Light V4b1 for Windows 8 Consumer Preview

description

I develop a win 8 app. This is I noticed that the design data be not displayed. I've attached a demo project to demonstrate the behavior. I could reproduce the behavior several times.

Issue 1:
  1. Open DesignDataIssue Project with VS 11
  2. If not, then open SettingPage.xaml design view -> PageTitle: "Setting Title" is visible
  3. Build Solution -> PageTitle is no longer visible and Error "Object does not match target type." is displayed (DataContext="{Binding Setting, Source={StaticResource Locator}}")
  4. Close and reopen SettingPage.xaml -> PageTitle: "Setting Title" is again visible
  5. Rebuild Solution -> PageTitle: "Setting Title" remains visible
Issue 2:
  1. Open SettingViewModel.cs and comment out the constructor "public SettingViewModel(INavigationService navigationService, ISettingService settingService)". Uncomment the constructor with resourceservice argument "public SettingViewModel(INavigationService navigationService, ISettingService settingService, IResourceService resourceService)"
  2. Build Solution -> PageTitle is not visible and Error "Das Gerät ist nicht bereit. (Exception from HRESULT: 0x80070015)" is displayed (DataContext="{Binding Setting, Source={StaticResource Locator}}")
  3. No Solution found!

file attachments

Closed Oct 21, 2012 at 9:39 PM by lbugnion
Never got a reply if that reproes in Win8 RP or RTM. Probably fixed.

comments

lbugnion wrote Jul 18, 2012 at 1:20 PM

Hi,

Do you have the issue in Windows 8 RP still? If yes, please update the sample and I will look at it. Right now I am getting quite a lot of errors when trying to port the sample to Win8 RP.

Thanks,
Laurent

roschler wrote Feb 15 at 5:03 PM

Was there ever a fix for this? I have multiple projects that are being affected by it. I'm running VS2013, Windows 8.1.

roschler wrote Feb 15 at 5:55 PM

This is not a fix but I'm putting it here in case it helps anyone. Moving the DataContext assignment out of a resources child XML element to an attribute of the Page element seems to have helped. In other words, I changed from this:

<Page.DataContext>
<Binding Mode="OneWay" Path="Main" Source="{StaticResource Locator}"/>
</Page.DataContext>

To this:

<Page
x:Name="pageRoot"
x:Class="RecNote.Pages.Help"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding Mode=OneWay, Path=Main, Source={StaticResource Locator}}" 
And I could see my design data, no longer got the consistency check Exception in the design editor, and no longer got the compiler warning "object type does not match target type". I have no idea why this helps.