Hi All,
I am trying to add a control to a tabcontrol in the code. I have the following:
txUserControl htmlControl = new txUserControl(Utils.FileMode.Open, Utils.TxMode.Edit, 0);
System.Windows.Forms.Integration.WindowsFormsHost host = new
System.Windows.Forms.Integration.WindowsFormsHost();
host.Child = htmlControl;
DockPanel panel = new DockPanel();
panel.LastChildFill = true;
panel.Children.Add(host);
TabItem tb = new TabItem();
tb.Content = panel;
tb.Header = OpenDocument.Document;
tbControlStories.Items.Add(tb);
tb.Focus();
I have added a button as well to the panel, and the button is displayed, but not my control.
If I removed the tabcontrol and I put a dock panel instead, the control is displayed.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" MinHeight="0" MaxHeight="600"/>
<RowDefinition Height="10"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel x:Name="StackPanelFields" Grid.Row="0">
</StackPanel>
<GridSplitter Grid.Row="1" ResizeDirection="Rows" HorizontalAlignment="Stretch" Height="3" Background="AliceBlue">
</GridSplitter>
<!-- <TabControl x:Name="tbControlStories" Grid.Row="2">
</TabControl> -->
<DockPanel x:Name="StackPanelStory" Grid.Row="2" LastChildFill="True">
</DockPanel>
Then in the code behind:
StackPanelStory.Children.Add(host);
and it works, my control is diplayed as expected.
Could someone tell me what I am doing wrong?
Thanks