开发者

How to loop through controls within TabItem

开发者 https://www.devze.com 2022-12-24 05:48 出处:网络
I\'d like to loop through the 开发者_StackOverflowcontrols within a TabItem.my xaml is something like

I'd like to loop through the 开发者_StackOverflowcontrols 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号