Create TreeListView programatically

2 posts, 0 answers
  1. ss
    ss avatar
    50 posts
    Member since:
    Jun 2010

    Posted 09 Jul 2010 Link to this post

    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.

  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 12 Jul 2010 Link to this post

    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
  3. DevCraft banner
Back to Top