.net - Using DataTemplates for View Model. -


While trying to upgrade avalon dock from 1.3 to 2.0, I am facing this problem first of all. However, I have a collection of ViewModel, which uses a data template and it converts each view modal into a separate tab.

So I have something like that.

  & lt; Advertising: Docking Manager x: name = "_ docking manager" document source = "{binding scenario}" & gt; & Lt; Advertising: DockingManager.LayoutItemTemplateSelector & gt; & Lt; Local: PanesTemplateSelector & gt; & Lt; Local: PanesTemplateSelector.ScannarioMainTemplate & gt; & Lt; DataTemplate & gt; & Lt; TabControl & gt; & Lt; TabItem header = "see 1" & gt; & Lt; WinForm: WindowsFormsHost name = "_ host1" /> & Lt; Text block text = "{binding sample text}" /> & Lt; / TabItem & gt; & Lt; TabItem Header = "View 2" & gt; & Lt; WinForm: WindowsFormsHost name = "_ host2" /> & Lt; / TabItem & gt; & Lt; / TabControl & gt; & Lt; / DataTemplate & gt; & Lt; / Local: PanesTemplateSelector.ScannarioMainTemplate & gt; & Lt; / Local: PanesTemplateSelector & gt; & Lt; / Advertising: DockingManager.LayoutItemTemplateSelector & gt; & Lt; Advertising: LayoutRoot & gt; & Lt; Advertising: LayoutPanel Orientation = "Vertical" & gt; & Lt; Advertising: LayoutDocumentPane / & gt; & Lt; / Advertisement: LayoutPanel & gt; & Lt; / Advertising: LayoutRoot & gt; & Lt; / Advertising: DockingManager & gt;   

So what will be the above for every scenario related to the source of the document, this & lt; Ad: LayoutDocumentPane / & gt; .

Binding works, except now I have to set the child of the VisualMost in the ViewModel side. And I do not know how to do this in the visual model. Binding for sample text works however.

I need to get _host1 control in the visual model and set it.

To me, it does not seem right / proper MVVM, it seems like I'm playing with footage in the visual model.

Is there any alternative to doing this or is this effort OK (if so, how do I do it?)

Thank you, KV 84

DataType DataType = "{x: Type Local:

MyViewmodelForHost1}" & gt; & Lt; WinForm: WindowsFormsHost name = "_ host1" /> & Lt; / DataTemplate / & gt;

I know what your landscape object looks like, but if I think it is the property of Host1, Host2

   & Lt; / TabItem & gt; & Lt; TabItem Header = "View 2" & gt; & Lt; Content display content = "{binding host 2}" /> & Lt; / TabItem & gt; & Lt; / TabControl & gt; & Lt; / DataTemplate & gt; & Lt; / Local: PanesTemplateSelector.ScannarioMainTemplate & gt;   

Host 1 and 2 are identical if this did not work. You might be able to add some view-model codes to your question.

Comments