DataGridComboBoxColumn SelectionChanged

Mar 6, 2009 at 12:37 AM
How can the SelctionChanged event get wired to the ComboBox in the DataGridComboBoxColum.  I tried the following, however, the cbo_selectionchanged event only fires once.

System.Windows.Controls.

ComboBox cbo;

 

 

private void RecipeActuatorPositionsGrid_BeginningEdit(object sender, Microsoft.Windows.Controls.DataGridBeginningEditEventArgs e)
{
    cbo = (System.Windows.Controls.
ComboBox)e.Column.GetCellContent(e.Row);
    cbo.SelectionChanged +=
new SelectionChangedEventHandler(cbo_SelectionChanged);
}

 

 

int i = 0;

 

 

void cbo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    i++;
}

Thanks.

 

Coordinator
Mar 6, 2009 at 6:57 PM
Use

<dg:DataGridComboBoxColumn ...>
    <dg:DataGridComboBoxColumn.EditingElementStyle>
        <Style TargetType={x:Type ComboBox}>
            <EventSetter Event="SelectionChanged" Handler="cbo_SelectionChanged" />
        </Style>
    </dg:DataGridComboBoxColumn.EditingElementStyle>
</dg:DataGridComboBoxColumn>
Mar 6, 2009 at 8:00 PM
Thanks for the help, worked like a charm.  I did have to add quotes around the {x:Type ComboBox}.