DataGridComboBoxColumn selectionChanged Problem

Mar 12, 2010 at 11:54 AM

hello friends

i am new to WPF and developing browse based WPF page

i have a DataGridComboBoxColumn column in DataGrid (WpfToolkit control)
now i want Selectedindexchanged for the combobox.

i have implemeted it in following way

CellStyle="{StaticResource LeftAlignedCellStyle}" 
Header="Schedule" x:Name="CmbSchedule" Width="250" 
SelectedValueBinding="{Binding SCHEDULE1}" 
DisplayMemberPath="SNAME" SelectedValuePath="SCODE"  >
   <Style TargetType="{x:Type ComboBox}" >
      <EventSetter Event="SelectionChanged" 
                Handler="CmbSchedule_SelectionChanged" />


In Code Behind file

Private Sub CmbSchedule_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim accb As ComboBox = CType(sender, ComboBox)
        Dim ItemName As ComboBox = CType(CmbItems.ItemsSource, ComboBox)
        If (GV1.Items.IndexOf(GV1.SelectedItem) > -1 AndAlso Not IsDBNull(GV1.Items(GV1.Items.IndexOf(GV1.SelectedItem))("SCHEDULE1"))) Then
            If (accb.SelectedValue = "Y") Then
                If (GV1.Items(GV1.Items.IndexOf(GV1.SelectedItem))("ITEMCODE").ToString = String.Empty) Then
                    MessageBox.Show("Please Select Item Before Schedule Settings", "Data Error", MessageBoxButton.OK, MessageBoxImage.Information)
                End If
            End If
        End If

    End Sub

Now what my problem is the event is raised multiple times
when i click on cell which contains this combobox, this event is raised multiple times
I want this event to be raised only when i change value in combobox

Plz help me