Reputation: 2168
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!
Upvotes: 4
Views: 3580
Reputation: 19296
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.
Upvotes: 8