<Grid>
<DockPanel LastChildFill="True" >
<TabControl x:Name="PossTabControl" DockPanel.Dock="Top" Height="Auto" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<TabItem Header="Tab Page 1" Margin="-9,-2,0,-2">
<WebBrowser Name="webBrowser1" Margin="0,36,0,0"></WebBrowser>
</TabItem>
<TabItem RenderTransformOrigin="0.094,0.5" Margin="-2,-2,2,-2" Height="25">
<TabItem.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="Images/Add.ico" Width="19" Height="15"></Image>
</StackPanel>
</DataTemplate>
</TabItem.HeaderTemplate>
</TabItem>
</TabControl>
</DockPanel>
<DockPanel LastChildFill="True">
<ToolBar Margin="0,28,0,342" DockPanel.Dock="Top" VerticalAlignment="Top" Height="40" Width="Auto">
<StackPanel Orientation="Horizontal">
<Button x:Name="btnBack" Height="30" Margin="0,-2,0,-3" Width="30" Foreground="#FFF02525">
<Button.Content>
<Image Source="Images/Back.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnFoward" Width="30" Height="30" Margin="2.5,-1,0,-2">
<Button.Content>
<Image Source="Images/Forward.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnHome" Width="30" Height="30" Margin="2.5,-1,0,-2">
<Button.Content>
<Image Source="Images/Home.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<ProgressBar x:Name="SocialProgress" Margin="2.9,-1,0,-2" Width="546" Height="30"></ProgressBar>
<Button x:Name="btnGo" Width="40" Margin="5,-1,0,-2" Content="GO" Click="btnGo_Click">
</Button>
<ComboBox x:Name="SearchCombo" Margin="0,3,-5,2" Width="51" SelectedIndex="0">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="Images/Google.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Yahoo.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Bing.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Amazon.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Ebay.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Twitter.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Wikipedia.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
</ComboBox>
<TextBox Margin="5,3,5,2" Name="SearchBar" Width="290"/>
<Image Source="Images/Magnifying.png" Width="30" Height="30"></Image>
<Button Width="94" Height="30"></Button>
</StackPanel>
</ToolBar>
</DockPanel>
<DockPanel LastChildFill="True">
<StackPanel Orientation="Horizontal">
<TextBox x:Name="AddressBar" Height="31" Margin="107,33,590,0" VerticalAlignment="Top" Background="Transparent" FontSize="20" Width="548"/>
</StackPanel>
</DockPanel>
<DockPanel LastChildFill="True">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Top">
<Button x:Name="btnMinimize" HorizontalAlignment="Left" Margin="858,0,0,0" VerticalAlignment="Top" Width="28" Height="27" Click="btnMinimize_Click">
<Button.Content>
<Image Source="Images/Minimize.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnMaximize" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Top" Width="28" Height="27" Click="btnMaximize_Click">
<Button.Content>
<Image Source="Images/Maximize.png" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnClose" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Top" Width="28" Height="27" Click="btnClose_Click">
<Button.Content>
<Image Source="Images/Close.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
</StackPanel>
</DockPanel>
</Grid>
我的WPF网页浏览器项目..当减小窗口大小时,工具栏项目在边框触摸工具栏中的最后一个按钮时消失,任何帮助解决问题将不胜感激[请注意这是我的第一个WPF项目..所以我的知识有限在主题
答案 0 :(得分:0)
我建议尽量避免为控件设置静态高度和宽度,最好使用Grid容器控件来放置控件。这样做和许多关于安排控制的问题将自动解决。 将此XAML粘贴到编辑器中,并检查如何使用Grid来放置控件
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Right">
<Button x:Name="btnMinimize" HorizontalAlignment="Left" Width="28" Height="27" >
<Button.Content>
<Image Source="Images/Minimize.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnMaximize" HorizontalAlignment="Left" Margin="4,0,0,0" Width="28" Height="27">
<Button.Content>
<Image Source="Images/Maximize.png" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnClose" HorizontalAlignment="Left" Margin="4,0,0,0" Width="28" Height="27" >
<Button.Content>
<Image Source="Images/Close.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
</StackPanel>
<TextBox x:Name="AddressBar" Background="Transparent" FontSize="20" Grid.Row="1"/>
<ToolBar Grid.Row="2" Height="40">
<StackPanel Orientation="Horizontal">
<Button x:Name="btnBack" Height="30" Margin="0,-2,0,-3" Width="30" Foreground="#FFF02525">
<Button.Content>
<Image Source="Images/Back.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnFoward" Width="30" Height="30" Margin="2.5,-1,0,-2">
<Button.Content>
<Image Source="Images/Forward.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<Button x:Name="btnHome" Width="30" Height="30" Margin="2.5,-1,0,-2">
<Button.Content>
<Image Source="Images/Home.ico" Stretch="Fill">
</Image>
</Button.Content>
</Button>
<ProgressBar x:Name="SocialProgress" Margin="2.9,-1,0,-2" Width="546" Height="30"></ProgressBar>
<Button x:Name="btnGo" Width="40" Margin="5,-1,0,-2" Content="GO">
</Button>
<ComboBox x:Name="SearchCombo" Margin="0,3,-5,2" Width="51" SelectedIndex="0">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="Images/Google.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Yahoo.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Bing.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Amazon.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Ebay.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Twitter.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel>
<Image Source="Images/Wikipedia.ico" Height="25" Width="25"></Image>
</StackPanel>
</ComboBoxItem>
</ComboBox>
<TextBox Margin="5,3,5,2" Name="SearchBar" Width="290"/>
<Image Source="Images/Magnifying.png" Width="30" Height="30"></Image>
<Button Width="94" Height="30"></Button>
</StackPanel>
</ToolBar>
<TabControl x:Name="PossTabControl" Grid.Row="3">
<TabItem Header="Tab Page 1" >
<WebBrowser Name="webBrowser1" ></WebBrowser>
</TabItem>
<TabItem >
<TabItem.HeaderTemplate>
<DataTemplate>
<Image Source="Images/Add.ico" Width="19" Height="15"></Image>
</DataTemplate>
</TabItem.HeaderTemplate>
</TabItem>
</TabControl>
</Grid>