2011-11-29 77 views
1

酒吧移動,但內容不滾動。ScrollViewer問題,WPF

任何想法?

我想創建一個工作時間表

<Window x:Class="WpfMiGantt.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525" xmlns:my="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"> 
    <Grid ShowGridLines="True"> 
     <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" > 
      <Border Width="1000" Height="1000"/> 
     </ScrollViewer > 
     <Grid ShowGridLines="True"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="30"/>  
       <RowDefinition Height="30"/> 
      </Grid.RowDefinitions> 
      <Grid Grid.Row="1" ShowGridLines="True" > 
       <Grid.ColumnDefinitions > 
        <ColumnDefinition Width="60" /> 
        <ColumnDefinition Width="60" /> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
        <ColumnDefinition Width="60"/> 
       </Grid.ColumnDefinitions> 
       <my:RibbonTextBox Height="23" Label="6:00" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox0" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="6:30" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox1" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="7:00" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox2" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="7:30" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox3" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="8:00" Grid.Column="4" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox4" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="8:30" Grid.Column="5" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox5" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="9:00" Grid.Column="6" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox6" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="10:00" Grid.Column="7" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox7" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="10:30" Grid.Column="8" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox8" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="11:00" Grid.Column="9" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox9" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="11:30" Grid.Column="10" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox10" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="12:00" Grid.Column="11" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox11" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="12:30" Grid.Column="12" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox12" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="13:00" Grid.Column="13" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox13" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="13:30" Grid.Column="14" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox14" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="14:00" Grid.Column="15" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox15" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="14:30" Grid.Column="16" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox16" VerticalAlignment="Center" /> 
       <my:RibbonTextBox Height="23" Label="15:00" Grid.Column="17" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox17" VerticalAlignment="Center" /> 

      </Grid> 
      <my:RibbonButton Label="Fecha" Grid.Column="0" Grid.Row="0" Content="Button" Height="30" HorizontalAlignment="Center" Margin="0" Name="ribbonButton0" VerticalAlignment="Center" Width="Auto" /> 
      <my:RibbonButton Label="" Grid.Column="0" Grid.Row="1" Content="Button" Height="30" HorizontalAlignment="Center" Margin="0" Name="ribbonButton1" VerticalAlignment="Top" Width="75" /> 
      <my:RibbonButton Content="Button" Grid.Column="2" Grid.ColumnSpan="2" Height="23" HorizontalAlignment="Left" Margin="38,8,0,0" Name="ribbonButton2" VerticalAlignment="Top" Width="75" /> 
     </Grid> 
    </Grid> 
</Window> 

我覺得行的順序是關鍵。

PD:你有沒有在codeplex或WPF中看到過類似的項目? 4

回答

3

我懷疑你希望滾動條作用於網格。您將不得不在ScrollViewer中的網格

<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" > 
     <Grid ShowGridLines="True" Width="1000" Height="1000"> 
      ...rest of grid content 
     </Grid> 
    </ScrollViewer > 
+0

謝謝謝謝謝謝! –

+0

如果這回答你的問題,那麼你可以標記爲已回答。 (投票號碼下的小勾號) – aqwert