0
我有DataGrid
並已實現拖放功能 現在,當我嘗試滾動時,它不工作只是顯示裸體標誌。 我訂閱ScrollBar.Scroll
,但它裏面,我不能得到的信息如何滾動, 我不知道我是否應該向上或向下滾動。我一定錯過了什麼。請幫助。謝謝DataGrid無法滾動B/C拖放
<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)
}
我沒有找到http://stackoverflow.com/questions/4124877/wpf-datagrid-cant-use-mouse-to-scroll-because-of-drag-drop – toosensitive
我一個解決方案嘗試了一個單獨的scrollviewer,但這會導致新的問題 - 性能下降。 http://stackoverflow.com/questions/11127511/slow-performance-with-wpf-datagrid-and-scrollviewer?rq=1 – toosensitive
看看這個問題的答案:http://stackoverflow.com/questions/ 10733581 /滾動-而拖動和墜-WPF –