I have a WPF window that holds a bunch of numbers. Or to use nicer words: Each column is bound to one int property. Now I want to have a nice way to change some of the numbers and I was hoping that I can use a numericUpDown control. Any hints would be appreciated!
You can use DataGridTemplateColumn
.
Sample code:
<DataGrid ItemsSource="{Binding MyData}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTemplateColumn Header="Age">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<wpfToolkit:IntegerUpDown Value="{Binding Age, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Where wpfToolkit
is:
xmlns:wpfToolkit="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"
In this example I use IntegerUpDown
control from Extended WPF Toolkit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With