用于控制的WPF ScrollViewer

时间:2015-05-12 12:14:43

标签: wpf xaml scrollviewer stackpanel

我的ScrollViewer存在问题。这是代码:

AddItem,
AddListMembers,
AddMember,
AddMembers,
AddPrincipalToQueue,
AddPrivileges,
AddProductToKit,
AddRecurrence,
AddToQueue,
AddUserToRecordTeam,
Assign,
AssignUserRoles,
Associate,
BackgroundSend,
Book,
Cancel,
CheckIncoming,
CheckPromote,
Clone,
Close,
CopyDynamicListToStatic,
CopySystemForm,
Create,
CreateException,
CreateInstance,
Delete,
DeleteOpenInstances,
DeliverIncoming,
DeliverPromote,
DetachFromQueue,
Disassociate,
Execute,
ExecuteById,
Export,
ExportAll,
ExportCompressed,
ExportCompressedAll,
GenerateSocialProfile,
GrantAccess,
Handle,
Import,
ImportAll,
ImportCompressedAll,
ImportCompressedWithProgress,
ImportWithProgress,
LockInvoicePricing,
LockSalesOrderPricing,
Lose,
Merge,
ModifyAccess,
PickFromQueue,
Publish,
PublishAll,
QualifyLead,
Recalculate,
ReleaseToQueue,
RemoveFromQueue,
RemoveItem,
RemoveMember,
RemoveMembers,
RemovePrivilege,
RemoveProductFromKit,
RemoveRelated,
RemoveUserFromRecordTeam,
RemoveUserRoles,
ReplacePrivileges,
Reschedule,
Retrieve,
RetrieveExchangeRate,
RetrieveFilteredForms,
RetrieveMultiple,
RetrievePersonalWall,
RetrievePrincipalAccess,
RetrieveRecordWall,
RetrieveSharedPrincipalsAndAccess,
RetrieveUnpublished,
RetrieveUnpublishedMultiple,
RetrieveUserQueues,
RevokeAccess,
Route,
RouteTo,
Send,
SendFromTemplate,
SetRelated,
SetState,
SetStateDynamicEntity,
TriggerServiceEndpointCheck,
UnlockInvoicePricing,
UnlockSalesOrderPricing,
Update,
ValidateRecurrenceRule,
Win

我知道StackPanel中的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> 成为可滚动的。你能帮忙提一些建议吗?提前谢谢。

这是不同卷轴外观的小屏幕截图,第二个是经典的: different scroller appearances

1 个答案:

答案 0 :(得分:0)

只需使用内部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仅应用于最简单的布局任务。