• For the past couple of days I've been playing with the way RadTreeView renders its items. To be honest, I wasn't looking for any particular outcome. I was doing it just for fun, hoping that something interesting might come out. And it did. I ended up with something quite interesting and it would be a shame not to share it.
    Bellow are few screenshots which show the TreeView from its initial state to the point where its deepest item is expanded.







    Note: I do lack certain designer skills :)

    The TreeView is bound to an XML data source which has the following...

  •  

    Sometimes we need to extend the RadTreeView’s Drag’and’Drop abilities in order to accept external data from other applications or Windows.

    In this post I will show you how to successfully drag and drop images from  windows desktop / windows explorer to a RadTreeView located in a running WPF Application.

    Imagine we want to make a tree that shows pictures and names of our favourite football teams and our favourite players in these teams.

    How can we achieve this ?

    We can first create some ViewModels: PlayerViewModel, TeamViewModel, LeagueViewModel that all inherit from BaseViewModel. The BaseViewModel will implement the INotifyPropertyChanged interface and will expose Name(string) and ImgSource(Uri) properties.

    Then we will create...

  • We were eagerly awaiting the Q1 release to demonstrate you the new cleaner and more flexible API that makes the work with RadTreeView fun. We also wanted to tell you something more about the benefits that come with the new data engine.

    Now that Q1 2011 is public and the improved RadTreeView is a fact, I would like to introduce the enhancements which we implemented during the last few months.

    Screenshot1

     

    The new data engine that we use in RadTreeView is actually our generic data layer used in RadGridView and other controls such as RadListControl and RadDropDownList. This allowed us to add...

  • Similar to this post, I’ve made a similar example on how to load on demand RadTreeView for Silverlight three level hierarchy using MVVM and OData service: 

    XAML 

    <UserControl.Resources>
        <DataTemplate x:Key="OrderDetailsTemplate">
            <Grid>
               ...
            </Grid>
        </DataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="OrderTemplate"
                ItemsSource="{Binding OrderDetailsCollection}"
                ItemTemplate="{StaticResource...
  • In my previous article on the same topic I described how to replace the ItemsPresenter of RadComboBox with a RadTreeView. It was as simple as updating the control template. Unfortunately the controls’ selection synchronization relied on a bug in RadComboBox that we recently fixed – the control was able to have a value in its SelectedItem property, that was not present in its Items collection. Now, in order to workaround this new problem, we have to either inherit RadComboBox, or create an attached behavior that will allow us to get the SelectedItem of the inner RadTreeView. The code you have to write...

  • Often we need to display in a TreeView flat, self-referencing data, loaded from a database, that has properties ID and ParentID (or similar) that define the hierarchy. The Telerik TreeView for ASP.NET can automatically bind itself to such data, but our Silverlight TreeView cannot do this out of the box. Fortunately, this “limitation” can be easily avoided with a simple value converter. There is a little trick, however – each data item needs a reference to its parent collection.

    Consider the following very simple data object:

    public class DataItem : INotifyPropertyChanged
    {
        private string text; 
     
     public int ID { get; set; }
        public int ParentID {...
  • This is part two of my Attaching a ContextMenu on TreeView blog post. I will show another approach for adding context menu on a treeview, that uses a single menu that is customized for each treeview item. One context menu per treeview should provide much better performance if the treeview is bound to a large data set, since there are much less visual elements that have to be created. I am also using an updated view model, where each item contains a reference to its parent. This will help me to rely entirely on the model for my application logic, which greatly...

  • Telerik RadControls for Silverlight provide a very powerful ContextMenu control, that supports right click, modifier keys and that can be easily attached to any visual element. In this article I will show how to attach RadContextMenu to a data-bound RadTreeView and perform actions on the clicked treeview items, depending on the selection in the context menu. For simplicity, here I will use a treeview, bound to a static collection, but it can be easily extended to load its items from a web service:

    <UserControl x:Class="ContextMenuInTreeView.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ContextMenuInTreeView" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"> <UserControl.Resources> <local:DataViewModel x:Key="ViewModel" /> <telerik:HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Children}"> <TextBlock Text="{Binding Text}"> <telerikNavigation:RadContextMenu.ContextMenu> <telerikNavigation:RadContextMenu> <telerikNavigation:RadMenuItem Header="New Child" /> <telerikNavigation:RadMenuItem Header="New Sibling" /> <telerikNavigation:RadMenuItem Header="Delete" /> </telerikNavigation:RadContextMenu> </telerikNavigation:RadContextMenu.ContextMenu> </TextBlock> </telerik:HierarchicalDataTemplate> </UserControl.Resources> <StackPanel Background="White" DataContext="{StaticResource...
  • As far as I can tell from the experience of my colleagues with RadControls for ASP.NET AJAX, one of the common feature requests for RadComboBox and RadTreeView is combining them into one piece. Recently we started to receive similar requests for RadComboBox and RadTreeView for Silverlight. Placing a TreeView in a ComboBox sometimes makes a lot of sense, so I decided to research the best way to do it.
     
    The first, the simplest and most obvious way is to place a RadTreeView as content of RadComboBox:

    <input:RadComboBox>
     <nav:RadTreeView
     ItemTemplate="{StaticResource ItemTemplate}"
     ItemsSource="{StaticResource ItemsSource}" />
    </input:RadComboBox>

    This works, but it has one important limitation: RadComboBox cannot...

  • In this example I will show you how to populate a RadTreeView using LINQ and WCF. Also you will see how to transform a flat data into a hierarchical one.

    The target result is:

    1. Create a new Silverlight Web Application Project

    NOTE: Make sure you choose "Web Application Project"

    After the project loads you can see that besides the regular Silverlight application, Visual Studio adds a Web application that will host the .xap file.

     

    Before writing any LINQ or creating any WCF service, we need a database to target.

    2. Right-click on RadTreeViewWithWCFWeb project and add a new item - "SQL Server Database". You can give the...