This is a migrated thread and some comments may be shown as answers.

RadTreeListView events

1 Answer 72 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Fabiana
Top achievements
Rank 1
Fabiana asked on 01 Jun 2010, 02:43 PM
Hi Support team!

I have one question...

My example is: I created 3 columns in RadTreeListView ( Name, LastName and Add)

--> I would like to verify if user can mark/check "Add" column based on tag of current row.
--> And after, check if there are items in RadTreeListView checked to enable button.

Please, someone can help me?


See my example:

MainPage.xaml:




<UserControl x:Class="SilverlightApplication1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:SilverlightApplication1"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:nav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
             mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             Height="257" Width="660"
             xmlns:my="clr-namespace:SilverlightApplication1">

    <UserControl.Resources>
        
        <my:NameList x:Key="comboNamesSource"/>
        
        <telerik:CellTemplate x:Key="firstNameTemplate" >
            <TextBlock Tag="{Binding LastName}" Foreground="#284869" Text="{Binding FirstName}" VerticalAlignment="Center" telerik:StyleManager.Theme="Office_Black" />
        </telerik:CellTemplate>

        <telerik:CellTemplate x:Key="lastNameTemplate">
            <telerik:RadComboBox Tag="{Binding LastName}" Text="{Binding LastName, Mode=TwoWay}" DisplayMemberPath="LastName"  ItemsSource="{Binding Source={StaticResource comboNamesSource}}" IsEditable="True" IsFilteringEnabled="True" IsReadOnly="False" Foreground="#284869"/>
        </telerik:CellTemplate>

        <telerik:CellTemplate x:Key="AddTemplate" >
            <CheckBox  Content="" IsTabStop="False"  VerticalAlignment="Center"  HorizontalAlignment="Center" Margin="0,3,0,3" Click="CellCheckBoxAdd_Click" />
        </telerik:CellTemplate>
        
        <DataTemplate x:Key="itemTemplate">
            <Grid />
        </DataTemplate>
        
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0">

        <nav:RadTreeListView Background="White" x:Name="RadTreeListViewTest" BorderBrush="#a9a9a9" BorderThickness="1" HorizontalContentAlignment="Center" Width="556" Height="170"
                         IsDragDropEnabled="False" IsDragPreviewEnabled="False" IsDragTooltipEnabled="False"
                         IsEditable="True"
                         SelectionMode="Single"
                         ItemTemplate="{StaticResource itemTemplate}" IsSingleExpandPath="False" IsExpandOnSingleClickEnabled="True"
                         IsLineEnabled="True" IsExpandOnDblClickEnabled="True">

        <nav:RadTreeListView.Columns>

            <nav:RadColumn Header="First Name" PropertyName="FirstName" Width="200" IsEditable="True" CellTemplate="{StaticResource firstNameTemplate}"/>

            <nav:RadColumn Header="Last Name" PropertyName="LastName" Width="200" IsEditable="False" CellTemplate="{StaticResource lastNameTemplate}"/>

            <nav:RadColumn Header="Add" PropertyName="Add" Width="100" IsEditable="true" CellTemplate="{StaticResource AddTemplate}"/>

            
        </nav:RadTreeListView.Columns>


    </nav:RadTreeListView>
        
        <HyperlinkButton Content="Add" Height="23" HorizontalAlignment="Left" Margin="508,222,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="100" Foreground="Black" Click="hyperlinkButton1_Click" />
   
    </Grid>

</UserControl>
-----------------


MainPage.xaml.cs:





using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections;
using System.Collections.ObjectModel;


namespace SilverlightApplication1
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            IList itemsSource = new ObservableCollection<object>();
            itemsSource = new NameList();
            this.RadTreeListViewTest.ItemsSource = itemsSource;
        }


        private void CellCheckBoxAdd_Click(object sender, RoutedEventArgs e)
        {
            //Check tag of checked item.

            //If tag = "11", set checkbox.checked = true, else checkbox.checked = false

            SetButtonState();
        }

        private void SetButtonState()
        {
            //Check if there is at least one item in RadTreeListView checked to enable hyperlinkButton1
            //??


            //this.hyperlinkButton1.IsEnabled = false;
        }

        private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
        {
           //Do nothing...
        }


    }
}


-------------------
NameList.cs:


using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace SilverlightApplication1
{
    public class NameList : ObservableCollection<PersonName>
    {
        public NameList()
            : base()
        {
            Add(new PersonName("A", "11"));
            Add(new PersonName("B", "22"));
            Add(new PersonName("C", "33"));
            Add(new PersonName("D", "44"));
            Add(new PersonName("E", "55"));
        }
    }

    public class PersonName
    {
        public PersonName(string first, string last)
        {
            this.firstName = first;
            this.lastName = last;
        }

        private String firstName;
        public String FirstName
        {
            get
            {
                return this.firstName;
            }
        }

        private String lastName;
        public String LastName
        {
            get
            {
                return this.lastName;
            }
           
        }
    }

}




1 Answer, 1 is accepted

Sort by
0
Accepted
Miroslav
Telerik team
answered on 04 Jun 2010, 02:47 PM
Hello Fabiana,


I can suggest using databinding to do this. The IsChecked and IsEnabled properties of the CheckBoxes can be databound. Then, another property in your ViewModel may track whether there are any checked items.

You can have a look at the attached project.

Greetings,
Miroslav
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeListView
Asked by
Fabiana
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or