I have a datagrid who's DataContext is bound to a list of a custom class. I want to add a DataGridTemplateColumn and bind a property in the custom column to the property in the custom class that represents that column.
'Minutes' is an int property in my custom class. And MinuteSlider is a custom UserControl that consist of a slider and a textbox. My goal is to bind the value of the slider in MinuteSlider to the 'Minutes' property that is bound to every row.
My DataGrid is below:
<Grid>
<dg:DataGrid Name="agendaDataGrid" Background="Transparent"
ItemsSource="{Binding}">
<dg:DataGrid.Columns>
<dg:DataGridTextColumn Binding="{Binding Index}"/>
<dg:DataGridTextColumn Binding="{Binding Question}"/>
<dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="{x:Type local:MinuteSlider}">
<local:MinuteSlider x:Name="minutes" MinuteValue="{Binding Path=Minutes}"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
</dg:DataGrid.Columns>
</dg:DataGrid>