Reputation: 140803
Here is the code that cause me problem since few hours:
TabItem newTab = new TabItem();
newTab.Header = source.Name;
newTab.Content = source.GetGui();
newTab.HorizontalContentAlignment = HorizontalAlignment.Stretch;
newTab.VerticalContentAlignment = VerticalAlignment.Stretch;
this.inputSourceDisplay.Items.Add(newTab);
The output is the control (from GetGui()) is showing but in the center vertical and in the center horizontal but haven't stretch at it suppose.
How can I solve that or how can I debug that?
Upvotes: 1
Views: 1163
Reputation: 204139
What does your "GetGui()" method return? Is it a UserControl? By default, UserControls explicitly set their Width and Height properties:
<UserControl x:Class="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
With the Height and Width explicitly set, the UserControl won't respond to attributes like HorizontalContentAlignment.
Upvotes: 1
Reputation: 140803
In WPF if the user control has a default width or height, the user control won't strech even if you use the Enumeration for stretching.
The solution was to remove from the UserControl Xaml the default width and height and the control behaved the way it should.
Upvotes: 0