We're having problems with a Delete button that we've added as a column in a GridView. We're using a CommandBinding, but the DeleteExecuted function where we remove the item from the collection doesn't get called, yet the row automagically disappears from the GridView. I can be debugging for a while trying to delete a bunch of rows (one-at-a-time) without ever hitting a breakpoint set at the very top of the DeleteExecuted function. During this time the rows are consistently being removed from the GridView - but the DeleteExecuted function isn't called. It's as if something within the GridView is automagically removing the row and then setting the event as handled and not routing on to the bound command. Then out of the blue during the same debugging session it will *sometimes* hit my breakpoint, and work reliably from that point on. Incredibly frustrating.
For the record, I'm using the new RadControls for WPF 2010 Q1 release build, running VS 2008 and .NET 3.5. Updating to VS 2010 and .NET 4 is not an option for us at this time. I'm about 90% sure that this was working reliably before we upgraded to the 2010 Q1 release, but unfortunately rolling back isn't an attractive option because we needed a fix that became available in the 2010 Q1 release.
I'm hoping someone out there can throw me some bread crumbs on what might be going on and how to fix it.
Here's where we define the button for the delete column:
And the pertinent stuff from the code-behind:
Thanks in advance!
For the record, I'm using the new RadControls for WPF 2010 Q1 release build, running VS 2008 and .NET 3.5. Updating to VS 2010 and .NET 4 is not an option for us at this time. I'm about 90% sure that this was working reliably before we upgraded to the 2010 Q1 release, but unfortunately rolling back isn't an attractive option because we needed a fix that became available in the 2010 Q1 release.
I'm hoping someone out there can throw me some bread crumbs on what might be going on and how to fix it.
Here's where we define the button for the delete column:
<telerik:GridViewColumn Header="Delete" IsVisible="True"> |
<telerik:GridViewColumn.CellTemplate> |
<DataTemplate> |
<Button Width="18" Height="18" Margin="5,0" |
Command="ApplicationCommands.Delete" CommandParameter="{Binding}" > |
<Button.Content> |
<Grid Width="8.083" Height="8.664" VerticalAlignment="Center" HorizontalAlignment="Center"> |
<Path Fill="{x:Null}" Stretch="Fill" Stroke="#FF000000" Margin="0.083,0.664,0,0" Data="M0.50001547,0.5 L6.5000797,6.5000169 M6.5000155,0.5 L0.5,6.5000704" StrokeThickness="2"/> |
<Path Fill="#FFCE3527" Stretch="Fill" Stroke="#FFCD3527" Margin="0,0,0.083,0.664" Data="M0.50001547,0.5 L6.5000797,6.5000169 M6.5000155,0.5 L0.5,6.5000704" StrokeThickness="2"/> |
</Grid> |
</Button.Content> |
</Button> |
</DataTemplate> |
</telerik:GridViewColumn.CellTemplate> |
</telerik:GridViewColumn> |
And the pertinent stuff from the code-behind:
public ucChartRegionGrid2() |
{ |
InitializeComponent(); |
this.Loaded += new RoutedEventHandler( ucChartRegionGrid2_Loaded ); |
this.CommandBindings.Add( new CommandBinding( ApplicationCommands.Delete, |
this.DeleteExecuted, this.DeleteCanExecute ) ); |
radGridViewDataBinding.SelectionChanged += new |
EventHandler<Telerik.Windows.Controls.SelectionChangeEventArgs>(radGridViewDataBinding_SelectionChanged); |
} |
public void DeleteCanExecute(object sender, CanExecuteRoutedEventArgs e) |
{ |
e.CanExecute = true; |
} |
public void DeleteExecuted(object sender, ExecutedRoutedEventArgs e) |
{ |
// set a breakpoint here. It’s not hit, but the row disappears from the grid!? |
RegionEvent2 deleteRange = e.Parameter as RegionEvent2; |
Thanks in advance!