3 Answers, 1 is accepted
0
Hi,
I am afraid that RadTreeListView can only listen for the standard .NET events such as INotifyCollectionChanged. Unfortunately, we can not tightly couple it with EntityCollection to listen specifically for this AssociationChanged event, which I even could not find on the EntityCollection class.
Maybe this StackOverflow discussions can give you some ideas.
Regards,
Rossen Hristov
the Telerik team
I am afraid that RadTreeListView can only listen for the standard .NET events such as INotifyCollectionChanged. Unfortunately, we can not tightly couple it with EntityCollection to listen specifically for this AssociationChanged event, which I even could not find on the EntityCollection class.
Maybe this StackOverflow discussions can give you some ideas.
Regards,
Rossen Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Benjamin
Top achievements
Rank 1
answered on 25 Feb 2013, 11:04 AM
Hi,
Thanks for your help.
The AssociationChanged event belong to the base class of EntityCollection : RelationEnd class.
I add a converter in order to create the ObservableCollections and make the wrap :
And i use it like that :
I have a graphic bug in the TreeListView (please see the attached image), there are white spaces in the control.
Does I made something wrong or does it's a bug from the TreeListView ?
Thank you for your help
Thanks for your help.
The AssociationChanged event belong to the base class of EntityCollection : RelationEnd class.
I add a converter in order to create the ObservableCollections and make the wrap :
public
class
RelatedEndToObservableCollectionConverter : IValueConverter
{
#region Fields
private
Dictionary<RelatedEnd, ObservableCollection<
object
>> _Dictionary;
#endregion
#region Constructors
public
RelatedEndToObservableCollectionConverter()
{
_Dictionary =
new
Dictionary<RelatedEnd, ObservableCollection<
object
>>();
}
#endregion
#region Methods
public
object
Convert(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
if
(!_Dictionary.Keys.Contains(value))
{
RelatedEnd relatedEnd = (RelatedEnd)value;
ObservableCollection<
object
> wraperCollection =
new
ObservableCollection<
object
>();
this
._Dictionary.Add(relatedEnd, wraperCollection);
relatedEnd.AssociationChanged += relatedEnd_AssociationChanged;
foreach
(var item
in
relatedEnd)
{
wraperCollection.Add(item);
}
}
return
_Dictionary[(RelatedEnd)value];
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
throw
new
NotImplementedException();
}
void
relatedEnd_AssociationChanged(
object
sender, System.ComponentModel.CollectionChangeEventArgs e)
{
switch
(e.Action)
{
case
System.ComponentModel.CollectionChangeAction.Add:
_Dictionary[(RelatedEnd)sender].Add(e.Element);
break
;
case
System.ComponentModel.CollectionChangeAction.Refresh:
_Dictionary[(RelatedEnd)sender].Clear();
foreach
(var item
in
(RelatedEnd)sender)
{
_Dictionary[(RelatedEnd)sender].Add(item);
}
break
;
case
System.ComponentModel.CollectionChangeAction.Remove:
_Dictionary[(RelatedEnd)sender].Remove(e.Element);
break
;
default
:
break
;
}
}
#endregion
}
And i use it like that :
<
telerik:RadTreeListView
ItemsSource
=
"{Binding Invoice.Chapters}"
SelectedItem
=
"{Binding SelectedItem}"
>
<
telerik:RadTreeListView.ChildTableDefinitions
>
<
telerik:TreeListViewTableDefinition
>
<
telerik:TreeListViewTableDefinition.ItemsSource
>
<
Binding
Path
=
"Chapters"
>
<
Binding.Converter
>
<
converters:RelatedEndToObservableCollectionConverter
/>
</
Binding.Converter
>
</
Binding
>
</
telerik:TreeListViewTableDefinition.ItemsSource
>
</
telerik:TreeListViewTableDefinition
>
</
telerik:RadTreeListView.ChildTableDefinitions
>
...
I have a graphic bug in the TreeListView (please see the attached image), there are white spaces in the control.
Does I made something wrong or does it's a bug from the TreeListView ?
Thank you for your help
0
Benjamin
Top achievements
Rank 1
answered on 25 Feb 2013, 11:11 AM
Hey,
My bad, I just found the solution, I had to populate the ObservableCollection before subscribe to the AssociationChanged event.
Thank tou !
My bad, I just found the solution, I had to populate the ObservableCollection before subscribe to the AssociationChanged event.
Thank tou !