【发布时间】:2012-09-18 07:37:37
【问题描述】:
我有一个滚动查看器控件。它的编码
<Window.Resources>
<DataTemplate x:Key="listBoxItemTemplate">
<TextBlock />
</DataTemplate>
<ItemsPanelTemplate x:Key="itemsPanelTemplate">
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0"/>
<RowDefinition/>
</Grid.RowDefinitions>
<RepeatButton x:Name="LineLeftButton"
Grid.Column="0"
Grid.Row="1"
Content="<"
Command="{x:Static ScrollBar.LineLeftCommand}"
CommandTarget="{Binding ElementName=scrollViewer}"/>
<RepeatButton x:Name="LineRightButton"
Grid.Column="2"
Grid.Row="1"
Content=">"
Command="{x:Static ScrollBar.LineRightCommand}"
CommandTarget="{Binding ElementName=scrollViewer}"/>
<ScrollViewer Grid.Column="1" Grid.Row="1" x:Name="scrollViewer"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Hidden">
<ListBox Name="lst2"
Margin="0,0,0,0"
VerticalAlignment="Stretch"
ItemsPanel="{StaticResource itemsPanelTemplate}"/>
</ScrollViewer>
</Grid>
我想在没有数据时禁用重复按钮。
也就是说,当我滚动列表框数据时,最后当特定一侧(即左、右)没有可用数据时,该侧的重复按钮将被禁用。当我向后滚动时,将启用上述重复按钮。
我在这里展示了一个图形表示。我相信这可以正确澄清。
图片1:
请检查左侧的重复按钮是否已禁用,因为左侧没有可滚动的数据。
图片2:
请检查右侧的重复按钮是否已禁用,因为右侧没有可滚动的数据。
这种类型的滚动是我想要实现的。我读了Wpf disable repeatbuttons when scrolled to top/bottom 但没用。
【问题讨论】:
标签: c# wpf vb.net repeatbutton