or

public class GridViewButtonColumn : GridViewBoundColumnBase { public static readonly DependencyProperty ButtonBackgroundProperty = . . . public static readonly DependencyProperty ButtonForegroundProperty = . . . public Brush ButtonBackground { get { return (Brush) GetValue( ButtonBackgroundProperty ); } set { SetValue( ButtonBackgroundProperty, value ); } } public Brush ButtonForeground { get { return (Brush) GetValue( ButtonForegroundProperty ); } set { SetValue( ButtonForegroundProperty, value ); } } public GridViewButtonColumn() { this.EditTriggers = GridViewEditTriggers.None; } public override FrameworkElement CreateCellElement( GridViewCell cell, object dataItem ) { Cell = cell; CellButton = new Button(); CellButton.Click += new RoutedEventHandler( CellButton_Click ); CellButton.CommandParameter = dataItem; Binding contentBinding = new Binding( "Content" ) { Source = this, Mode = BindingMode.TwoWay }; CellButton.SetBinding( Button.ContentProperty, contentBinding ); Binding backgroundBinding = new Binding( "ButtonBackground" ) { Source = this, Mode = BindingMode.TwoWay }; CellButton.SetBinding( Button.BackgroundProperty, backgroundBinding ); Binding foregroundBinding = new Binding( "ButtonForeground" ) { Source = this, Mode = BindingMode.TwoWay }; CellButton.SetBinding( Button.ForegroundProperty, foregroundBinding ); if ( CellButtonVisibility != null ) { CellButton.SetBinding( Button.VisibilityProperty, CellButtonVisibility ); } if ( this.DataMemberBinding != null ) { SetBinding( ContentProperty, this.DataMemberBinding ); } GridViewRow row = cell.ParentRow as GridViewRow; row.SetBinding( GridViewRow.DetailsVisibilityProperty, new Binding( "Visibility" ) { Source = CellButton, Mode = BindingMode.TwoWay } ); return CellButton; } void CellButton_Click( object sender, RoutedEventArgs e ) { Button btn = sender as Button; DataRetentionPolicy policy = btn.DataContext as DataRetentionPolicy; RoutedEventArgs newEventArgs = new ButtonColumnRoutedEventArgs( ClickEvent, policy ); RaiseEvent( newEventArgs ); } } <telerik:RadGridView AutoExpandGroups="True" AutoGenerateColumns="False" Background="{DynamicResource DataBackground}" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserInsertRows="False" CanUserResizeColumns="False" CanUserSortColumns="True" EnableColumnVirtualization="True" EnableRowVirtualization="True" FontSize="16" FontWeight="Bold" Foreground="{DynamicResource DataForeground}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" IsReadOnly="True" ItemsSource="{Binding Path=DataRetentionPolicies, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type cs:AdvancedSettingEditor}}}" Margin="5" Name="DataPolicies" SelectionUnit="FullRow" ScrollMode="Deferred" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ShowGroupFooters="True" TabIndex="8" ToolTip="Data Maintenance Properties" Visibility="{Binding Converter={StaticResource BoolToVisibility}, Mode=TwoWay, Path=EnableRetention, RelativeSource={RelativeSource AncestorType={x:Type cs:AdvancedSettingEditor}}}"> <telerik:RadGridView.Columns> <cs:GridViewButtonColumn ButtonBackground="{DynamicResource ButtonBackground}" ButtonForeground="{DynamicResource ButtonForeground}" Click="EditButton_Click" Content="Edit" FontSize="16" FontWeight="Bold" Width="75" /> </telerik:RadGridView.Columns> </telerik:RadGridView>lstGridView.ForEach(p =>{ if (p.SortDescriptors != null && p.SortDescriptors.Count > 0) { p.RaiseEvent(new GridViewSortingEventArgs((p.SortDescriptors[0] as ColumnSortDescriptor).Column, SortingState.None, SortingState.Ascending) { RoutedEvent = RadGridView.SortingEvent, Source = this }); }});