I made a custom DataGridColumn
(DGNumericColumn
) with an editing element of type NumericUpDown
(taken from the Extended WPF toolkit)
<k:DataGrid ItemsSource="{Binding Profiles}"
SelectedIndex="{Binding SelectedProfile}">
<k:DataGrid.Columns>
<k:DGNumericColumn Binding="{Binding Depth}"/>
.
.
.
What I want is (what everybody wants from datagrid :)), is to, for example, update the Depth
property in the ViewModel, in a way similar to what happens when NumericUpDown
control is not "inside" a DataGrid
, e.g. when the value of the control is changed and not only when the cell changes (CellEditEnding
event). I thought that the following could might work, but it didn't.
<k:DataGrid ItemsSource="{Binding Profiles}"
SelectedIndex="{Binding SelectedProfile}">
<k:DataGrid.Columns>
<k:DGNumericColumn>
<k:DGNumericColumn.EditingElementStyle>
<Style TargetType="j:NumericUpDown">
<Setter Property="Value" Value="{Binding Depth}"/>
<Setter Property="Maximum" Value="10.0"/>
</Style>
</k:DGNumericColumn.EditingElementStyle>
</k:DGNumericColumn>
.
.
.
Keep in mind that the maximum threshold in the style works, and no binding problems are reported in the output area of Visual Studio. How to solve the problem of property changing only when the cell loses its focus?