I read the following blog post regarding the new xaml editing features available in VS2013:
http://blogs.msdn.com/b/visualstudio/archive/2013/08/09/xaml-editor-improvements-in-visual-studio-2013.aspx
Data binding Intellisense is something I've been wanting for ages, so I gave it a try - but unfortunately it's returning an error in the error list (though it still builds fine).
This is what I've added to my UserControl declaration / tag:
d:DataContext="{d:DesignInstance Type=lTemplates:TemplateEditorCustomVM}"
This is the error in the list:
Error 95 Access is denied:
System.Collections.ObjectModel.ObservableCollection'1[_.di1.TemplateEditorCustomVM+TemplateCriteriaVM]'.
I'm not entirely sure what it's attempting to do, both classes are declared as public (main view model and a nested class).
Anyone got any ideas?
If not it's not the end of the world, as Resource Key Intellisense appears to work which is still a huge bonus.
Edit
OK - I moved the nested classes out into the public namespace, and VS has given me a more detailed error:
Error 64
Attempt by method '_.di1.Templates.TemplateEditorCustomVM..ctor()' to access method 'System.ComponentModel.BindingList'1<System.__Canon>..ctor()'
failed.
I'm a little confused I must say:
Firstly, why would intellisense need to instantiate the VM class, all it should care about is what properties are available and what type they are - all of which can be retrieved with reflection.
Secondly I don't understand why its erroring when it runs fine when the application is started.
I may have to do the old trick of having visual studio debug itself running the designer to see what it's attempting to do...
further edit
Right, I changed the BindingList properties to straight forward List properties (as the BindingList is from the WinForms side of things so I thought this might be worth changing to see what it does). But I got a similar error:
Error 64
Attempt by method '_.di3.Templates.TemplateEditorCustomVM..ctor()' to access method 'System.Collections.Generic.List'1<System.__Canon>..ctor()' failed.
I did a quick google on System.__Canon and its just a optimization detail :
https://stackoverflow.com/a/16856205/182568
Though still no closer to sussing out whats going on, ah well I'll keep digging further.
edit - now have a repo
Right, I began commenting out huge chunks of the VM to try to get to the bottom of this out of curiosity - and I now have a VM class which appears to reproduce the issue:
public class Nested
{
public class TestCheck
{
public int One { get; set; }
public int Two { get; set; }
}
}
public class SanityTestVM
{
public List<Nested.TestCheck> Test { get; set; }
}
Gives:
Error 14 Attempt by method
'_.di14.Templates.SanityTestVM..ctor()' to access method 'System.Collections.Generic.List'1<System.__Canon>..ctor()' failed.
It appears the issue is having a List which has a nested class for its type - if its a normal class (non nested), everything is fine.
I think I'm going to need to submit a connect case for this - before I do is anyone able to confirm this, I have 4 versions of VS on a Windows 8.1 machine and I just want to rule the development environment out.
Looks like this is indeed a bug in VS2013 - I've asked a few colleagues to see if they can reproduce it and they can, so its not just my environment.
I've submitted a connect case - so if anyone else hits this error feel free to vote it up:
https://connect.microsoft.com/VisualStudio/feedback/details/808323/
The issue is caused by having a view model that contains a property with a generic definition which contains a nested class type:
public class AClass
{
public class AnotherClass
{
public int AProperty { get; set; }
}
}
class TestVM
{
public List<AClass.AnotherClass> NestedTypeList { get; set; }
}
XAML:
<Window x:Class="WpfApplication1.MainWindow"
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"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:TestVM}"
Title="MainWindow" Height="354" Width="535">
<Grid>
</Grid>
</Window>
Gives:
Error 1 Attempt by method '_.di1.WpfApplication1.TestVM..ctor()' to access method 'System.Collections.Generic.List'1<System.__Canon>..ctor()' failed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With