我手动添加的datagrid内容,如何在C#代码中获取表中的信息
- <DataGrid Name="dgProdOrder" AutoGenerateColumns="False" DisplayMemberPath="{Binding}" SelectionMode="Single" VerticalAlignment="Stretch" HeadersVisibility="Column" HorizontalAlignment="Stretch">
- <DataGrid.Columns>
- <DataGridTemplateColumn Header="工单">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <TextBlock Name="WorkOrderNew" Text="{Binding WorkOrder}" VerticalAlignment="Center" HorizontalAlignment="Center" Width="120" />
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="批次号">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <TextBox Name="BatchCodeNew" Text="{Binding BatchCode}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="240" />
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="开始时间" Width="180">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <DatePicker Name="datePickerStartTimeNew" Text="{Binding StartDate}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></DatePicker>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="结束时间" Width="180">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <DatePicker Name="datePickerEndTimeNew" Text="{Binding EndDate}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></DatePicker>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- </DataGrid.Columns>
- </DataGrid>
复制代码
第一个问题:如何初始化这个datepicker,为当前时间
一般都是对独立的datepicker(name为datePickerStartTime)赋值,this.datePickerStartTime.SelectedDate
可是这个嵌套在里面的日期空间,使用这个方法就不行了
第二个问题:
如何获取表中的所有数据 |
|