c# - WPF : Binding List<xxUserControl> into dragablz:TabablzControl -


context

i have datagrid contains documents. when double-click on document, open window contain opened documents in derived tabcontrol (tabablzcontrol materialdesign xaml).

double click on document

private void row_doubleclick(object sender, mousebuttoneventargs e)     {         datagridrow row = sender datagridrow;         // operations row         document doctolookup = row.datacontext document;          bool isexist = application.current.windows.oftype<lookdmdocumentupwindow>().any();          if (isexist)         {             viewmodellocator.lookdmdocumentupvm.documentstolookup.add(new documentviewer(doctolookup));             viewmodellocator.lookdmdocumentupvm.documentstolookup = viewmodellocator.lookdmdocumentupvm.documentstolookup;         }         else         {             var windowtoshow = new lookdmdocumentupwindow();             viewmodellocator.cleanlookdmdocumentup();             viewmodellocator.lookdmdocumentupvm.documentstolookup.add(new documentviewer(doctolookup));             viewmodellocator.lookdmdocumentupvm.documentstolookup = viewmodellocator.lookdmdocumentupvm.documentstolookup;             windowtoshow.show();         }     } 

the system able know if window opened or not.

the viewmodel

public class lookdmdocumentupviewmodel : viewmodelbase {     private list<documentviewer> _documentstolookup;      public lookdmdocumentupviewmodel()     {         documentstolookup = new list<documentviewer>();     }      public list<documentviewer> documentstolookup     {         { return _documentstolookup; }         set         {             set(() => documentstolookup, ref _documentstolookup, value);         }     } } 

the view

<window x:class="wpfapplication.views.lookdmdocumentupwindow"     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:wpfapplication.views"     xmlns:materialdesign="clr-namespace:materialdesignthemes.wpf;assembly=materialdesignthemes.wpf"     xmlns:dragablz="clr-namespace:dragablz;assembly=dragablz"     xmlns:dockablz="clr-namespace:dragablz.dockablz;assembly=dragablz"     datacontext="{binding lookdmdocumentupvm, mode=twoway, source=locator}"     mc:ignorable="d"     title="lookdmdocumentupwindow" height="300" width="300"> <dockablz:layout>     <dragablz:tabablzcontrol borderthickness="0"                              showdefaultclosebutton="true"                              margin="0,-1,0,1" itemssource="{binding documentstolookup}">         <dragablz:tabablzcontrol.intertabcontroller>             <dragablz:intertabcontroller />         </dragablz:tabablzcontrol.intertabcontroller>          <dragablz:tabablzcontrol.itemtemplate>             <datatemplate>                 <textblock text="{binding document.doctitle}"/>             </datatemplate>         </dragablz:tabablzcontrol.itemtemplate>         <dragablz:tabablzcontrol.contenttemplate>             <datatemplate>                 <contentcontrol content="{binding documentviewerusercontrol}"></contentcontrol>             </datatemplate>         </dragablz:tabablzcontrol.contenttemplate>      </dragablz:tabablzcontrol> </dockablz:layout> 

the usercontrol instanciated many times (code behind)

public partial class documentviewer : usercontrol {     public document document;     public documentviewer documentviewerusercontrol;      public documentviewer(document document)     {         initializecomponent();          this.document = document;         documentviewerusercontrol = this;     } } 

the issue list in viewmodel updated when add new document has opened none of these shown window. more specifically, no tabcontrol created when list updated.

here user interface design when double-click event handled

picture


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -