I’ve been playing with the developer preview release of Windows 8 that we got from //BUILD/. Everyday, we find more and more “issues” that are either just straight up bugs, things that are not implemented yet, or maybe even issues that won’t be resolved because WinRT is “just different”. This one was especially “fun” to track down – and when we did, we couldn’t believe the issue.
Start with a simple WinRT application in Visual Studio 11. Add a class library project that will hold a couple UserControls that we’ll use in the main application. Pretty standard stuff.
Create 2 UserControls in the library, the first one will use the other. UserControl1 can just have some container (Grid) then use UserControl2 (which just has an ellipse). In the main application, add a reference to the ClassLibrary and use UserControl1 in the MainPage. Your solution should look something like this:
<!-- MainPage.xaml --> ... xmlns:controls="using:ClassLibrary1.Controls" ... <Grid x:Name="LayoutRoot" Background="#FF0C0C0C"> <controls:UserControl1 /> </Grid>
<!-- UserControl1.xaml --> ... xmlns:controls="using:ClassLibrary1.Controls" ... <Grid x:Name="LayoutRoot" Background="#FF0C0C0C"> <controls:UserControl2 /> </Grid>
<!-- UserControl2.xaml --> <Ellipse Height="40" Width="40" Fill="Red" />
Now here’s the key step. Add a new class to the ClassLibrary, say Class1, and have that class IMPLEMENT INotifyPropertyChanged (be sure to choose the right using statement – the one from UI.Xaml.Data).
public class Class1 : INotifyPropertyChanged { #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion }
That’s it. Run it.
You will get a runtime exception:
Crazy, huh? The Microsoft guys have confirmed this to be a known bug. I just can’t believe what that bug would be? How is a simple UNREFERENCED class that implements INPC getting in the way of a couple UserControls?
Ahh … the joys of coding against pre-release software…
Hi, I have the same problem… Have you found a workaround?
I’m really asking me if MS is really dogfooding their apis… (I’m only working 10 hours with the C# WinRT APIs and already have this problem…)