views:

403

answers:

0

I have a custom CellEditingTemplate that has a textbox and a calendar control inside a grid. I've made the textbox receive the focus when the user edits the cell by pressing F2 on the keyboard. Unfortunately Silverlight's data grid hooks up to the Grid's LostFocus event so when the user clicks on the date picker control, the LostFocus event fires and the cell exits edit mode. Anyone got any ideas on how to stop this from happening? (If only Silverlight had a .Handled property on RoutedEventArgs.)

Sample XAML:

<data:DataGridTemplateColumn.CellEditingTemplate>
  <DataTemplate>
    <Grid>
      <TextBox Loaded="FocusTextBox"
         Text="{Binding Path=ETD, Mode=TwoWay}" />
      <controls:DatePicker
         x:Name="datePicker"
         SelectedDate="{Binding Path=ETD, Mode=TwoWay, Converter={StaticResource DateTimeConverter}}"
         Margin="2"
         Width="22"
         HorizontalAlignment="Right" />
    </Grid>
  </DataTemplate>
</data:DataGridTemplateColumn.CellEditingTemplate>