We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

TreeView not visible while using DockingManager.ClientControl

I created a TreeView as follow (HierarchicalView.xaml):

    <UserControl.DataContext>
        <panels:HierarchicalViewModel />
    </UserControl.DataContext>

    <syncfusion:TreeViewAdv ItemsSource="{Binding Root}" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0">
        <syncfusion:TreeViewAdv.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Children, Mode=TwoWay}">
                    <Grid>
                        <TextBlock Text="{Binding Name}" Foreground="White" Background="Red" />
                    </Grid>
                </HierarchicalDataTemplate>
            </syncfusion:TreeViewAdv.ItemTemplate>
        </syncfusion:TreeViewAdv>

The ViewModel does contain a Root. And the root does contain the Children.
But it doesn't display anything, while using the DockingManager.

        <s:DockingManager PersistState="True" x:Name="SyncDockingManager" ContainerMode="TDI">
            <s:DockingManager.ClientControl>
                <report:HierarchicalView />
            </s:DockingManager.ClientControl>

But it does work if I dock it normally

            <report:HierarchicalView s:DockingManager.SideInDockedMode="Left" s:DockingManager.DesiredMinWidthInDockedMode="500" />

I didn't change anything, just moved it out of the <s:DockingManager.ClientControl> tag.
Am I missing something, or is this a bug?



7 Replies

VR Venkateshwaran Ramdoss Syncfusion Team March 23, 2017 08:37 PM UTC

Hi Thomas, 
 
Thank you for contacting Syncfusion Support. 
 
We have prepared a sample and tried to reproduce the reported issue at our end. But we were unable to reproduce the reported issue. We have prepared sample for your reference and it can be downloaded from the below link. 
 
 
Could you please check the sample and provide more details about your query by modifying the sample and providing replication steps to reproduce the issue? It will be helpful us to proceed further. 
 
Regards, 
Venkateshwaran V.R. 



TC Thomas Christof March 24, 2017 02:46 PM UTC

Thanks for your time and the prepared example.
I modified it so that you can reproduce the error.

In MainWindow.xaml

Comment IN to see nothing:

            <syncfusion:DockingManager.ClientControl>
                <local:CustomTreeControl />
            </syncfusion:DockingManager.ClientControl>

Comment the above lines out and this in:

            <!--<local:CustomTreeControl />-->

And you can see the result.

Attachment: TreeViewAdv_e42380eb.zip


VR Vijayalakshmi Roopkumar Syncfusion Team March 27, 2017 11:29 AM UTC

Hi Thomas,

Thank you for the update.

We have analyzed the sample and found that you have set the DataContext before CustomTreeControl has been intialized. Whenever on setting the Itemsource control of TreeViewAdv in the DockingManager client control, set the DataContext after the CustomTreeControl has been loaded. Please find the modified sample from the following location.  
Code Snippet: 
  
 //setting the DataContext in the CustomTreeControl loaded event   
private voidCustomTreeControl_Loaded(object sender, RoutedEventArgs e)   
{  
this.DataContext = newHierarchicalViewModel();  
}  
 

Sample: http://www.syncfusion.com/downloads/support/forum/129514/ze/TreeViewAdv_Modified-1076472576 

Now the TreeView will visible on setting it in DockingManager client control. 
  
Please let us know if you have any other concerns on this.

Regards,
Vijayalakshmi V.R.
 



TC Thomas Christof March 27, 2017 04:50 PM UTC

Thank you for tracing the error down. But shouldn't it be done automatically? Isn't it the job of your control to load the essential bindings? Just wondering, since I never had to do anything code behind. (xaml.cs)


VR Venkateshwaran Ramdoss Syncfusion Team March 28, 2017 03:11 PM UTC

Hi Thomas, 
 
Thank you for your update. 
 
DockingManager is a FrameWork control and not a ItemsControl. So, we should set the DataContext for this. We have prepared a sample for this behavior with ContentControl. In this sample, we have used a ContentControl. Please find the sample and video in the below link.  
 
 
 
Please let us know if you have any other concerns on this. 
 
Regards, 
Venkateshwaran V.R. 



TC Thomas Christof March 28, 2017 04:03 PM UTC

Thanks again for your effort. I already got it working with your first provided example. Please consider this ticket as already solved and don't provide any further examples or videos. My last answer wasn't a programming related problem, just a suggestion.

Because whenever I declear the DataContext within the xaml, I don't have to set anything code behind. So, I am aware that setting the DataContext in the xaml.cs after the control has been loaded, works. However, from my point of view I can't understand why this is still required, since the DataContext is already provided in the .xaml. So I can just assume, that your TreeViewAdv.ClientControl lack some features.


MS Marimuthu Sivalingam Syncfusion Team March 29, 2017 12:02 PM UTC

Hi Thomas,

Thanks for your update.

We have analyzed your query " I am aware that setting the DataContext in the xaml.cs". In our DockingManager we have bound the DockingManager DataContext property to ClientControl source internally. So, CustomTreeControl DataContext will overridden by DockingManager DataContext to CustomTreeControl even we set the DataContext in xaml. While setting DataContext in loaded event, CustomTreeControl DataContext is updated instead of DockingManager DataContext. So only we suggest you to set DataContext in code behind while using Control inside the DockingManager ClientControl.

Regards,
Marimuthu S.

Loader.
Up arrow icon