Skip to content

Commit

Permalink
Merge pull request #13 from egorozh/fix_bug_with_scrollViewerHandler
Browse files Browse the repository at this point in the history
fix scroll viewer handler defect
  • Loading branch information
Dirkster99 authored Aug 24, 2021
2 parents a379b3c + e79ff7c commit 4caa231
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/InplaceEditBoxLib/Views/EditBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,11 @@ private void OnLostFocus(object sender, RoutedEventArgs e)
/// If an EditBox is in editing mode and the content of a ListView is
/// scrolled, then the EditBox switches to normal mode.
/// </summary>
private void OnScrollViewerChanged(object sender, RoutedEventArgs args)
private void OnScrollViewerChanged(object sender, ScrollChangedEventArgs args)
{
if (args.HorizontalOffset == 0 && args.VerticalOffset == 0)
return;

if (this.IsEditing && Mouse.PrimaryDevice.LeftButton == MouseButtonState.Pressed)
this.OnSwitchToNormalMode();
}
Expand Down Expand Up @@ -811,7 +814,7 @@ private void HookItemsControlEvents()
if (_ParentItemsControl != null)
{
// Handle events on parent control and determine whether to switch to Normal mode or stay in editing mode
_ParentItemsControl.AddHandler(ScrollViewer.ScrollChangedEvent, new RoutedEventHandler(this.OnScrollViewerChanged));
_ParentItemsControl.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(this.OnScrollViewerChanged));
_ParentItemsControl.AddHandler(ScrollViewer.MouseWheelEvent, new RoutedEventHandler((s, e) => this.OnSwitchToNormalMode()), true);

_ParentItemsControl.MouseDown += new MouseButtonEventHandler((s, e) => this.OnSwitchToNormalMode());
Expand Down

0 comments on commit 4caa231

Please sign in to comment.