Yes. We're doing this now by subclassing DataGrid and handling the PreparingCellForEdit event. Here is the code.
Imports Csla.Silverlight
Public Class EditableGridBase
Inherits DataGrid
Public Sub New()
AddHandler CurrentCellChanged, AddressOf dg_CurrentCellChanged
AddHandler PreparingCellForEdit, AddressOf dg_PreparingCellForEdit
End Sub
Private Sub dg_CurrentCellChanged(ByVal sender As Object, ByVal e As EventArgs)
EnterEditMode()
End Sub
Sub EnterEditMode()
Try
BeginEdit()
Catch ex As Exception
End Try
End Sub
Private Sub dg_PreparingCellForEdit(ByVal sender As Object, ByVal e As DataGridPreparingCellForEditEventArgs)
Dim txt As TextBox = Nothing
If TypeOf e.Column Is ValidatedDataGridTextColumn Then
Dim sp = TryCast(e.EditingElement, StackPanel)
txt = TryCast(sp.Children(0), TextBox)
Dim p = TryCast(sp.Children(1), PropertyStatus)
txt.Width = e.Column.ActualWidth - 2
p.Visibility = Windows.Visibility.Collapsed
ElseIf TypeOf e.Column Is DataGridCheckBoxColumn Then
Dim ch = TryCast(e.EditingElement, CheckBox)
If ch IsNot Nothing Then
ch.Focus()
ch.IsChecked = Not ch.IsChecked.Value
Return
End If
Else
txt = TryCast(e.EditingElement, TextBox)
End If
If txt IsNot Nothing Then
txt.SelectionLength = txt.Text.Length
txt.Focus()
End If
End Sub
End Class
Copyright (c) Marimer LLC