我试图防止在 ListBox 中滚动。使用 ScrollViewer.VerticalScrollBarVisibility 看起来像是一个很好的解决方案 - 滚动被阻止......但是!只需点击 ListBox 的底部,内容就会向下移动。我试图在重复问题之前询问类似的主题(对不起,它可能关注谁)。
这是我的代码:
<StackPanel Orientation="vertical">
<Grid Height="130" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" x:Name="itemIco1" Width="120" Height="120" HorizontalAlignment="Left"
Source="{Binding ImageURL}"
Stretch="Fill" CacheMode="BitmapCache" VerticalAlignment="Top" Margin="0,5,5,0" Visibility="Visible"/>
<ListBox Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<TextBlock
Name="TextBlockTitle"
Margin="0,0,0,0"
FontSize="26" FontFamily="Segoe WP Semilight" Foreground="{Binding TitleColor}"
TextTrimming="WordEllipsis" TextWrapping="Wrap"
Width="Auto" Height="auto" MaxHeight="96" VerticalAlignment="Top" FontWeight="{Binding Font}" Text="{Binding Title}" />
<TextBlock
Name="TextBlockBody"
Margin="0,0,0,0"
FontSize="26" FontFamily="Segoe WP Semilight" Foreground="#FF5C5A5A"
TextTrimming="WordEllipsis" TextWrapping="Wrap"
Width="Auto" Height="auto" MaxHeight="100" VerticalAlignment="Top" Text="{Binding Body}" FontWeight="{Binding Font}"/>
</ListBox>
</Grid>
<TextBlock x:Name="date" Height="16" Text="{Binding Date}" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="16" FontFamily="Segoe WP Semilight" FontWeight="{Binding Font}" Foreground="Black" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
</StackPanel>