我知道TabControl不是自動調整大小的項目,並且您可以將它錨定到一邊,然後將其設置爲拉伸並且可以解決問題,但是當應用程序被最大化時,還有其他方法可以讓TabControl擴展到全屏嗎?同時也讓所有物業擴張並保持相稱。在XAML中創建所有內容時,這可以在XAML中完成,而不是在後面的代碼中完成?如何讓TabControl調整其內部的其他成員
Bellow是應用程序的MainWindow與TabControl的代碼片段,也是它包含的所有其他wpf屬性中包含的5個TabItem之一。我試圖做到這一點,當最大化整個應用程序後,任何建議?
XAML:
<Window x:Class="qaTrackingDatabase.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="QA Tracking DB Update Tool" Height="700.963" Width="868.283" Icon="rm12icon.ico" VerticalAlignment="Top">
<Grid Margin="0,0,-8,3">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFDFEDF7" Offset="0"/>
<GradientStop Color="#FFDFECF7" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TabControl Name="myTabControl" Height="658" Width="858" Margin="0,10,0,0" SelectionChanged="TabControl_SelectionChanged" Background="#FFDFECF7" VerticalAlignment="Top">
<TabItem x:Name="Branch" Header="Branch" Width="170" >
<Grid HorizontalAlignment="Left">
<RadioButton Name="Add" Content="Add" RenderTransformOrigin="0.488,0.454" Margin="25,28,618,548" Checked="Branch_RadioBtns_Checked"/>
<RadioButton Name="Delete" Content="Delete" HorizontalAlignment="Left" Margin="25,99,0,0" VerticalAlignment="Top" Checked="Branch_RadioBtns_Checked" Height="49" Width="205"/>
<TextBox Name="Add_Name_txtBox" IsEnabled="{Binding ElementName=Add, Path=IsChecked}" HorizontalAlignment="Left" Height="25" TextWrapping="Wrap" Text="Enter Name" VerticalAlignment="Top" Width="230" Margin="351,53,0,0" SpellCheck.IsEnabled="True" Background="White"/>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="250,57,509,336"> Branch Name:</TextBlock>
<ComboBox Name="Dproduct_Combo" IsEnabled="{Binding ElementName=Delete, Path=IsChecked}" Text="Select" HorizontalAlignment="Left" Height="25" Margin="111,120,0,0" VerticalAlignment="Top" Width="119" IsReadOnly="True" SelectionChanged="Get_Dproduct_Branch"/>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="41,123,757,482"> Product:</TextBlock>
<ComboBox Name="Aproduct_Combo" IsEnabled="{Binding ElementName=Add, Path=IsChecked}" Text="Select" HorizontalAlignment="Left" Height="25" Margin="111,53,0,0" VerticalAlignment="Top" Width="119"/>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="41,57,757,548"> Product:</TextBlock>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="250,123,509,478"> Select Branch:</TextBlock>
<ComboBox Name="Dbranch_Combo" IsEnabled="{Binding ElementName=Delete, Path=IsChecked}" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="119" IsReadOnly="True" Margin="351,119,0,0"/>
<Button Content="Commit
Changes" HorizontalAlignment="Left" VerticalAlignment="Top" Width="192" Margin="637,187,0,0" Height="49" FontFamily="Levenim MT" FontWeight="Bold" FontSize="16" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Click="Branch_Commit_Changes"/>
</Grid>
</TabItem>
我不太清楚在這裏明白你的問題。 當你最大化你的窗口,你想要你的按鈕和領域放大/看起來更大? – Miiite
您給TabControl一個固定的高度和寬度,並想知道它爲什麼不調整大小? – Paparazzi