Hello,
I Implemented this example populated from a database. But when inserting an item in the TreeView from an item of the ListBox DragAndDrop The TreeView is not updated. The list that loads the Treeview is of the type ObservableCollection
Loaded:
ListBox to Treeview
Thanks.
I Implemented this example populated from a database. But when inserting an item in the TreeView from an item of the ListBox DragAndDrop The TreeView is not updated. The list that loads the Treeview is of the type ObservableCollection
Loaded:
protected void RadHierarquia_Loaded() |
{ |
ObservableCollection<IHierarquico> hierarquia = new ObservableCollection<IHierarquico>(); |
HierarquicoCollection lHierarquia = new HierarquicoCollection(); |
foreach (IHierarquico item in hierarquia) |
{ |
lHierarquia.Add(item); |
} |
RadHierarquia.DataContext = lHierarquia; |
} |
ListBox to Treeview
private void OnDropInfo(object sender, DragDropEventArgs e) |
{ |
if (statusDrag == 1) |
{ |
var destinationItem = e.Options.Destination as Telerik.Windows.Controls.RadTreeViewItem; |
var papeis = meusPapeisBox.SelectedItems.Cast<DtoPapel>().ToList();//e.Options.Payload as IList<DtoPapel>; |
if (papeis == null && e.Options.Payload is DtoPapel) |
{ |
papeis = new List<DtoPapel>() { e.Options.Payload as DtoPapel }; |
} |
if (e.Options.Status == DragStatus.DropComplete) |
{ |
if (destinationItem != null && papeis != null) |
{ |
foreach (var item in papeis) |
{ |
HierarquicoData hData = destinationItem.Item as HierarquicoData; |
DtoHierarquiaEstrutura obHierarquia = new DtoHierarquiaEstrutura(); |
obHierarquia.IdEstruturaPai = hData.Id; |
obHierarquia.IdAgrupamento = hData.IdPai; |
obHierarquia.Papel = item; |
lHierarquia.Add(obHierarquia); |
destinationItem.IsExpanded = true; |
statusDrag = 0; |
} |
//foreach (Telerik.Windows.Controls.RadTreeViewItem itens in RadHierarquia.Items) |
//{ |
// LoadTreeView(itens); |
//} |
e.Handled = true; |
} |
} |
} |
else |
{ |
return; |
} |
} |
Thanks.