WPF ScrollViewer 控件
WPF ScrollViewer for control
我对 ScrollViewer 有疑问。这是代码:
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="0">
<TextBlock x:Name="tbFrom" Text="MailSendTo=Send to:" HorizontalAlignment="Left" Margin="0,0,0,3"/>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<util:ctlStaffPicker x:Name="ctlStaffPicker1" ForMessaging="True" TabIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxHeight="75"></util:ctlStaffPicker>
</ScrollViewer>
</StackPanel>
<StackPanel Grid.Row="1" Margin="0,10,0,5" Height="70">
<TextBlock HorizontalAlignment="Left" x:Name="tbQuickMessage" Text="LBLQuickMessage=Quick Message:" TextWrapping="Wrap" Margin="0,0,0,3"/>
<TextBox x:Name="txtQuickMessage"
MaxHeight="35"
HorizontalAlignment="Stretch"
Text="{Binding MessageText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:ctlNewMessage}}}"
TextWrapping="Wrap"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TabIndex="1" />
</StackPanel>
我知道 StackPanel 中的 ScrollViewer 永远无法正常工作。我只想让滚动 <util:ctlStaffPicker>
。你能帮忙提点建议吗?提前致谢。
这是不同滚动条外观的小截图,第二张是经典的:
只需使用内部 Grid Panel
代替:
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Orientation="Vertical" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="tbFrom" Text="MailSendTo=Send to:" HorizontalAlignment="Left" Margin="0,0,0,3"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch">
<util:ctlStaffPicker x:Name="ctlStaffPicker1" ForMessaging="True" TabIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxHeight="75"></util:ctlStaffPicker>
</ScrollViewer>
</Grid>
<StackPanel Grid.Row="1" Margin="0,10,0,5" Height="70">
<TextBlock HorizontalAlignment="Left" x:Name="tbQuickMessage" Text="LBLQuickMessage=Quick Message:" TextWrapping="Wrap" Margin="0,0,0,3"/>
<TextBox x:Name="txtQuickMessage"
MaxHeight="35"
HorizontalAlignment="Stretch"
Text="{Binding MessageText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:ctlNewMessage}}}"
TextWrapping="Wrap"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TabIndex="1" />
</StackPanel>
</Grid>
请注意,StackPanel
s 应该只用于最简单的布局任务。
我对 ScrollViewer 有疑问。这是代码:
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="0">
<TextBlock x:Name="tbFrom" Text="MailSendTo=Send to:" HorizontalAlignment="Left" Margin="0,0,0,3"/>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<util:ctlStaffPicker x:Name="ctlStaffPicker1" ForMessaging="True" TabIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxHeight="75"></util:ctlStaffPicker>
</ScrollViewer>
</StackPanel>
<StackPanel Grid.Row="1" Margin="0,10,0,5" Height="70">
<TextBlock HorizontalAlignment="Left" x:Name="tbQuickMessage" Text="LBLQuickMessage=Quick Message:" TextWrapping="Wrap" Margin="0,0,0,3"/>
<TextBox x:Name="txtQuickMessage"
MaxHeight="35"
HorizontalAlignment="Stretch"
Text="{Binding MessageText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:ctlNewMessage}}}"
TextWrapping="Wrap"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TabIndex="1" />
</StackPanel>
我知道 StackPanel 中的 ScrollViewer 永远无法正常工作。我只想让滚动 <util:ctlStaffPicker>
。你能帮忙提点建议吗?提前致谢。
这是不同滚动条外观的小截图,第二张是经典的:
只需使用内部 Grid Panel
代替:
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Orientation="Vertical" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="tbFrom" Text="MailSendTo=Send to:" HorizontalAlignment="Left" Margin="0,0,0,3"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch">
<util:ctlStaffPicker x:Name="ctlStaffPicker1" ForMessaging="True" TabIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxHeight="75"></util:ctlStaffPicker>
</ScrollViewer>
</Grid>
<StackPanel Grid.Row="1" Margin="0,10,0,5" Height="70">
<TextBlock HorizontalAlignment="Left" x:Name="tbQuickMessage" Text="LBLQuickMessage=Quick Message:" TextWrapping="Wrap" Margin="0,0,0,3"/>
<TextBox x:Name="txtQuickMessage"
MaxHeight="35"
HorizontalAlignment="Stretch"
Text="{Binding MessageText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:ctlNewMessage}}}"
TextWrapping="Wrap"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TabIndex="1" />
</StackPanel>
</Grid>
请注意,StackPanel
s 应该只用于最简单的布局任务。