How to focus and expand a particular row in telerik RadTreeListView?

I wrote one simple program to test and show my list in telerik RadTreeListView, as shown below :

Definition a property :

List<Package> Packages { get; set; }

In Constructors :

public MainWindow()
    {
        InitializeComponent();
        Packages = CreatePachage();
        BindData();
    }

Definition of BinData() for craate resource :

private void BindData()
    {
        Packages = new List<Package>(Packages);
        TlvPackage.ItemsSource = Packages;
    }

Definition of CreatePachage() :

private List<Package> CreatePachage()
    {
        var p = new List<Package>
            {
                new Package
                {
                    PackageId = 1,
                    Name = "p1",
                    Version = "1.1.1.1",
                    Count = 15,
                    Items = new Collection<Package>
                    {
                        new Package {PackageId = 11,Name = "P.1.1", Version = "1.1", Count = 12},
                        new Package {PackageId = 12,Name = "P.1.1", Version = "1.1", Count = 12},
                        new Package {PackageId = 13,Name = "P.1.2", Version = "1.2", Count = 13}
                    }
                },
                new Package
                {
                    PackageId = 14,
                    Name = "p2",
                    Version = "2.2.2.2",
                    Count = 15,
                    Items = new Collection<Package>
                    {
                        new Package {PackageId = 18,Name = "P.2.2", Version = "2.2", Count = 13},
                        new Package {PackageId = 19,Name = "P.2.2", Version = "2.2", Count = 13}
                    }
                },
                new Package
                {
                    PackageId = 20,
                    Name = "p3",
                    Version = "3.3.3.3",
                    Count = 15,
                    Items = new Collection<Package>
                    {
                        new Package {PackageId = 48,Name = "P.3.2", Version = "3.2", Count = 13},
                        new Package {PackageId = 49,Name = "P.3.2", Version = "3.2", Count = 13}
                    }
                }
            };
        return p;
    }

Now, i want to update on row of resorce of bind to RadTreeListView, as shown below :

private void BtnEdit_OnClick(object sender, RoutedEventArgs e)
    {
        var currentItem = TlvPackage.SelectedItem as Package;
        var frm = new AddEdit { DataContext = currentItem };
        if (frm.ShowDialog() == true)
        {
            BindData();
        }
    }

But after the update list expanded all item and close nodes and not focus to current item of edited.How to do this work???

Source: New Questions

Leave a Reply