Telerik blogs
  • Web

    Attaching a ContextMenu on a TreeView with RadControls for Silverlight

    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...
    April 27, 2009
  • Web

    Comparing Generic Types

        Today I was dealing with the problem of comparing generic types in Silverlight. After researching the problem I found many similar issues for which I couldn't find any straightforward solution on the web. So here we go - a post on the issue how to compare generic types. First, let’s say we have a simple generic class which is composed of two generic properties A and B, and a method that we will later use to compare these two properties. Moreover, I will constraint the class to invoke the constructor of the generic type argument by using where T : new()      public class GenericClass<T> where T : new()       {...
    January 10, 2009
  • Web

    Passing parameters to a UserControl inside RadWindow for Silverlight

    I just wrote a simple application that demonstrates how to databind a treeview to a dummy data source and edit its items in a UserControl, placed in a RadWindow. You could see my other blog posts for examples with web service binding and upgrade the application to suit your needs. To accomplish the requirements, we need to add a property that will contain the edited data item on the UserControl. When the selection in the TreeView changes, we will update that property with the new selection and then open the RadWindow. The UserControl will create a copy of the data item...
    January 07, 2009
  • Web

    Auto-complete ComboBox with WCF Service and RadControls for Silverlight

    Sometimes we need to load very large amount of items in a ComboBox and let the user select one of them. Usually in those cases the ComboBox allows typing in order to auto-select the items, that contain the text in the control. Such scenarios are possible with RadComboBox for Silverlight and now I will show you a simple application, that demonstrates what I think is a better practice for the implementation. We want to put all words from the English dictionary of RadSpell for ASP.NET in a RadComboBox for Silverlight and allow the user to select one of them, that will...
    December 04, 2008
  • Web

    RadControls for Silverlight 2 - Drag and Drop Basics

    Who would not like to implement a sleek drag and drop in minutes? I definitely would. This is why I find the new RadDragAndDrop a welcome addition to the controls. Straight to the point then: How to implement a simple drag/drop? To answer this question I will walk you through the DragDrop example that is available here: http://demos.telerik.com/silverlight/#Examples/DragAndDrop/FirstLook This example shows that the DragDrop can be used with any controls/objects, not just the Telerik RadControls. DragDrop 101 Few simple things to remember: Every object that will be dragged must have AllowDrag property to true, it is an attached property and in xaml it can be set the following way:   <Rectangle...
    October 15, 2008