c# - How to use view models for windows inside a DLL -


i'm new wpf. here xaml defining window defined inside dll:

<window x:class="mynamespace.myclass"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"         d1p1:ignorable="d"         xmlns:attachedproperties="clr-namespace:mynamespace.attachedproperties"         xmlns:viewmodels="clr-namespace:mynamespace.viewmodels"         datacontext="{binding source={staticresource vmlocator}}"         title="{binding myvm.mytitle, mode=onetime}" height="300" width="460">     <window.resources>         <viewmodels:viewmodellocatorteststeps x:key="vmlocator" d:isdatasource="true" />     </window.resources> 

when client code constructs window object, exception thrown:

cannot find resource named 'vmlocator' 

how define resource earlier exists when needed? i'd prefer solution enable intellisense work. first attempt @ window defined inside dll.

using visual studio 2013.

if want window create own datacontext, can stick in constructor in code-behind, , avoid necessity of making vmlocator resource. resources of wpf control (including window) available children of control.

just:

 public mynamespace()  {      initializecomponents();      this.datacontext = new vmlocator();  } 

if want make datacontext resource, create application-level resource , reference that.

also - 'mynamespace' confusing name class :)


Popular posts from this blog