tags:

views:

19

answers:

0

i have a TreeView that is bound to a collection, I want to expand a treeViewItem automatically from a object i used ItemContainerGenerator.ContainerFromItem, it returns always null the ItemContainerGenerator.Status is NotStrated i call StartAt method i have an exception "unable to call "StartAt" when the generation of content is being"

IItemContainerGenerator generator = treeViewByWS.ItemContainerGenerator; GeneratorPosition position = generator.GeneratorPositionFromIndex(0); try { ((IItemContainerGenerator)(tvDCTM.ItemContainerGenerator)).StartAt(position, GeneratorDirection.Forward, true); } catch (Exception ex) { LOG.Error("error in start At" + ex); } if (lastElement != null) { LOG.Info("test expandBrowser() .........................."); LOG.Info("last cabinet ....." + lastElement.Name);

            foreach (Object item in tvDCTM.Items)
            {
                LOG.Info("tvDCTM.ItemContainerGenerator.Status= " + tvDCTM.ItemContainerGenerator.Status);

                    TreeViewItem t = new TreeViewItem();
                    t = tvDCTM.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
                    if (t == null)
                    {
                        LOG.Info(" t is null ....");
                    }
                    else { LOG.Info("t is not null ....."); }

Thank you