I am following the example posted by Telerik on how to show/hide columns in their RadGridView control, as shown here:
<StackPanel x:Name="CustomizeGrid" Background="Transparent" Orientation="Horizontal">
<ListBox ItemsSource="{Binding Columns, ElementName=WorklistGridView}">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Header}" IsChecked="{Binding IsVisible, Mode=TwoWay}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<telerik:RadGridView x:Name="WorklistGridView" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" IsReadOnly="True" SelectionMode="Multiple"
CanUserSelect="False" IsSynchronizedWithCurrentItem="False" ItemsSource="{Binding Mode=OneWay}" IsFilteringAllowed="True">
<telerik:RadGridView.Columns>
<telerik:GridViewSelectColumn x:Name="Select" IsResizable="False" />
<telerik:GridViewDataColumn Header="Status" DataMemberBinding="{Binding OrderStatusDescription}"/>
<telerik:GridViewDataColumn Header="Patient Name" DataMemberBinding="{Binding PatientName}"/>
But the example is not compiling correctly. The problem is here: CheckBox Content="{Binding Header}"
The main error listed is: Value does not fall within the expected range.
I'm not sure why this is happening. I'll try to post the rest of the error below. Does anyone else have this working, or have any ideas what's up?
System.InvalidOperationException
An unhandled exception was encountered while trying to render the current silverlight project on the design surface. To diagnose this failure, please try to run the project in a regular browser using the silverlight developer runtime. at Microsoft.Windows.Design.Platform.SilverlightViewProducer.OnUnhandledException(Object sender, ViewUnhandledExceptionEventArgs e) at Microsoft.Expression.Platform.Silverlight.SilverlightPlatformSpecificView.OnUnhandledException(Object sender, ViewUnhandledExceptionEventArgs args) at Microsoft.Expression.Platform.Silverlight.Host.SilverlightImageHost.<>c_DisplayClass1.b_0(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
System.ArgumentException Value does not fall within the expected range. at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh) at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj) at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value) at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue) at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation) at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp) at System.Windows.Data.BindingExpression.SendDataToTarget() at System.Windows.Data.BindingExpression.SourceAcquired() at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e) at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e) at System.Windows.DataContextChangedEventHandler.Invoke(Object sender, DataContextChangedEventArgs e) at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e) at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive) at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent) at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)