If in the content of RadGridView.ControlPanelItem has a binding with a RelativeSource or ElementName and the grid is placed in the collapsed UserControl, a binding error is thrown in the output window.
We noticed that RadGridView does not get garbagecollected sometimes.
So i fired up a memory analyzer to see what is going on.
This is the graph that shows that the RadGridView is causing a leak. The only references that keep the GridView from getting collected are those two WeakEventListeners
To further investigate i decompiled GridViewDataControl and could identify the culprit.
private void SubscribeToDispatcherShutdown()
{
if (this.dispatcherShutdownListener != null)
this.dispatcherShutdownListener.Detach();
this.dispatcherShutdownListener = new WeakEventListener<GridViewDataControl, object, EventArgs>(this);
this.dispatcherShutdownListener.OnEventAction = (Action<GridViewDataControl, object, EventArgs>) ((grid, source, eventArgs) => grid.OnDispatcherShutdownFinished(source, eventArgs));
this.dispatcherShutdownListener.OnDetachAction = (Action<WeakEventListener<GridViewDataControl, object, EventArgs>>) (weakEventListener => this.Dispatcher.ShutdownFinished -= new EventHandler(this.dispatcherShutdownListener.OnEvent));
this.Dispatcher.ShutdownFinished += new EventHandler(this.dispatcherShutdownListener.OnEvent);
}
In the second line from the botton
... weakEventListener => this.Dispatcher.ShutdownFinished -
If you have the following model, the columns that show the Test and Date properties (in the derived class) cannot be sorted or filtered. Also, no header text is displayed.
public
class
RowModel
{
public
int
Id {
get
;
set
; }
public
Bar FredBar {
get
;
set
; }
}
public
class
Fred : Bar
{
public
DateTime Date {
get
;
set
; }
public
string
Test {
get
;
set
; }
}
public
abstract
class
Bar
{
public
string
Title {
get
;
set
; }
public
double
Value {
get
;
set
; }
}
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Id}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FredBar.Title}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FredBar.Value}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FredBar.Date}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FredBar.Test}"
/>
</
telerik:RadGridView.Columns
>
Bind a grid to a DataView
Start editing and change the values of a few cells.
Press Escape twice to cancel the edit of the entire row.
Expected: the values return to the old values
Actual: the values remain the last entered ones
Unhandled exception System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it. at System.Windows.Threading.Dispatcher.VerifyAccess() at System.Windows.DependencyObject.GetValue(DependencyProperty dp) at Telerik.Windows.Data.SortDescriptorBase.get_SortDirection() at Telerik.Windows.Data.Expressions.SortDescriptorCollectionExpressionBuilder.Sort() at Telerik.Windows.Data.QueryableExtensions.Sort(IQueryable source, IEnumerable`1 sortDescriptors) at Telerik.Windows.Data.QueryableExtensions.Sort(IQueryable source, SortDescriptorCollection sortDescriptors) . . .
As a workaround, the Path with the PathGeometry setter in the style can be replaced by a RadGlyph with a pin icon. The IsPinned Trigger in the style can be replaced with a DataTrigger to the parent row's IsPinned. Here's an example of the updated style for the Fluent theme: <Style x:Key="GridViewPinButtonStyle" TargetType="grid:GridViewPinButton"> <Setter Property="PathStyle" Value="{StaticResource PinUnpinPathStyle}"/> <Setter Property="Foreground" Value="{telerik1:FluentResource ResourceKey=IconBrush}"/> <Setter Property="MinHeight" Value="28"/> <Setter Property="MinWidth" Value="22"/> <Setter Property="IsBackgroundVisible" Value="False"/> <Setter Property="Command" Value="{x:Static telerik:RadGridViewCommands.TogglePinnedRowState}"/> <Setter Property="CommandParameter" Value="{Binding}"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="VerticalContentAlignment" Value="Stretch"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="IsTabStop" Value="False"/> <Setter Property="Padding" Value="0 0 2 0"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="telerik:RadPathButton"> <Grid Background="Transparent"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="BackgroundVisibility"> <VisualState x:Name="BackgroundIsHidden"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Collapsed</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="BackgroundIsVisible"/> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}"/> <telerik:RadGlyph x:Name="UnPinIcon" Foreground="{TemplateBinding Foreground}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center" Glyph="{StaticResource GlyphPin}"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="{telerik1:FluentResource ResourceKey=AccentMouseOverBrush}"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Foreground" Value="{telerik1:FluentResource ResourceKey=AccentPressedBrush}"/> </Trigger> <DataTrigger Binding="{Binding IsPinned, RelativeSource={RelativeSource AncestorType=telerik:GridViewRow}}" Value="True"> <Setter TargetName="UnPinIcon" Property="Glyph" Value="{StaticResource GlyphUnpin}" /> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> ArgumentException: 'RadGlyphExtension' is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types. StackTrace: at System.Windows.Setter.Seal() at System.Windows.SetterBaseCollection.Seal() at System.Windows.Style.Seal() at System.Windows.Style.Seal() at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache) at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) at System.Windows.FrameworkElement.UpdateStyleProperty() at System.Windows.FrameworkElement.OnInitialized(EventArgs e) at Telerik.Windows.Controls.RadButton.OnInitialized(EventArgs e) at Telerik.Windows.Controls.RadPathButton.OnInitialized(EventArgs e) at Telerik.Windows.Controls.GridView.GridViewPinButton.OnInitialized(EventArgs e) at System.Windows.FrameworkElement.TryFireInitialized() at System.Windows.FrameworkElement.EndInit() at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
Setting the theme via the StyleManager.SetTheme(control, theme) method does not style the cell as expected when a CellStyle is defined for its parent column. The current workaround is to explicitly set the theme via the style: <Style x:Key="BlueCellStyle" TargetType="telerik:GridViewCell"> <Setter Property="Background" Value="PowderBlue"/> <Setter Property="telerik:StyleManager.Theme" Value="VisualStudio2013" /> </Style>
To work this around set the GroupRenderMode property of RadGridView to Flat.
When GroupRenderMode is set to Nested the issue can be overcome by calling the BringIntoView method on the row returned in the ScrollIntoViewAsync method's callback:gridView.ScrollIndexIntoViewAsync(index,
new
Action<FrameworkElement>((f) =>
{
f.BringIntoView();
}));
If you have a RadComboBox inside a ControlPanelItem, when you open the RadComboBox's dropdown and select an item, the ControlPanelItem is not closed. As a workaround, you can manually capture the mouse. Please check the attached project.