2009-07-20 190 views
0

有誰知道什麼是錯我的代碼:ScrollViewer沒有正確顯示?

<Border Background="AliceBlue" BorderThickness="2"> 
    <Grid Name="MainGrid" Background="DarkGray" > 
     <Grid.RowDefinitions> 
      <RowDefinition Height="0.02*"/> 
      <RowDefinition Height="0.07*"/> 
      <RowDefinition Height="0.63*"/> 
      <RowDefinition Height="0.05*"/> 
      <RowDefinition Height="0.05*"/> 
     </Grid.RowDefinitions> 

     [...SNIP...] 

      <StackPanel Grid.Row="2"> 
      <Expander Header="Filteroptionen" Foreground="WhiteSmoke" FontWeight="Bold"> 
       <Border Margin="18,10,18,10" Name="border1" CornerRadius="10,10,10,10" Background="Gray" > 
        <Grid> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition></ColumnDefinition> 
          <ColumnDefinition></ColumnDefinition> 
          <ColumnDefinition></ColumnDefinition> 
         </Grid.ColumnDefinitions> 
         <StackPanel Margin="15,5,5,5" Grid.Column="0"> 
          <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest1">test1</RadioButton> 
          <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest2">test2</RadioButton> 
          <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest3">test3</RadioButton> 
         </StackPanel> 
          <StackPanel Margin="15,5,5,5" Grid.Column="1"> 
           <my:DatePicker HorizontalAlignment="Left" Height="25" Name="datePicker1" Width="115" Text="Von" /> 
           <my:DatePicker HorizontalAlignment="Left" Height="25" Name="datePicker2" Width="115" Text="Bis" IsEnabled="True" /> 
          </StackPanel> 
          <StackPanel Margin="15,5,5,5" Grid.Column="2"> 
           <WrapPanel> 
            <Label FontWeight="Normal" Foreground="White" >Number</Label> 
            <TextBox FontWeight="Normal" Width="193"></TextBox> 
           </WrapPanel> 
           <WrapPanel> 
            <Label FontWeight="Normal" Foreground="White" >Name</Label> 
            <TextBox FontWeight="Normal" Width="250"></TextBox> 
           </WrapPanel> 

          </StackPanel> 

         </Grid> 
       </Border> 
      </Expander> 
        <Border Margin="18,10,18,10" CornerRadius="10,10,10,10" Background="Gray" > 
         <my:DataGrid Margin="10,10,10,10" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="auto" ItemsSource="{Binding}" Name="mainDataGrid" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" /> 
       </Border> 
      </StackPanel> 

我已經把它貼在這裏一個圖像,顯示問題(我的滾動條顯示不出來正常,它就會由網格我想切):
Picture

非常感謝您的幫助!

乾杯

回答

2

容納面板的高度沒有限制。發生的事情是,包含面板(包含DataGrid的StackPanel)正在增長,因此DataGrid認爲它不需要滾動。

嘗試在StackPanel上設置Height值(如窗口的高度或類似的東西)。滾動條應該出現並工作。

0

或者,如果您的容器沒有固定高度,請在ScrollViewer上設置MaxHeight。