Reputation: 1421
Consider the following scenario:
WPF view:
d:DataContext="{d:DesignInstance vm:DesignViewModel, IsDesignTimeCreatable=True}"
ViewModel is located in a separate c# project:
internal class DesignViewModel : ViewModel
{ /* create demo data in ctor */ }
ViewModel has this entry in AssemblyInfo:
[assembly: InternalsVisibleTo("WPF.Demo.View")]
Error message in XAML Designer:
Observations:
Question: How can I set d:DataContext to an internal class of another assembly?
Upvotes: 1
Views: 373
Reputation: 186
You can't. By definition, when you mark an artifact as internal you are making it invisible from other assemblies.
Alternatively, you can expose a method on a public object, that makes what you want in the assembly's objects.
Regards,
Upvotes: -1