WPF, VS 2010
I have a treeview bound to a collection of objects that implement INotifyPropertyChanged. The AssociatedOfferings child collection is a collection of the same type of object. When I change a value of one of the objects from the ViewModel the change is not reflected in the TreeView. My View is as follows:
Then in the ViewModel if I take one of the objects and set its IsSelected property to True, or the Name to something else, the change is not reflected in the View.
I have a treeview bound to a collection of objects that implement INotifyPropertyChanged. The AssociatedOfferings child collection is a collection of the same type of object. When I change a value of one of the objects from the ViewModel the change is not reflected in the TreeView. My View is as follows:
<
HierarchicalDataTemplate
x:Key
=
"TopItemTemplate"
ItemsSource
=
"{Binding AssociatedOfferings}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
CheckBox
IsChecked
=
"{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled
=
"{Binding IsEnabled}"
/>
<
TextBlock
Text
=
"{Binding Name}"
Margin
=
"10,0,0,0"
/>
</
StackPanel
>
</
HierarchicalDataTemplate
>
<
telerik:RadTreeView
ItemsSource
=
"{Binding Items}"
DataContext
=
"{Binding}"
ItemTemplate
=
"{DynamicResource TopItemTemplate}"
/>
Then in the ViewModel if I take one of the objects and set its IsSelected property to True, or the Name to something else, the change is not reflected in the View.
4 Answers, 1 is accepted
0
Hi Heather,
Changes in your business items collection ( AssociatedOfferings) like changing property of an ite , reordering of items or drag`N`drop of items, affect the RadTreeView only if the collection implements the INotifyCollectionChanged interface. For instance, you can use an ObservableCollection.
Please ensure your application meets this requirement and if it does and the problem still occurs please send me a sample reproducing your issues. I would be glad to assist you.
Sincerely yours,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Heather
Top achievements
Rank 1
answered on 22 Oct 2010, 04:14 PM
Here is the definition of my class objects and as you can see the Class inherits from EntityBase (which implements INotifyPropertyChanged) and the collection of associatedobjects is an ObsesrvableCollection.
I will try and put together a sample and submit as a ticket.
EDIT: I put together a sample and it works in my sample. The code is exactly what is in my real app. Can't figure out why it works in my sample but not in my app, will have to research further.
Public
Class
ServiceOfferingSelect
Inherits
EntityBase
Public
Sub
New
()
'noop
End
Sub
Public
Sub
New
(
ByVal
source
As
Entities.ServiceOffering)
_id = source.ServiceOfferingId
_name = source.ServiceName
If
source.DiscountRates.Count > 0
Then
Me
.Discounts = (From d
In
source.DiscountRates
Select
New
ListItem
With
{.Id = d.DiscountRateID, .Name = d.DiscountName}).ToList
End
If
End
Sub
Private
_id
As
Integer
Public
Property
Id()
As
Integer
Get
Return
_id
End
Get
Set
(
ByVal
value
As
Integer
)
_id = value
End
Set
End
Property
Private
_name
As
String
Public
Property
Name()
As
String
Get
Return
_name
End
Get
Set
(
ByVal
value
As
String
)
_name = value
End
Set
End
Property
Public
Property
Discounts
As
List(Of ListItem)
Public
ReadOnly
Property
HasDiscounts
As
Boolean
Get
If
Discounts
Is
Nothing
Then
Return
False
Else
Return
Discounts.Count > 0
End
If
End
Get
End
Property
Public
ReadOnly
Property
IsEnabled()
As
Boolean
Get
Return
Not
_enrollmentid.HasValue
End
Get
End
Property
Private
_enrollmentid
As
Nullable(Of
Integer
)
Public
Property
EnrollmentId()
As
Nullable(Of
Integer
)
Get
Return
_enrollmentid
End
Get
Set
(
ByVal
value
As
Nullable(Of
Integer
))
_enrollmentid = value
End
Set
End
Property
Private
_selecteddiscountid
As
Nullable(Of
Integer
)
Public
Property
SelectedDiscountId()
As
Nullable(Of
Integer
)
Get
Return
_selecteddiscountid
End
Get
Set
(
ByVal
value
As
Nullable(Of
Integer
))
_selecteddiscountid = value
End
Set
End
Property
Private
_parentserviceid
As
Nullable(Of
Integer
)
Public
Property
ParentServiceId()
As
Nullable(Of
Integer
)
Get
Return
_parentserviceid
End
Get
Set
(
ByVal
value
As
Nullable(Of
Integer
))
_parentserviceid = value
End
Set
End
Property
Private
_associationrule
As
ServiceOfferingAssociationRule = ServiceOfferingAssociationRule.NotApplicable
Public
Property
AssociationRule()
As
ServiceOfferingAssociationRule
Get
Return
_associationrule
End
Get
Set
(
ByVal
value
As
ServiceOfferingAssociationRule)
_associationrule = value
End
Set
End
Property
Private
_associatedofferings
As
ObservableCollection(Of PresentationModel.ServiceOfferingSelect)
Public
Property
AssociatedOfferings()
As
ObservableCollection(Of PresentationModel.ServiceOfferingSelect)
Get
If
_associatedofferings
Is
Nothing
Then
_associatedofferings =
New
ObservableCollection(Of PresentationModel.ServiceOfferingSelect)
End
If
Return
_associatedofferings
End
Get
Set
(
ByVal
value
As
ObservableCollection(Of PresentationModel.ServiceOfferingSelect))
_associatedofferings = value
End
Set
End
Property
Private
_isselected
As
Boolean
Public
Property
IsSelected()
As
Boolean
Get
Return
_isselected
End
Get
Set
(
ByVal
value
As
Boolean
)
If
Not
_isselected.Equals(value)
Then
_isselected = value
OnPropertyChanged(
"IsSelected"
)
For
Each
itm
In
AssociatedOfferings
If
itm.AssociationRule = ServiceOfferingAssociationRule.Required
Then
itm.IsSelected =
True
End
If
Next
End
If
End
Set
End
Property
End
Class
I will try and put together a sample and submit as a ticket.
EDIT: I put together a sample and it works in my sample. The code is exactly what is in my real app. Can't figure out why it works in my sample but not in my app, will have to research further.
0
Hi Heather,
I prepared a sample project for you that demonstrates binding a boolean property of a business object to checkbox in your visual presentation. ( Note that RadTreeView has checkbox support -->http://www.telerik.com/help/wpf/check-box-support.html ) Please examine it and see if you are missing something in your project because we are unable to reproduce your issue using the code you provided .
If the sample doesn`t help you, could you please send us your project ?
Sincerely yours,
Petar Mladenov
the Telerik team
I prepared a sample project for you that demonstrates binding a boolean property of a business object to checkbox in your visual presentation. ( Note that RadTreeView has checkbox support -->http://www.telerik.com/help/wpf/check-box-support.html ) Please examine it and see if you are missing something in your project because we are unable to reproduce your issue using the code you provided .
If the sample doesn`t help you, could you please send us your project ?
Sincerely yours,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Heather
Top achievements
Rank 1
answered on 27 Oct 2010, 06:07 PM
I apologize, I haven't had time to update this ticket. I found the issue...it was an issue in my base class that was causing the NotifyPropertyChanged to not get fired in my app. Once I fixed that issue the problem went away.