2011-05-20 47 views
1

我有我的主要功能與功能區選項卡和數據網格。當窗口最大化以適合屏幕時,我怎樣才能最大化窗口中的每一個細節?我正在嘗試使用viewbox,但它不工作。當窗口在wpf中最大化時,如何在窗口中展開所有內容?

<Viewbox Stretch="Uniform"> 
     <Grid x:Name="LayoutRoot"> 

      <Grid.RowDefinitions> 
       <RowDefinition Height="*"/> 
       <RowDefinition Height="auto"/> 
      </Grid.RowDefinitions> 


       <ribbon:Ribbon x:Name="Ribbon"> 

        <ribbon:RibbonTab x:Name="HomeTab" 
            Header="Home"> 
         <ribbon:RibbonGroup x:Name="Group1" 
             Header="Refresh"> 
          <ribbon:RibbonButton x:Name="BtmRefresh" 
              LargeImageSource="Images\refresh.png" 
              Label="Refresh" Margin="25,0,30,0" Click="BtmRefresh_Click" /> 
         </ribbon:RibbonGroup> 
        </ribbon:RibbonTab> 
       </ribbon:Ribbon> 


      <StackPanel Name="PanelDataGrid" Height="Auto" > 

        <DataGrid AutoGenerateColumns="False" Margin="0,138,0,0" Name="dataGrid" Height="Auto" ItemsSource="{Binding}" SelectionUnit="Cell" AlternatingRowBackground="#FFDFE9F5" 
       SelectionMode="Single" ColumnWidth="68" HeadersVisibility="Column" RowBackground="{x:Null}" > 
         <DataGrid.Background> 
          <ImageBrush ImageSource="/GridCellColor;component/Images/barcode.png" /> 
         </DataGrid.Background> 
         <DataGrid.Columns > 

          <DataGridTextColumn Binding="{Binding Path=Job_Num}" Header="Job Nº" IsReadOnly="True" Width="1*" /> 
          <DataGridTextColumn Binding="{Binding Path=Product_Code}" IsReadOnly="True" Header="Product" Width="1*" /> 
    </DataGrid.Columns> 
        </DataGrid> 
       </StackPanel> 

     </Grid> 
    </Viewbox> 

我試着電網標籤

幫助之前加入。

由於提前

+0

我建議張貼您的XAML代碼樣本,以獲得更好的和更具體的回答 – 2011-05-20 14:21:33

+1

你能與視框發佈您的XAML代碼? – Rachel 2011-05-20 14:57:30

+0

@Rachel請看看我的代碼與它已編輯的問題。 – CPM 2011-05-20 15:08:29

回答

1

添加StretchDirection="Both"到您的視框,它應該工作

// Will Stretch it and keep the ratio the same 
<Viewbox Stretch="Uniform" StretchDirection="Both"> 


// Will Stretch it to fill full screen regardless of ratio 
<Viewbox Stretch="Fill" StretchDirection="Both"> 
+0

是伸展,但想要字體變大,整個網格和標籤變得更大,所以如果我把它放在更大的屏幕看起來更大。我希望你明白我在說什麼,我該怎麼做。謝謝您的回覆 – CPM 2011-05-20 14:53:06

+0

@CPM查看我的編輯 – Rachel 2011-05-20 15:47:57

+0

當我試圖做到這一點時,我的所有窗口都凝結成一行,不工作。 – CPM 2011-05-20 15:52:58

0

我正要走出去,猜想,你需要你的視框中錨定到控件的邊緣。這是保證金屬性。

你的ViewBox應該在它的XAML中看起來像Margin=5,5,5,5

+0

對不起,我不明白你在說什麼 – CPM 2011-05-20 14:38:28

+0

@CPM看看編輯。 – msarchet 2011-05-20 14:45:38

+0

已嘗試過,但無法正常工作。 – CPM 2011-05-20 14:53:21

相關問題