How to sync Treeview Contextmenu and Toolbar

20 posts, 0 answers
  1. Stefania
    Stefania avatar
    107 posts
    Member since:
    May 2013

    Posted 28 Aug 2013 Link to this post

    Hi,
    Is it possibile to keep syncronize treeview context menu and toolbar?

    Example

    1- Toolbar on Root node click
    Icon1(Print Report) | Icon2(Delete) | Icon3(Modify)

    2- Toolbar on node2.1 click
    Icon1(Print Report) | Icon3(Modify)

    TreeView

    RootNode             -> ContextMenu:    Icon1 - Print Report
      |                                                         Icon2 - Delete
      |                                                         Icon3 - Modify 
      |_ node1
      |_ node2
            |_node2.1       -> ContextMenu
                                             Icon1 - Print Report
                                             Icon3 - Modify 


    Thanks
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 28 Aug 2013 Link to this post

    Hi Stefania,

    You can definitely synchronize the RadTreeView and RadToolBar controls content. I'd suggest an approach where you use a common ViewModel and populate the RadTreeView with business items. If every business item contains a list of options, you can display those in a RadContextMenu and in a RadToolBar.

    This means that you will have to populate the ItemsSource collections of the RadTreeView, RadContextMenu and RadToolBar with business data. And in order to make sure that the RadToolBar is displaying the options available for a selected node, you can bind its ItemsSource to a collection coming from the currently SelectedItem in the RadTreeView. For that purpose you can bind the RadTreeView SelectedItem to a business item from your view model and use that business item to populate the RadToolBar as well.

    Please find a sample solution attached - it demonstrates the suggested approach. I hope it can help you get started.

    Regards,
    Tina Stancheva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 29 Apr 2015 in reply to Tina Stancheva Link to this post

    I have using Telerik “RadTreeView” in WPF application, I have try to print the Treeview with inside of scroll TreeViewItems, but printed “PrintVisual” only, so how can I take the print of full RadTreeView?
  5. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 30 Apr 2015 Link to this post

    Hi,

    The treeview uses virtualization which means that not all items will be presented in the visual tree until they are not needed to. This said, try to disable the Virtualization (IsVirtualizing=false). This is however recommended when the treeview is a smaller one. Keep the virtualization on  when the treeview is bigger one as this will increase its performance.

    Regards,
    Peshito
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 04 May 2015 in reply to Peshito Link to this post

    Hi Peshito,

    Thanks for your replay, My requirement is how to take the print inside of RadTreeView scorll items. Here i have attached screen Short, please help me. 

    Thanks,

    Bennit.

  7. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 05 May 2015 Link to this post

    Hello,

    There is not an out of the box way to do so. There is a workaround though that you could use. In your export method set the height of the control to double.NaN. This way the TreeView will act for a moment as there is no predefined height for it and you will be able to export its whole content. At the end of your method simply return its old height value.

    Attached is a sample project illustrating the above approach.

    As this topic is regarding "How to sync Treeview Contextmenu and Toolbar", I would suggest to open another topic regarding the current issue as it would be easier to follow.

    Hope this helps.

    Regards,
    Peshito
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  8. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 05 May 2015 in reply to Peshito Link to this post

    Hi Peshit,

    Thanks, I can take print. Now we have using “telerik:RadGridView.RowDetailsTemplate” for look
    like a hierarchical Grid. I need to Print the RadGridView and Export to Excel but I can’t do
    that . Please find the attachment.

  9. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 07 May 2015 in reply to bennit Link to this post

    Hi Peshito,

    Thanks for your help, now i can take print. Now i have try to export  "RadTreeView" to excel but i have no Idea, Please check below code and help me.

     

    <Window x:Class="Test.PrintTreeview"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            Title="PrintTreeview" >
        <Grid >
           
                <Grid x:Name="PrintGrid">
                    
                <ScrollViewer Name="testScroll">
                    <telerik:RadTreeView Name="terrview" Margin="0,0,0,61" BorderThickness="1" BorderBrush="Gray">
                       
                        <telerik:RadTreeViewItem Header="test1" IsExpanded="True">Name1

                        </telerik:RadTreeViewItem >
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>

                    </telerik:RadTreeView>
                </ScrollViewer>
            </Grid>
        
            <Grid>
                <Button Content="Print" Width="150" Height="30" Margin="60,230,82,10" Name="print" Click="print_Click" ></Button>
            </Grid>
        </Grid>

    </Window>

     

     

    Thanks,

    Bennit.

  10. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 07 May 2015 Link to this post

    Hi Tina Stancheva,

    I have using  Hierarchical "RadTreeView", My requirement is export RadTreeView to excel but i have no Idea, Please check below code and help me. 

    <Window x:Class="Test.PrintTreeview"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            Title="PrintTreeview" >
        <Grid >
           
                <Grid x:Name="PrintGrid">
                    
                <ScrollViewer Name="testScroll">
                    <telerik:RadTreeView Name="terrview" Margin="0,0,0,61" BorderThickness="1" BorderBrush="Gray">
                       
                        <telerik:RadTreeViewItem Header="test1" IsExpanded="True">Name1

                        </telerik:RadTreeViewItem >
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>

                    </telerik:RadTreeView>
                </ScrollViewer>
            </Grid>
        
            <Grid>
                <Button Content="Print" Width="150" Height="30" Margin="60,230,82,10" Name="print" Click="print_Click" ></Button>
            </Grid>
        </Grid>

    </Window>

      Thanks,Bennit.

  11. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 07 May 2015 Link to this post

    Hi,

    The method below shows how to export the TreeView into Excel using Telerik's ExportExtentsons.
    private void print_Click(object sender, RoutedEventArgs e)
       {
           var actHeight = terrview.ActualHeight;
           terrview.Height = double.NaN;
     
           string extension = "xlsx";
           SaveFileDialog dialog = new SaveFileDialog()
           {
               DefaultExt = extension,
               Filter = "*.xlsx)|*.xlsx"
           };
     
           if (dialog.ShowDialog() == true)
           {
               using (Stream stream = dialog.OpenFile())
               {
                   Telerik.Windows.Media.Imaging.ExportExtensions.ExportToExcelMLImage(terrview, stream);
               }
           }
           terrview.Height = actHeight;
       }
    More information about Exporting support can be found following the link below:
    http://docs.telerik.com/devtools/silverlight/common-export-support

    Regards,
    Peshito
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  12. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 07 May 2015 in reply to Peshito Link to this post

     Hi Peshito, 

    Thanks for your help, now I can export to excel as an image.But in “Infragistics” export to excel with editable option. I can Expand and Collapse the RadTreeView after export to excel this functionality in “Infragistics”. I need that same functionality in "Telerik", its possible please help me. Find the attachment.

    Thanks,

    Bennit.

     

  13. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 07 May 2015 in reply to bennit Link to this post

    Hi Peshito, 

    Thanks for your help, now I can export to excel as an image.But in “Infragistics” export to excel with editable option. I can Expand and Collapse the TreeView after export to excel this functionality in “Infragistics” control. I need that same functionality in "Telerik", its possible please help me. Find the attachment.

    Thanks,

    Bennit.

  14. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 11 May 2015 Link to this post

    Hi,

    You are welcome, Bennit. I am glad the exporting worked well. However the feature you referred to is not supported by the TreeView control and it is not editable after the export is done as it is exported as a picture.

    Regards,
    Peshito
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  15. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 21 May 2015 in reply to Peshito Link to this post

    Hi Peshito,

    You are right, I have using "Group By" concept to export the data to excel. But now I have another one question, how to remove the "MouseOver" color in RadTreeView? here I have post my code, but its not working..

     <Style TargetType="RadTreeViewItem">
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                               <Setter Property="Background" Value="White"></Setter>
                            </Trigger>
                        </Style.Triggers>
                    </Style>

    Regards,

    Bennit.

     

     

     

     

  16. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 22 May 2015 Link to this post

    Hello,

    As I suggested earlier the topic of the forum thread is regarding "How to sync Treeview Contextmenu and Toolbar". As is switched on other topics several times I will ask you to start another forum thread for issues not related with this topic's matter.

    Regarding the technical question about disabling the MouseOver state, it can be done by retemplating the TreeViewItemStyle. Attached is a sample project demonstrating this approach. What I did there was to remove the MouseOverVisual from the ControlTemplate.

    Regards,
    Peshito
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  17. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 26 May 2015 in reply to Peshito Link to this post

    Hi Peshito,

    Thanks for your help, now working fine. I have try to create a new forum thread but i don't know how to create new thread, please guide me.

    I have one mode question,  how to remove the "MouseOver" color in RadGridView column Header? 

    Regards,

    Bennit.

  18. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 27 May 2015 Link to this post

    Hi Bennit,

    I am glad it is working well. As to your question about the MouseOver color and how to create new thread, this can be done by following the link below:
    http://www.telerik.com/forums/wpf

    Simply choose the appropriate product you would like to ask a question for and then click the "New thread" button in order to start the new thread. If your question is related with TreeView control, choose TreeView as a product and if it is about GridView, choose GridView as a product.

    See attached pictures for more information.

    Hope this helps.

    Regards,
    Peshito
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  19. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 27 May 2015 in reply to Peshito Link to this post

    Hi Peshito,

    Thanks for your help to created a "New thread", Now I have created New thread and post my question. please use this link to find the question.

    http://www.telerik.com/forums/remove-mouseover-color-in-gridview-column-header#_ZAHPXDMcEe_7k-L7HKFSQ

    Regards,

    Bennit.

  20. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 27 May 2015 Link to this post

    Hi Bennit,

    Thank you for opening another thread regarding your last question regarding how to remove the "MouseOver" color in RadGridView column Header. Your will receive an appropriate answer shortly.

    Regards,
    Peshito
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  21. bennit
    bennit avatar
    14 posts
    Member since:
    Aug 2014

    Posted 27 May 2015 in reply to Peshito Link to this post

    Hi Peshito,

    Ok Thanks..

    Bennit.

Back to Top
UI for WPF is Visual Studio 2017 Ready