Comments (4)
I have seen this before, not sure what causes it though. Interestingly, it works fine if you just shove everything into the Winform interop control and use a winform window. Although you do have to deal with winforms swallowing certain keypresses by default instead of passing them to the Avalonia control. Obviously using a winform window when trying to move away from winforms is not ideal.
from avalonia.
I'm digging into the issue in the Avalonia source code, it looks like WM_KEYDOWN events are being fired but not WM_CHAR events, this issue appears to be very similar to the behaviour of this issue:
#785
The resolution for that issue was to give focus to the window after it was shown, so it may be a similar situation with the new avalonia child window not receiving proper focus when being opened from a winforms app.
from avalonia.
Digging down further, it appears the issue is with the WinForms message loop, when running inside a WinForms application the message loop is handled by the WinForms Application class, while when running inside an Avalonia window it uses it's own Win32DispatcherImpl properly routing events. The WinForms Application message loop is looking for the Control.FromChildHandle() of the Window and it is not finding the Control to route the WM_CHAR event to. When running inside an Avalonia Interop hosting control all works fine as it finds the parent Form window from Control.FromChildHandle().
from avalonia.
I think I found a solution, it looks like the event loop was not started properly for the Avalonia window because it was launched from a WinForms app context relying on the WinForms event loop which was looking for a top level Windows.Form.Control to dispatch the WM_CHAR events to. The solution was to force the Avalonia Event loop to start with the new Window, so instead of Window.Show() I would call this method, this causes the Window to be displayed but also for the Avalonia Event loop to start:
Application.Current.Run(avaloniaWindow);
from avalonia.
Related Issues (20)
- NumericUpDown tab index ignored on Windows HOT 1
- Menu Item InputGesture does not display when using MVVM HOT 1
- Clicking the title bar with the mouse causes frame drops and freezes HOT 3
- WindowState does not reflect correct state on Windows HOT 8
- When dragging a file onto the App window
- Context menu keyboard shortcut ignored until menu is visible at least once (Windows) HOT 2
- ILauncher is not working in browser HOT 1
- Avalonia.Browser 11.0.11 UP 11.1.0-beta2 ERROR HOT 3
- Name table parsing is incorrect HOT 5
- Returning UnsetValue in IValueConverter.ConvertBack is reported as a binding error
- Clipboard does not copy/paste objects when complied with .Net8 HOT 7
- Unpredictable behavior with KeyFrames using the same KeyTime
- GetRealizedTreeContainers doesn't return all the TreeViewItem HOT 5
- Avalonia.Browser 11.1.0-beta2 test error
- ToggleSwitch : knob transitions should not remove when dragging is false.
- DrawingContext has a mess in state management in 11.1.0-rc2. HOT 1
- `AvaloniaRuntimeXamlLoader.Load` fails if `x:Class` contains private members
- `ContextMenu.PlacementTarget` is always `null` HOT 1
- `VirtualizingStackPanel` scrolls more than expected when receiving a `Reset` event.
- Missing methods for DrawingContext HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalonia.