nrb

Hi

I¡¯m trying to convert some code written in .net 2.0 to WPF

Is there something equaling in WPF to the .net 2.0 combo box selectionChangeCommitted event

Meaning that I want the event to be fired only after a user change the item in the combo and not when it¡¯s done by code

Thanks




Re: Windows Presentation Foundation (WPF) selection change in wpf

Yiling Lai

Hello, You can try Selector.SelectionChanged event.






Re: Windows Presentation Foundation (WPF) selection change in wpf

nrb

Hi yiling

Thanks for your help

How it will help What is the difference between handling the selection change event of the selector class itself

Rather the combo class event in both cases it will happened even after a change throw code

Im looking for event that will be fired only after a user was changing the selection item un the combo

thanks






Re: Windows Presentation Foundation (WPF) selection change in wpf

Wei Zhou - MSFT

Hi nrb

Do you mean that you want to handle event only after a user changed selected item but not by the code If so, the DropDownClosed event of ComboBox may more suitable for you.

Best Regards

Wei Zhou






Re: Windows Presentation Foundation (WPF) selection change in wpf

Yiling Lai

Hello, Selector is one base class of ComboBox. so Selector.SelectionChanged might suitable for you.






Re: Windows Presentation Foundation (WPF) selection change in wpf

nrb

hi Wei

once again thanks for your help...

It will be fired even if the user just open the drop down list and didn¡¯t make any new selection

and it leaves me to handle and see if an item was changed...

another ¡°problematic¡± event that I have encountered is the TabConrol deselecting event

in .net 2.0 I use this event to run some validity checks before the user can select a different tab, if the checks fail I cancel

the event and the original tab stay selected

but I couldn¡¯t find something similar in WPF so I had to do something like this :

Private Sub TabControlMain_PreviewLostKeyboardFocus(ByVal sender As Object, ByVal e As System.Windows.Input.KeyboardFocusChangedEventArgs) Handles TabControlMain.PreviewLostKeyboardFocus

If e.NewFocus.GetType.ToString.Equals("System.Windows.Controls.TabItem") Then

' only if a new tab is the target

If checkDataValidity() = False Then

e.Handled = True

End If

End If

End Sub

Am I missing something here is this how WPF should work






Re: Windows Presentation Foundation (WPF) selection change in wpf

Wei Zhou - MSFT

Hi nrb

Yes, you can cancel the selected tab change event by setting the Handled property as true. For example,

private void TabItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{

// do some validations
e.Handled = true;
}

Best Regards

Wei Zhou