views:

52

answers:

0

Hello,

When I click a cell in my DataGridComboBoxColumn the ComboBox gets visible and I can select items. When I have selected an item its visible at the top thats fine. But when the cell aka ComboBox loses its focus because I click something different in the DataGrid then there is no item/text visible anymore in the cell I have previously selected.

How can I keep that selection/selected text?

thats my code:

     <DataGridComboBoxColumn
                Width="*"
                Header="Monday"
                DisplayMemberPath="SchoolclassName"
                SelectedValueBinding="{Binding SchoolclassCodeMonday}"  
                ItemsSource="{Binding Source={StaticResource ClassCodes}}">

                <DataGridComboBoxColumn.ElementStyle>
                    <Style TargetType="ComboBox">
                        <Setter Property="IsSynchronizedWithCurrentItem" Value="False" />
                        <Setter Property="ItemsSource" Value="{Binding Source={StaticResource ClassCodes}}" />
                    </Style>
                </DataGridComboBoxColumn.ElementStyle>

                <DataGridComboBoxColumn.EditingElementStyle>                   
                    <Style TargetType="ComboBox">
                        <Setter Property="ItemsSource" Value="{Binding Source={StaticResource ClassCodes}}" />
                        <Setter Property="IsDropDownOpen" Value="True" />
                    </Style>                   
                </DataGridComboBoxColumn.EditingElementStyle>
            </DataGridComboBoxColumn>

there seems to be a solution for my problem: http://wpf.codeplex.com/Thread/View.aspx?ThreadId=46627 (scroll to the bottom) but I can not transfer the solution to my problem. Because my model setup is quite different.

SchoolclassName is a string property in Schoolclass.cs SchoolclassCodeMonday is a string property in TimeTable.cs ClassCodes aka SchoolclassCodes is a property of type ObservableCollection|Schoolclass|

Someone knows how to fix my binding?