我有一个DataGrid
并且已经实现了拖放功能现在当我尝试滚动时,它不起作用,只是显示一个裸体标志。我订阅ScrollBar.Scroll
了,但在里面,我无法获得如何滚动的信息,我不知道我应该向上还是向下滚动。我肯定错过了什么。请帮忙。谢谢
<toolkit:DataGrid x:Name="dg"
Style="{StaticResource DataGridStyle}"
RowDetailsVisibilityMode="VisibleWhenSelected"
ItemsSource="{Binding Relations}"
SelectionUnit="FullRow"
SelectedItem="{Binding ListSelection}" IsReadOnly="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
MouseDoubleClick="dg_MouseDoubleClick"
PreviewKeyDown="DgPreviewKeyDown"
PreviewMouseWheel="DgPreviewMouseWheel"
PreviewMouseLeftButtonDown="DataGridPreviewMouseLeftButtonDown"
PreviewMouseMove="DataGridMouseMove"
Drop="DataGridDrop"
DragEnter="DataGridDragEnter"
ScrollBar.Scroll="DgScroll">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTextColumn Header="Symbol" Binding="{Binding Relation}" MinWidth="310">
<toolkit:DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</toolkit:DataGridTextColumn.ElementStyle>
</toolkit:DataGridTextColumn>
<toolkit:DataGridTextColumn Header="Description" Width="*" MinWidth="300" Binding="{Binding Description}">
<toolkit:DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</toolkit:DataGridTextColumn.ElementStyle>
</toolkit:DataGridTextColumn>
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
private void DgScroll(object sender, ScrollEventArgs e)
{
var viewer = DragDropHelper.GetDescendantByType(dg, typeof(ScrollViewer)) as ScrollViewer;
if (viewer == null) return;
var newVal = e.NewValue; //How I can know scroll up or down???
viewer.ScrollToVerticalOffset(viewer.VerticalOffset + 30)
}