1

I was coding happily ever after a personal project, when I noticed that I lost my blendability with mvvm light framework on my view models.

Trying to figure out why, I started digging into my constructors, adding and removing and cursing in arcane languages, until I figured the next bit out:

One of my viewmodels, if in design mode, was trying to call a static class that I use to generate random data (makes it easy to test some things).

Now, one specific method was calling a Sqlite database to get a range of values, and then choosing a random one from them.

This worked great for the app in runtime, but in design time, it will just break something, and cause the blendability to disappear.

As a workaround, I'm now fetching that random value from an array of hardcoded value that resides in my "if (InDesignMode)" clause, but I'm wondering if anyone knows why this happens, and if there's a work around this.

Cheers, and thanks in advance :)

Noctis
  • 11,507
  • 3
  • 43
  • 82
  • I assume it's the Visual Studio WPF designer you're seeing this in. Can you turn up your data binding information in the Output Window and see if there's any more detail? (Tools menu -> Options -> Debugging -> Output Window -> WPF Trace Settings -> Data Binding, set to something like Verbose or All) – Chris Mantle Sep 24 '13 at 14:10
  • If you are using the ViewModelLocator from mvvm-light you can inject a different Service into the View Model during design time and run time. This is happening because in Design Time WPF will not make calls to your database, so whatever you are supposed to get from your database will return null. Also, you generally don't want to use dynamic data in your Design Time anyways. – Daryl Behrens Sep 24 '13 at 18:54
  • @ChrisMantle -> Nice ... wasn't aware of this. Set it to verbose and then all ... getting a bunch of CA2214 (ctor chain ending in virtual call, mainly RaisePropertyChanged), but nothing else. – Noctis Sep 25 '13 at 02:13
  • @DarylBehrens -> Yep, I agree. It was using an array, but then I thought: "Hey, I can just put it in the DB, and let the user add and remove options ..." and this is how it ended trying to call the DB for design time. :) – Noctis Sep 25 '13 at 02:14

0 Answers0