【发布时间】:2014-07-24 19:18:20
【问题描述】:
我正在开发简单的聊天 WP 应用程序。我使用来自 Coding4Fun 工具包的 ChatBubble 文本块控件。当用户按住它并向上/向下移动时,我想让这个控件可滚动。我通过将 ContentControl 放在 ScrollViewer 控件中来更改控件样式,但没有帮助。它现在只是“负责”,但我仍然无法在其中滚动。
<Border x:Name="EnabledBorder"
Grid.Row="1"
Padding="{TemplateBinding Padding}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">
<Grid>
<ContentControl
x:Name="HintContentElement"
BorderThickness="0"
Background="Transparent"
Foreground="Gray"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Content="{TemplateBinding Hint}" />
<ScrollViewer>
<ContentControl
x:Name="ContentElement"
Margin="1 2"
MaxHeight="170"
BorderThickness="0"
Background="Transparent"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" />
</ScrollViewer>
</Grid>
</Border>
这是一段 XAML 页面
<c4f:ChatBubbleTextBox
InputScope="Text"
TextChanged="ChatBubbleTextBox_TextChanged"
Text="{Binding CommentText, Mode=TwoWay}"
ChatBubbleDirection="LowerRight"
TextWrapping="Wrap"
AcceptsReturn="True"
Style="{StaticResource themeAwareChatBubbleStyle}" />
【问题讨论】:
-
在您的 ScrollViewer 上尝试 Background="Transparent" 以便不仅仅是内容充当滚动的命中点
-
@ChrisW。同样的结果。我猜 ScrollViewer 默认有透明背景。
-
是的,我在想也许就像银光一样,有时您必须这样做。
标签: c# wpf xaml textbox windows-phone