Not sure if this is a bug (probably not).
But i am posting it for posterity since it caused me grief.
If a collection property (observable collection) is nothing when first presented to the itemssource
any subsequent assignments are not observed.
(My data class was generated by a webservice proxy and since it was just a shallow representation of the class the default new assignemnt for the collection was not reproduced in the client version.)
This can be worked around by making sure all the collections are initailized before assigning to the itemssource or
by reassinging the itemssource after the addition
My example below
click 1st button and a new item is added to a new initialized child collection but it is not displayed in the listview
click 2nd button and i reassign the who itemssource and it shows up.
But i am posting it for posterity since it caused me grief.
If a collection property (observable collection) is nothing when first presented to the itemssource
any subsequent assignments are not observed.
(My data class was generated by a webservice proxy and since it was just a shallow representation of the class the default new assignemnt for the collection was not reproduced in the client version.)
This can be worked around by making sure all the collections are initailized before assigning to the itemssource or
by reassinging the itemssource after the addition
My example below
click 1st button and a new item is added to a new initialized child collection but it is not displayed in the listview
click 2nd button and i reassign the who itemssource and it shows up.
<
UserControl
x:Class
=
"RadControlsSilverlightApp8.MainPage"
xmlns:d
=
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerikGridView
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
mc:Ignorable
=
"d"
d:DesignWidth
=
"640"
d:DesignHeight
=
"480"
>
<
Grid
x:Name
=
"LayoutRoot"
>
<
StackPanel
Orientation
=
"Vertical"
>
<
Button
Content
=
"Add New Level "
Height
=
"23"
HorizontalAlignment
=
"Left"
Name
=
"Button1"
VerticalAlignment
=
"Top"
/>
<
Button
Content
=
"Reassign"
Height
=
"23"
HorizontalAlignment
=
"Left"
Name
=
"Button2"
VerticalAlignment
=
"Top"
/>
<
telerikGridView:RadTreeListView
IsReadOnly
=
"True"
x:Name
=
"tvKits"
Grid.Row
=
"1"
Grid.Column
=
"1"
AutoGenerateColumns
=
"False"
>
<
telerikGridView:RadTreeListView.ChildTableDefinitions
>
<
telerikGridView:TreeListViewTableDefinition
ItemsSource
=
"{Binding Items}"
/>
</
telerikGridView:RadTreeListView.ChildTableDefinitions
>
<
telerikGridView:RadTreeListView.Columns
>
<
telerikGridView:GridViewDataColumn
Header
=
"Assembly"
DataMemberBinding
=
"{Binding Name}"
/>
</
telerikGridView:RadTreeListView.Columns
>
</
telerikGridView:RadTreeListView
>
</
StackPanel
>
</
Grid
>
</
UserControl
>
Imports
System.Collections.ObjectModel
Partial
Public
Class
MainPage
Inherits
UserControl
Dim
zz
As
New
ObservableCollection(Of Test)
Public
Sub
New
()
InitializeComponent()
End
Sub
Private
Sub
Button1_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.RoutedEventArgs)
Handles
Button1.Click
zz(0).Items(0).Items(0).Items =
New
ObservableCollection(Of Test)
zz(0).Items(0).Items(0).Items.Add(
New
Test)
End
Sub
Private
Sub
Button2_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.RoutedEventArgs)
Handles
Button2.Click
tvKits.ItemsSource =
Nothing
tvKits.ItemsSource = zz
End
Sub
Private
Sub
tvKits_Loaded(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.RoutedEventArgs)
Handles
tvKits.Loaded
zz.Add(
New
Test)
zz(0).Items =
New
ObservableCollection(Of Test)
zz(0).Items.Add(
New
Test)
zz(0).Items(0).Items =
New
ObservableCollection(Of Test)
zz(0).Items(0).Items.Add(
New
Test)
tvKits.ItemsSource = zz
' tvKits.ExpandAllHierarchyItems()
End
Sub
End
Class
Public
Class
Test
Private
_Items
As
ObservableCollection(Of Test)
Public
Property
Items()
As
ObservableCollection(Of Test)
Get
Return
_Items
End
Get
Set
(
ByVal
value
As
ObservableCollection(Of Test))
_Items = value
End
Set
End
Property
Private
_Name
As
String
=
"AA"
Public
Property
Name()
As
String
Get
Return
_Name
End
Get
Set
(
ByVal
value
As
String
)
_Name = value
End
Set
End
Property
End
Class