2011-07-19 74 views
0

我上傳了我的窗口畫面,還有白色的空間,我需要填寫與用戶控件,但我不能頂部固定在那裏,下,左,右請指點我如何能做到這一點感謝:)WPF需要有關面板

XAML

<ribbon:RibbonWindow x:Class="H_Pro.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
    Title="H-Pro. Version 1.0.0" Height="394" Width="856" xmlns:my="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon" WindowState="Maximized" Loaded="RibbonWindow_Loaded"> 

<Grid x:Name="LayoutRoot"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

      <my:Ribbon x:Name="MainRibbon" Height="auto" Width="auto" AllowDrop="False" ClipToBounds="False" DataContext="{Binding}" Focusable="True" IsCollapsed="False" IsDropDownOpen="True" IsManipulationEnabled="False" IsMinimized="False"> 
       <my:RibbonTab Header="Main"> 
        <my:RibbonGroup Name="SecurityRibbonGroup" Header="Security" Width="100"> 
         <my:RibbonButton Name="btnChangeUser" Label="Change User" LargeImageSource="/H-Pro;component/Images/1310403730_group.png" Click="btnChangeUser_Click"> 

         </my:RibbonButton> 
         <my:RibbonButton Name="btnUserList" Label="Users List" LargeImageSource="/H-Pro;component/Images/1294319913_people.png" Click="btnUserList_Click" /> 
        </my:RibbonGroup> 
        <my:RibbonGroup Name="BookingOperationsRibbonGroup" Header="Booking Informations" Width="auto"> 
         <my:RibbonButton Label="New Booking" Name="btnNewBooking" LargeImageSource="/H-Pro;component/Images/1310421580_appointment-new.png" /> 
         <my:RibbonButton Label="Booking List" Name="btnBookingList" LargeImageSource="/H-Pro;component/Images/booking.png"/> 
        </my:RibbonGroup> 
        <my:RibbonGroup Name="GuestRibbonGroup" Header="Guest Operations" Width="auto"> 
         <my:RibbonButton Name="btnGuestDataBase" Label="Guest Database" LargeImageSource="/H-Pro;component/Images/dbd.png" /> 
         <my:RibbonGroup /> 
         <my:RibbonButton Label="Add New Guest"/> 
         <my:RibbonButton Label="Top Guests"/> 
        </my:RibbonGroup> 
       </my:RibbonTab> 
       <my:RibbonTab Header="Add/Edit" Name="AddEditRibbonTab"> 
        <my:RibbonGroup Name="AddRooms" Header="Rooms" Width="auto"> 
         <my:RibbonButton Label="Add/Edit Rooms" Name="btnAddEditRooms" LargeImageSource="/H-Pro;component/Images/1310459678_hotel4stars.png" /> 
        </my:RibbonGroup> 
       </my:RibbonTab> 
      </my:Ribbon> 
    <Grid Grid.Row="1" Name="grid1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> 
     <DockPanel LastChildFill="False"> 
      <StackPanel DockPanel.Dock="Top" Background="Yellow"></StackPanel> 
      <StackPanel DockPanel.Dock="Bottom" Background="White" Height="23"> 
       <StatusBar Height="23" Name="MainStatusBar" Width="auto" /> 
       </StackPanel> 
      <StackPanel DockPanel.Dock="Left" Background="AliceBlue" Width="49" Height="auto"/> 

     </DockPanel> 

    </Grid> 
</Grid> 

enter image description here

+0

你能提供更多的細節嗎?無法錨定它的意義? –

回答

1

一個建議:添加另一行到您的網格,並將您的StatusBar移動到網格,而不是DockPanel。

並且像StackPanel一樣,如果將高度/寬度設置爲自動,或者不指定高度/寬度,默認情況下它不會填充父控件。汽車將根據需要使用盡可能多的空間。

1

將內容區域內的用戶控件,並將其設置爲 '拉伸':

<local:MyUserControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/> 

這將確保它填充內容區域。

+0

我有很多用戶控件,我必須爲所有這些代碼編寫代碼? –