我有一个XAML页面,其中有4个网格(rectGrid,dateGrid,roomGrid,optionGrid),其中3个(rectGrid,dateGrid,roomGrid)是动态创建的(在Code Behind中)
我想做的是,rectGrid是可滚动的Horizontal和Vertical,但roomGrid只有Horizontal而dateGrid只能垂直
这是代码
<ScrollViewer Height="Auto" Width="Auto" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<Grid>
<Grid Name="optionsGrid">
<Label Name="lZeit" Content="Zeitraum: von" Margin="100,7,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
<DatePicker Name="dpVon" Margin="192,7,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="150" Height="23"></DatePicker>
<Label Name="lBis" Content="bis" Margin="372,7,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
<DatePicker Name="dpBis" Margin="440,8,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="150" Height="23"></DatePicker>
<Button Content="OK" Height="23" HorizontalAlignment="Left" Margin="620,6,0,0" Name="selectDates" VerticalAlignment="Top" Width="60" RenderTransformOrigin="-2.552,0.522" Click="selectDates_Click"/>
<Button Content="Drucken" Height="23" HorizontalAlignment="Left" Margin="740,6,0,0" Name="print" VerticalAlignment="Top" Width="60" RenderTransformOrigin="-2.552,0.522" Click="print_Click"/>
</Grid>
<Grid HorizontalAlignment="Stretch" Margin="100,70" Name="rectGrid" VerticalAlignment="Stretch" OpacityMask="Black" Opacity="1" ShowGridLines="False" Height="Auto" Width="Auto">
</Grid>
<Grid Height="30" HorizontalAlignment="Stretch" Margin="98,31,0,0" Name="dateGrid" VerticalAlignment="Top" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="656*"/>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="1129*"/>
</Grid.ColumnDefinitions>
</Grid>
<Grid HorizontalAlignment="Left" Height="Auto" Width="82" Name="roomGrid" Margin="0,70">
</Grid>
</Grid>
</ScrollViewer>
这是一个截图: enter image description here
答案 0 :(得分:0)
不要将Grids
放在ScrollViewer
中,而是执行此操作;
<Grid Name="optionsGrid" ScrollViewer.HorizontalScrollBarVisibility="Visible">
OR
<Grid Name="optionsGrid" ScrollViewer.VerticalScrollBarVisibility="Visible">
我真的不明白你的问题或Grids
的命名,所以你需要根据需要改变它。
答案 1 :(得分:0)
我已经解决了。
<Grid HorizontalAlignment="Stretch" Name="rectGrid" VerticalAlignment="Stretch" OpacityMask="Black" Opacity="1" ShowGridLines="False" Height="Auto" Width="Auto">
</Grid>
</ScrollViewer>