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

Create TreeListView programatically

1 Answer 87 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
ss
Top achievements
Rank 1
ss asked on 09 Jul 2010, 10:10 AM

Hello,

I have TreeListView that contains 4 columns (Title, Name, Age, Street)

I have also class User 

public class User

{

public String Title;

public String Name;

public int Age;

public String Street;

}

Now I would like to create TreeListView programatically but I dont know how to bind User properties to columns. Can you please help me how to do this?

Thank you very much.

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 12 Jul 2010, 09:26 AM
Hello ss,

Here is an example of a TreeListView:

<UserControl x:Class="Telerik.Windows.Examples.TreeListView.FirstLook.Example"
        xmlns:local="clr-namespace:Telerik.Windows.Examples.TreeListView.FirstLook"
        xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls">
    <UserControl.Resources>
        <local:RadTreeListXmlDataSource x:Key="TreeListSource"
                Source="RadRibbonBarCodeCoverage.xml" />
        <local:RelativeBlocksValueConverter x:Key="RelativeBlocksValueConverter1" />
        <local:ItemImageSourceValueConverter x:Key="ItemImageSourceValueConverter1" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Border telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True" Grid.RowSpan="3" />
        <telerik:RadTreeListView x:Name="RadTreeListView1"
                                 AutoGenerateColumns="False"
                                 IsReadOnly="True"
                                 ItemsSource="{StaticResource TreeListSource}">
            <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 BlocksNotCovered}" Header="Not Covered (Blocks)" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Converter={StaticResource RelativeBlocksValueConverter1}, ConverterParameter=0}"
                                            Header="Not Covered (%)" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding BlocksCovered}" Header="Covered (Blocks)" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Converter={StaticResource RelativeBlocksValueConverter1}, ConverterParameter=1}"
                                            Header="Covered (%)" />
            </telerik:RadTreeListView.Columns>
        </telerik:RadTreeListView>
    </Grid>
</UserControl>

We will release our Q2 version very soon and you will be able to see the complete example.

Sincerely yours,
Ross
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
ss
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or