I have a RadGridView with an ObservableCollection as it's ItemsSource.
The ObservableCollection holds a collection of objects similar in relation to sports players and teams.
where the Player object looks like:
ObservableCollection<Player> _players;// Psuedo-code Object DescriptionsPlayer{ UniqueIdentifier (Guid) string Name Guid TeamID (FK to Team's UniqueIdentifier) string Position int Number //etc.} Team{ UniqueIdentifier (Guid) string Name string Location //etc.}<telerik:RadGridView> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Team" DataMemberBinding="{Binding Team.Name}" /> <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" /> <telerik:GridViewDataColumn Header="Position" DataMemberBinding="{Binding Position}" /> <telerik:GridViewDataColumn Header="Number" DataMemberBinding="{Binding Number}" /> </telerik:RadGridView.Columns></telerik:RadGridView>The RadGrid I have is displaying columns for all of the properties similar to the XAML posted above.
I query for all the Players, Including the Navigation Property for Team, asynchronously. In the callback I call _players.Clear() and Add the results from the query to _players.
After the first query the column filters on the RadGridView work fine. When I perform the Load operation again, and then click on the Filter icon on the Column with Header == "Team" the screen goes blank and I get this message in my output window:
"Binding cannot be changed after it has been used."
I've also seen this error when the site is deployed:
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; BRI/2; MS-RTC LM 8)
Timestamp: Mon, 30 Jan 2012 20:08:56 UTC
Message: Unhandled Error in Silverlight Application [Binding_CannotBeChangedAfterUse]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60831.0&File=System.Windows.dll&Key=Binding_CannotBeChangedAfterUse
at System.Windows.Data.BindingBase.CheckSealed()
at Telerik.Windows.Data.DataFieldDescriptorExtensions.PrepareBinding(IDataFieldDescriptor fieldDescriptor, Binding memberBinding)
at Telerik.Windows.Data.DataFieldDescriptorExtensions.CreateConvertedAndFormattedValueFunc(IDataFieldDescriptor fieldDescriptor, Func`2 func)
at Telerik.Windows.Controls.GridView.FilteringViewModel.InitializeConvertedAndFormattedValueFunc()
at Telerik.Windows.Controls.GridView.FilteringViewModel.CreateDistinctValueViewModel(Object distinctValue)
at Telerik.Windows.Controls.GridView.DistinctValueViewModelCollection.AddRangeFromSource(IEnumerable source)
at Telerik.Windows.Controls.GridView.DistinctValueViewModelCollection.SetSource(IEnumerable source, Func`2 createDistinctValueCallback)
I managed to work around this problem by creating a property (and binding to it instead) on my Player BO similar to:
public string TeamName{ get { return this.Team == null ? string.Empty : this.Team.Name; }}