日期:2014-05-17  浏览次数:20993 次

WPF DataGridComboBoxColumn 一失去焦点就丢失text
在我的DataGrid中定义两个级联的DataGridComboBoxColumn,A1,A2,A1变的时候也把A2的ItemsSource改变。现在改变起来没问题,但是A2一旦失去焦点,那么本应显示的Text也不显示,十分奇怪。背后的绑定显示数据更改已经生效了,但是就是不显示在DataGrid上:

<DataGrid x:Name="Dg_Main" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
                                CanUserAddRows="True" CanUserDeleteRows="True" SelectionMode="Single" SelectionUnit="FullRow"
                                AlternatingRowBackground="Wheat" RowHeaderWidth="10" AlternationCount="2"
                                AutoGenerateColumns="False" ItemsSource="{Binding Path=Displays}" PreparingCellForEdit="Dg_Main_PreparingCellForEdit">
                            <DataGrid.Columns>
                                <DataGridComboBoxColumn Header="A1" MinWidth="80" ItemsSource="{Binding Source={StaticResource A1Source}}" SelectedValueBinding="{Binding Path=a1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="PrimitiveValue" DisplayMemberPath="Content"/>
                                <DataGridComboBoxColumn Header="A2" MinWidth="80"   SelectedValueBinding="{Binding Path=a2, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="PrimitiveValue" DisplayMemberPath="Content" EditingElementStyle="{StaticResource EditCombobox}">
                                    <DataGridComboBoxColumn.ElementStyle>
                                        <Style TargetType="ComboBox">
                                            <!--<Setter Property="ItemTemplate">
                                                <Setter.Value>