Tree List view not Working with sample code please help - build filed

4 posts, 0 answers
  1. Adarsh
    Adarsh avatar
    2 posts
    Member since:
    Feb 2011

    Posted 17 Feb 2011 Link to this post

    <

     

     

    UserControl x:Class="TreeViewTest.Example"

     

     

     

    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" >

     

     

     

     

    <Grid >

     

     

     

     

    <Grid.ColumnDefinitions>

     

     

     

     

    <ColumnDefinition Width="Auto"/>

     

     

     

     

    <ColumnDefinition Width="*"/>

     

     

     

     

    </Grid.ColumnDefinitions>

     

     

     

     

    <Grid.RowDefinitions>

     

     

     

     

    <RowDefinition Height="Auto" />

     

     

     

     

    <RowDefinition Height="Auto" />

     

     

     

     

    <RowDefinition Height="Auto" />

     

     

     

     

    <RowDefinition Height="Auto" />

     

     

     

     

    </Grid.RowDefinitions>

     

     

     

     

    <telerik:RadTreeListView x:Name="radTreeListView"

     

     

     

    AutoGenerateColumns="False">

     

     

     

     

    <telerik:RadTreeListView.ChildTableDefinitions>

     

     

     

     

    <telerik:TreeListViewTableDefinition ItemsSource="{Binding Items}" />

     

     

     

     

    </telerik:RadTreeListView.ChildTableDefinitions>

     

     

     

     

    <telerik:RadTreeListView.Columns>

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"

     

     

     

    Header="Name" />

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Count}"

     

     

     

    Header="Count" />

     

     

     

     

    </telerik:RadTreeListView.Columns>

     

     

     

     

    </telerik:RadTreeListView>

     

     

     

     

    <Button Grid.Column="0" Grid.Row="2" Content="Button" Height="23" HorizontalAlignment="Left" Name="button1" Width="75" Click="button1_Click" />

     

     

     

     

    </Grid>

     

     

    </

     

     

    UserControl>

     


    using

     

     

    System;

     

    using

     

     

    System.Windows;

     

    using

     

     

    System.Windows.Data;

     

    using

     

     

    System.Globalization;

     

    using

     

     

    Telerik.Windows.Controls;

     

    using

     

     

    System.Collections.Generic;

     

    using

     

     

    System.Collections.ObjectModel;

     

    using

     

     

    Telerik.Windows.Controls.GridView;

     

    using

     

     

    Telerik.Windows.Data;

     

    namespace

     

     

    TreeViewTest

     

     

    {

     

     

     

    public partial class Example : System.Windows.Controls.UserControl

     

    {

     

     

    public Example()

     

     

    {

     

    InitializeComponent();

     

     

     

    RadTreeListView radTreeListView = new RadTreeListView();

     

     

     

    list =

     

    new ObservableCollection<TreeListSource>();

     

     

     

     

    TreeListSource treelist = new TreeListSource();

     

     

    treelist.name =

     

    "ab";

     

     

    list.Add(treelist);

     

     

     

    TreeListSource treelist1 = new TreeListSource();

     

     

    treelist.name =

     

    "bb";

     

     

    list.Add(treelist1);

     

     

     

    TreeListSource treelist2 = new TreeListSource();

     

     

    treelist.name =

     

    "abb";

     

     

    list.Add(treelist2);

     

     

     

    TreeListSource treelist3 = new TreeListSource();

     

     

    treelist.name =

     

    "affb";

     

     

    list.Add(treelist3);

     

     

     

    TreeListSource treelist4 = new TreeListSource();

     

     

    treelist.name =

     

    "aerb";

     

     

    list.Add(treelist4);

     

    list =

     

    new ObservableCollection<TreeListSource>(list);

     

     

    }

     

     

     

    public ObservableCollection<TreeListSource> list

     

     

    {

     

     

     

    get;

     

     

     

     

    set;

     

     

    }

     

     

     

     

    public class TreeListSource:IValueConverter

     

    {

     

     

    public string name

     

     

    {

     

     

     

    get;

     

     

     

     

    set;

     

     

    }

     

     

     

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

     

     

    {

     

     

     

    string passedvalue = (string)value;

     

     

     

     

    string paramVal = (string)parameter;

     

     

     

     

    return paramVal + passedvalue;

     

     

    }

     

     

     

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

     

     

    {

     

     

     

    string passedvalue = (string)value;

     

     

     

     

    string paramVal = (string)parameter;

     

     

     

     

    return paramVal + passedvalue;

     

     

    }

     

    }

     

     

     

    private void button1_Click(object sender, RoutedEventArgs e)

     

     

    {

     

    list =

     

    new ObservableCollection<TreeListSource>();

     

     

     

     

    TreeListSource treelist = new TreeListSource();

     

     

    treelist.name =

     

    "ab";

     

     

    list.Add(treelist);

     

     

     

    TreeListSource treelist1 = new TreeListSource();

     

     

    treelist.name =

     

    "bb";

     

     

    list.Add(treelist1);

     

     

     

    TreeListSource treelist2 = new TreeListSource();

     

     

    treelist.name =

     

    "abb";

     

     

    list.Add(treelist2);

     

     

     

    TreeListSource treelist3 = new TreeListSource();

     

     

    treelist.name =

     

    "affb";

     

     

    list.Add(treelist3);

     

     

     

    TreeListSource treelist4 = new TreeListSource();

     

     

    treelist.name =

     

    "aerb";

     

     

    list.Add(treelist4);

     

    list =

     

    new ObservableCollection<TreeListSource>(list);

     

     

     

     

    this.radTreeListView.ItemsSource = list;

     

     

     

     

    }

     

    }

     

    }



    Always getting error
    Error 1 The type or namespace name 'RadTreeListView' could not be found (are you missing a using directive or an assembly reference?) c:\users\v-apuro\documents\visual studio 2010\Projects\TreeViewTest\TreeViewTest\obj\Debug\Example.g.i.cs 38 18 TreeViewTest


  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 17 Feb 2011 Link to this post

    Hi Adarsh,

    I have prepared an example using the snippet provided and everything works fine on my side.
    Can you please check the attached project and let me know how it differs from yours ?


    Regards,
    Vanya Pavlova
    the Telerik team
  3. DevCraft banner
  4. Adarsh
    Adarsh avatar
    2 posts
    Member since:
    Feb 2011

    Posted 17 Feb 2011 Link to this post

    Thx for your help and i have one doubts if i want each and every row has the child list how do i specify in XAML
    like the demo u have for the teleric conrols if you can help me that will be great.

    Like the beloe contol

    http://demos.telerik.com/silverlight/#TreeListView/FirstLook

  5. codputer
    codputer avatar
    45 posts
    Member since:
    Apr 2007

    Posted 06 Mar 2011 Link to this post

    Example application not working - Silverlight2.zip

    Pulling my hair out here trying to get the treeviewlist to show the expander.  I think it has something to do with setting the datacontext and the itemsource - from XML or Imperative code.... not sure.

    Please provide a working sample...
    I'm on building on Version 2010.3.1314.1040

    runtime version: v2.0.50727

Back to Top