In my wpf project, I have a datagrid which is being populated by a dataset and contains some columns and many rows. I want to iterate through Column[1] Rows[i] (for example get the values inside the cells of column[1] for all the rows in the datagrid). My question is how can I bind these cells value to a single textbox ? I know using multibinding would be one of the way to achieve the solution but I have not found any help regarding multibinding a textbox through a datagrid. For example, I have read the following questions:
How to bind multiple values to a single WPF TextBlock?
How to use a MultiBinding on DataGridTextColumn?
Also, binding a single value is achievable and I have already done that. I would appreciate any help. Thanks in advance !!
My XAML:
<DataGrid x:Name="datagridbatch"
FontSize="13.333" FontWeight="Normal"
IsReadOnly="True"
SelectionChanged="datagridbatch_SelectionChanged"
SelectionUnit="FullRow" SelectionMode="Single"
VerticalAlignment="Top" HorizontalAlignment="Right"
Height="615" Width="373" Margin="0,0,0,-582"
CanUserResizeColumns="False" CanUserResizeRows="False"
CanUserDeleteRows="False" CanUserAddRows="False"
RowHeight="30"
Grid.Row="5" Grid.Column="1"
CanUserReorderColumns="False" CanUserSortColumns="False"
ColumnHeaderHeight="25" ColumnWidth="*"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto" />
<TextBox x:Name="input2"
Margin="0,0,0,0" Width="490" Height="30"
Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Left"
Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"
FontSize="13.333" FontWeight="Normal"
Text="{Binding SelectedItem.UNIQUEPART_ID, ElementName=datagridbatch}"
BorderBrush="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"
FontFamily="Tahoma"
IsReadOnlyCaretVisible="True"
HorizontalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True"/>