Tutorial :How to loop through controls within TabItem



Question:

I'd like to loop through the controls within a TabItem. my xaml is something like

TabControl TabItem ScrollViewer Grid

I have tried

TabItem ti = TabControl.Selected as TabItem

foreach (UIElement control in ti)    ...  

Which causes an error

Basically I would like to get to the ScrollViewer Content or Grid


Solution:1

Figured it out:

First grab the TabItem and declare the ScrollViewer and then get the ScrollViewer Content and declare the Grid as a FrameworkElement

TabItem ti = GBtabControl.SelectedItem as TabItem;  ScrollViewer sc = ti.Content as ScrollViewer;  FrameworkElement element = sc.Content as FrameworkElement;  

Thanks


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »