MVVM Docking Adapter

I am using the Docking adapter sample to create a MVVM layout. I am running into issues when setting attached properties on the DataTemplates that are targeted for specific type. If I set the ns:DockingManager.CanFloat="False" in xaml on the DataTemplate this value is not set when the content control is created. This issue is easily reproduce-able, if you open the solution working-with-wpf-docking-manager-and-mvvm-master solution navigate to the DockingManagerMVVM project, App.xaml if you add the can float = false you will notice that you can still float the windows.


Below is a floating window...

What is the best approach to get the attached properties at the DataTemplate level to flow to the ContentControl in the adapter?

Thanks


2 Replies 1 reply marked as answer

AI Anirudhan Iyyappan Syncfusion Team July 8, 2020 03:55 PM UTC

Hi Justin Mason, 
 
Currently, we are analyzing your query “best approach to get the attached properties at the DataTemplate level to flow to the ContentControl in the adapter”. We will let you the further details by July 10th, 2020. 
 
Regards, 
Anirudhan 



AI Anirudhan Iyyappan Syncfusion Team July 10, 2020 03:00 PM UTC

Hi Justin Mason, 
 
Thanks for your patience. 
 
We have checked you query “best approach to get the attached properties at the DataTemplate level to flow to the ContentControl in the adapter”. We need the add this attach property in the DockingAdapte.cs. For further reference please to the code snippet and sample. 
 
Code snippet: 
 
 
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) 
{ 
    if (e.Property.Name == "ItemsSource") 
    { 
       if (e.OldValue != null) 
       { 
           var oldcollection = e.OldValue as INotifyCollectionChanged; 
           oldcollection.CollectionChanged -= CollectionChanged; 
       } 
       if (e.NewValue != null) 
       { 
           ((DocumentContainer)PART_DockingManager.DocContainer).AddTabDocumentAtLast = true; 
            var newcollection = e.NewValue as INotifyCollectionChanged; 
            int count = 0; 
            foreach (var item in ((IList)e.NewValue)) 
            { 
                if (item is IDockElement) 
                { 
                   ContentControl control = new ContentControl() { Content = item }; 
                   DockingManager.SetHeader(control, ((IDockElement)item).Header); 
                   if((item as IDockElement).Header == "All Documents") 
                   DockingManager.SetCanFloat(control, false); 
                   if (((IDockElement)item).State == DockState.Document) 
                   { 
                      DockingManager.SetState(control, Syncfusion.Windows.Tools.Controls.DockState.Document); 
                   } 
                   else 
                   { 
                      if (count != 0) 
                      { 
                           DockingManager.SetTargetNameInDockedMode(control, "item" + (count-1).ToString()); 
                           DockingManager.SetSideInDockedMode(control, DockSide.Bottom); 
                      } 
                           DockingManager.SetDesiredWidthInDockedMode(control, 220); 
                           control.Name = "item" + (count++).ToString(); 
                   } 
                   PART_DockingManager.Children.Add(control); 
               } 
           } 
           newcollection.CollectionChanged += CollectionChanged; 
      } 
   } 
   base.OnPropertyChanged(e); 
} 
 
 
 
Regards, 
Anirudhan 


Marked as answer
Loader.
Up arrow icon