This is my current scenario: I have many user controls that are in a separate WPI window on a tab control in WPI window . Something like this:
& lt; Window x: class = "main window" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http: //schemas.microsoft.com/winfx/2006/xaml "Title =" SCAR "windowstate =" max "& gt; & Lt; TabControl Name = "MainTabControl" & gt; & Lt; TabItem name = "tab ops" & gt; & Lt; Grid & gt; & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; Roadfinion height = "20" /> & Lt; /Grid.RowDefinitions> & Lt; Grid.ColumnDefinitions & gt; & Lt; ColumnDefinition / & gt; & Lt; Column width = "30" /> & Lt; ColumnDefinition / & gt; & Lt; /Grid.ColumnDefinitions> & Lt; Local: Service List Height = "Auto" CanInsert = "True" CanCollapse = "True" Grid.ColumnSpan = "3" x: Name = "SL" RecordState = "Edit" /> & Lt; Local: Reservation list CanCollapse = "True" Grid.Row = "1" RecordState = "Edit" x: Name = "RL" /> & Lt; Local: Driver List CanDelete = "False" CanInsert = "False" CanCollapse = "True" Grid.Row = "1" Grid. Column = "2" recordstate = "edit" x: name = "DL" /> & Lt; Local: Client Farm CanDelete = "False" CanInsert = "False" Grid. Line = "2" grid Colspan = "3" recordstate = "see" x: name = "cl" /> & Lt; / Grid & gt; & Lt; / TabItem & gt; & Lt; TabItemItem name = "TabCodes" & gt; & Lt; Local: Client List x: Name = "CustomerCrud" RecordState = "View" / & gt; & Lt; / TabItem & gt; & Lt; Button grid Rows = "1" content = "exam" click = "button_link" /> & Lt; / Grid & gt; & Lt; / Border & gt; & Lt; / Window & gt; Sorry for indentation. For some reason I can not get the code indented properly here: (
I need to set what ( TabControl.Load method to determine, which Currently my different user controls are visible . I need to do it dynamically, I can not hardcode the relationship between tabITimes and their children, something like this: if (TabControl. Is XXXX) ... Here is not possible Because it is a dynamic UI and I do not have any way which is coming out in control. I am digging a little bit and have found that the TabItem control Their "children" do not appear in the visual tree. I can only see the ContentPresenter , and then TabControl , as if tab items do not have "their contents" , So I can not, for example, do a FindAncestor on tab items. < Another interesting fact is that loaded is being organized on my user control event called startup even if they appear on the screen or not. An ideal scenario will be to find an event that is only removed on my Usercontrols, when they are under the tabITim.
Appreciate any thoughts. Thank you in advance
You should be able to take advantage of VisualTreeHelper and its As a result, the TabItem.Content object has been returned to provide the SO and find your specified type, UserControl in this specification. Note : For additional details please see the comments that flow in the question of SO.
Comments
Post a Comment