Hello,
I bound the RadTreeView to an ObservableCollection of TreeFolderHierarchyItem (my object)
Since this this an observablecollection, I just need to add a new TreeFolderHierarchyItem object to my observable collection
Adding new Item works fine and RadTreeView control refreshs correctly with the new item. But I want, enter in edit mode for this new item in order to change its header .
using MyRadViewTree.ItemContainerGenerator.ContainerFromIndex(0) returns always null even when all the node are expanded . So I am not able to iterate into the hierarchy ...
I thought to set IsEditMode=True but when I calls MyRadTreeVieew.Items I get my Observable collection of TreeFolderHierarchyItem as expected but useless for setting the EditMode ..
What am I doing wrong ?
Thanks for your help
I bound the RadTreeView to an ObservableCollection of TreeFolderHierarchyItem (my object)
public class TreeFolderHierarchyItem : INotifyPropertyChanged
{
#region properties
private string _header;
private bool _isexpanded;
private string _defaultimagesrc;
private string _expandedimagesrc;
private string _collapsedimagesrc;
private TreeFolderItem _tag;
private TreeFolderHierarchy _items;
public string Header
{
get { return _header; }
set
{
if (value != _header)
{
_header = value;
OnPropertyChange("Header");
}
}
}
public bool IsExpanded
{
get { return _isexpanded; }
set {
if (value != _isexpanded)
{
_isexpanded = value;
OnPropertyChange("IsExpanded");
}
}
}
public string DefaultImageSource
{
get { return _defaultimagesrc; }
set
{
if (value != _defaultimagesrc)
{
_defaultimagesrc = value;
OnPropertyChange("DefaultImageSource");
}
}
}
public string ExpandedImageSource
{
get { return _expandedimagesrc; }
set
{
if (value != _expandedimagesrc)
{
_expandedimagesrc = value;
OnPropertyChange("ExpandedImageSource");
}
}
}
public string CollapsedImageSource
{
get { return _collapsedimagesrc; }
set
{
if (value!= _collapsedimagesrc)
{
_collapsedimagesrc = value;
OnPropertyChange("CollapsedImageSource");
}
}
}
public TreeFolderItem Tag
{
get { return _tag; }
set
{
if (value != _tag)
{
_tag = value;
OnPropertyChange("Tag");
}
}
}
public TreeFolderHierarchy Items
{
get
{
return _items;
}
set
{
if (value != _items)
{
_items = value;
OnPropertyChange("Child");
}
}
}
public int ID
{
get { return Tag.ID; }
set {
if (value != Tag.ID)
{
Tag.ID = value;
OnPropertyChange("ID");
}
}
}
public TreeFolderHierarchyItem(TreeFolderItem tag, bool isexpanded )
{
_items = new TreeFolderHierarchy();
if (tag == null)
throw new ArgumentException();
_tag = tag;
SetProperties(isexpanded);
}
private void SetProperties(bool isexpanded)
{
_header = _tag.Titre;
_isexpanded = isexpanded;
switch (_tag.Type)
{
case TreeFolderType.Acte:
_defaultimagesrc = "folder.png";
_expandedimagesrc = "openedfolder.png";
_collapsedimagesrc = "folder.png";
break;
case TreeFolderType.Message:
_defaultimagesrc = "sent.png";
_expandedimagesrc = "sent.png";
_collapsedimagesrc = "sent.png";
break;
case TreeFolderType.Pdf:
_defaultimagesrc = "3Drafts.png";
_expandedimagesrc = "3Drafts.png";
_collapsedimagesrc = "3Drafts.png";
break;
case TreeFolderType.Libre:
_defaultimagesrc = "1PersonalFolder.png";
_expandedimagesrc = "1PersonalFolder.png";
_collapsedimagesrc = "1PersonalFolder.png";
break;
}
}
#endregion
public event PropertyChangedEventHandler PropertyChanged;
// Helper Methods
private void OnPropertyChange(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Since this this an observablecollection, I just need to add a new TreeFolderHierarchyItem object to my observable collection
Adding new Item works fine and RadTreeView control refreshs correctly with the new item. But I want, enter in edit mode for this new item in order to change its header .
using MyRadViewTree.ItemContainerGenerator.ContainerFromIndex(0) returns always null even when all the node are expanded . So I am not able to iterate into the hierarchy ...
I thought to set IsEditMode=True but when I calls MyRadTreeVieew.Items I get my Observable collection of TreeFolderHierarchyItem as expected but useless for setting the EditMode ..
What am I doing wrong ?
Thanks for your help