TabControl: WinForms Vs WPF
-
Hi, does anybody knows what is the WPF way to avoid Tab Selection? in WinForms i had the Selecting event which i could cancel (with CancelEventArgs) btw, is there any source of the net that gives you the deifferences? i found this great document: Wpf for those who knows WinForms[^] But it doesn't cover everything, just Layouts, Binding and some general issues (Form Vs Window etc.) i would love to get other sources like that :) thanks,
-
Hi, does anybody knows what is the WPF way to avoid Tab Selection? in WinForms i had the Selecting event which i could cancel (with CancelEventArgs) btw, is there any source of the net that gives you the deifferences? i found this great document: Wpf for those who knows WinForms[^] But it doesn't cover everything, just Layouts, Binding and some general issues (Form Vs Window etc.) i would love to get other sources like that :) thanks,
Read up on Preview events and the cancelling of them. This code in effect cancels the mouse click so that the tab selection will not take place. You can get access to the tabitem that was click from the e.OriginalSource and then perform you logic to cancel the mouse click or not.
Private Sub tcOpenPages_PreviewMouseLeftButtonDown(ByVal sender As Object, _
ByVal e As System.Windows.Input.MouseButtonEventArgs) _
Handles tcOpenPages.PreviewMouseLeftButtonDownDim bolCancelTabSelection As Boolean = False 'write some code to set bolCancelTabSelection If bolCancelTabSelection Then e.Handled = True End If
End Sub
Cheers, Karl
» CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP ProfileJust a grain of sand on the worlds beaches.
-
Hi, does anybody knows what is the WPF way to avoid Tab Selection? in WinForms i had the Selecting event which i could cancel (with CancelEventArgs) btw, is there any source of the net that gives you the deifferences? i found this great document: Wpf for those who knows WinForms[^] But it doesn't cover everything, just Layouts, Binding and some general issues (Form Vs Window etc.) i would love to get other sources like that :) thanks,
I believe you should be able to use SelectionChanged event of TabControl. Such as- -------------------------- void tb1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.RemovedItems[0] == TbPage1) { MessageBox.Show(""); } //throw new NotImplementedException(); } ------------------------- -Ajay.
------------------------- www.componentone.com -------------------------
-
I believe you should be able to use SelectionChanged event of TabControl. Such as- -------------------------- void tb1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.RemovedItems[0] == TbPage1) { MessageBox.Show(""); } //throw new NotImplementedException(); } ------------------------- -Ajay.
------------------------- www.componentone.com -------------------------