Skip to content

PreviewKeyDown in the floating window has always IsRepeat = true #495

@cirartem

Description

@cirartem

I found that the keyboard click event works differently in the main window and in the floating window. It works correctly in the main window, IsRepeat = false is returned on the first press, IsRepeat = true is returned on hold. In a floating window, IsRepeat = true is immediately returned.
I reproduced the behavior on the test program MVVMTestApp.

MainWindow.xaml change line 61

      <local:PanesTemplateSelector.FileViewTemplate>
          <DataTemplate>
              <StackPanel Orientation="Vertical">
                  <TextBlock Text="FileViewTemplate" />
                  <TextBox
                      Background="Transparent"
                      BorderThickness="0"
                      Text="{Binding TextContent, UpdateSourceTrigger=PropertyChanged}"
                      PreviewKeyDown="TextBox_PreviewKeyDown"/>
              </StackPanel>
          </DataTemplate>
      </local:PanesTemplateSelector.FileViewTemplate>

MainWindow.xaml.cs add

private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)  
{  
	Debug.WriteLine($"TextBox_PreviewKeyDown. sender={sender?.GetType()?.Name?.ToString()}; OriginalSource={(e.OriginalSource as UIElement)?.GetType()?.Name?.ToString()} Source={e.Source?.GetType()?.Name?.ToString()} Key={e.Key} IsRepeat={e.IsRepeat} Handled={e.Handled}");  
}

Output in console:
KeyDownBug

I found this bug in my program with the xceed 2.5 library, I tried to get around this bug for a long time, but I did not find a solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions