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

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

3 Answers 44 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Adarsh
Top achievements
Rank 1
Adarsh asked on 17 Feb 2011, 02:06 PM

<

 

 

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


3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 17 Feb 2011, 05:38 PM
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
0
Adarsh
Top achievements
Rank 1
answered on 17 Feb 2011, 11:00 PM
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

0
codeputer
Top achievements
Rank 2
answered on 06 Mar 2011, 10:20 PM
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

Tags
TreeListView
Asked by
Adarsh
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Adarsh
Top achievements
Rank 1
codeputer
Top achievements
Rank 2
Share this question
or