gpt4 book ai didi

c# - 不足以阻止在 WP7 ListBox 中滚动

转载 作者:行者123 更新时间:2023-11-30 18:39:14 24 4
gpt4 key购买 nike

我试图阻止在 ListBox 中滚动。使用 ScrollViewer.VerticalScrollBarVisibility 看起来是很好的解决方案 - 滚动被阻止......但是!只要我点击 ListBox 的底部,内容就会向下移动。我想在 duplicated issue 之前问类似的话题(抱歉,这可能与谁有关)。

这是我的代码:

<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>

最佳答案

要解决此问题,请尝试在嵌套列表框中设置属性 IsHitTestVisible="False",因此它应该是这样的:

 <ListBox IsHitTestVisible="False" Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<TextBlock x: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 NewsTitle}" />
<TextBlock x: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 NewsBody}" FontWeight="{Binding Font}"/>
</ListBox>

关于c# - 不足以阻止在 WP7 ListBox 中滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10313065/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com