Reputation: 1959
I have a window with a tabcontrol inside of it, and each tabitem will parent a frame, which is bound to a page object. But I can't seem to be able to make the frame/page resize to fit the "main window". Here's the code I have:
<controls:MetroWindow x:Class="Mplayer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="Mplayer"
Initialized="Window_Initialized" Height="770" Width="1125">
<TabControl HorizontalAlignment="Left" Height="45" VerticalAlignment="Top" Width="1125" Margin="0,0,0,0">
<TabItem Header="Home" x:Name="HomeTab">
<TabItem.Content>
<Frame Source="HomePage.xaml" Margin="0,0,7,-697"/>
</TabItem.Content>
</TabItem>
</TabControl>
</controls:MetroWindow>
And here's the "HomePage.xaml"
<Page x:Class="Mplayer.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Height="770" Width="1125"
Title="HomePage" Foreground="Black">
<Grid Background="#373737">
<Grid Background="#585858" HorizontalAlignment="Left" Width="400"/>
</Grid>
</Page>
I hope you understand my question, and thanks in advance :)
Upvotes: 0
Views: 2401
Reputation: 81233
Remove harcoded height and width from page definition as well as TabControl definiton:
Height="770" Width="1125"
Upvotes: 1
Reputation: 404
You set the height and width for TabControl and HomePage explicitly. Remove those values both in Page and TabControl.
<TabControl>
<TabItem Header="Home" x:Name="HomeTab">
<Frame Source="HomePage.xaml"/>
</TabItem>
</TabControl>
Upvotes: 0