How to reference indevedual controls in wpf DataGrid Visual Studio 2010
I am using Visual Studio 2010 beta 2. I created a WPF application that
has a DataGrid. I am able to bind the DataGrid to a DataTable. The
DataGrid has one column that is a DataGridTemplateColumn contains a
TextBox control.
I have a "Save" button that once it is clicked, I need to get what the
user typed in the TextBox. Is there a way I can loop through the
DataGrid and access each Row, Cell control? For example, TextBox tx =
(TextBox)DataGrid1.Rows[0][0].
Your help will be greatly appreciated
Martin CookPosted Feb 10, 2010, 6:30 AM
Make your Binding Two Way and your underlying object will be updated like so: -
TextBox Text="{Binding Notes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Padding="5,5,5,5" Width="200" Height="100" AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" />
Hope this helps.
Cheers,
Martin