Hi,
I created a behavior to scroll to the selected item in a RadGridView when the selected item is set programmatically. Basically, I used Dan's answer in this post: https://www.telerik.com/forums/scroll-to-row-when-programmatically-setting-selected-item.
This works fine when applying the behavior directly to the grid as in following example
<telerik:RadGridView Grid.Column="2" ItemsSource="{Binding StockSvtCollectionView}" SelectedItem="{Binding CurrentModel}" GroupRenderMode="Flat" AutoGenerateColumns="False" IsReadOnly="True" ShowGroupFooters="True" ShowColumnFooters="True" AutoExpandGroups="True" Margin="0,-10,0,10">
<i:Interaction.Behaviors>
<uct:RadGridViewScrollSelectedItemIntoViewBehavior/>
</i:Interaction.Behaviors>
Now I'm looking for an easy way to apply this behvior to all my GridViews. I tried using a style:
<Style x:Key="DefaultTelerikGridView" TargetType="{x:Type telerik:RadGridView}">
<Style.Setters>
<Setter Property="i:Interaction.Behaviors">
<Setter.Value>
<uct:RadGridViewScrollSelectedItemIntoViewBehavior/>
</Setter.Value>
</Setter>
<Setter Property="telerik:StyleManager.Theme" Value="{StaticResource DefaultTelerikApplicationTheme}"/>
</Style.Setters>
</Style>
<Style TargetType="{x:Type telerik:RadGridView}" BasedOn="{StaticResource DefaultTelerikGridView}"/>
But this generates this error:
The property "Behaviors" is not a DependencyProperty. To be used in markup, non-attached properties must be exposed on the target type with an accessible instance property "Behaviors". For attached properties, the declaring type must provide static "GetBehaviors" and "SetBehaviors"
Any help would be much appreciated.