DataGrid中添加ComboBox问题
做DataGrid添加一列ComboBox的有趣问题
相位列是采用ComboBox的列
代码如下:
<dg:DataGridTemplateColumn Header="相位" Width="60">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=相位}"></TextBlock>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
<dg:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox x:Name="PhaseSelect"
SelectedItem="{Binding Path=相位,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={StaticResource PhasePeriod}}"
IsReadOnly="True"
DisplayMemberPath="Day" SelectedValuePath="Index"
SelectionChanged="PhaseSelect_SourceUpdated" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellEditingTemplate>
</dg:DataGridTemplateColumn>