Let's think about what is actually going on here.
With XAMPP, you are basically running an Apache server inside a Windows program.
With WSL v1, you have a Linux virtual machine running within Windows that has drush, composer, etc.
With WSL v2, you have Linux running in Hyper-V (MS hypervisor), so you get near-native Linux performance with less virtualization overhead.
So, basically the question becomes "How do I access a server running in a Windows environment from a Linux environment inside the Windows environment?"
Depending on how comfortable you are with firewalls and proxies and things, and depending on how your computer is already set up, configuring this may not be too hard-- but it could also be a real mess.
composer
For composer
, you just need access to your Windows files from within Linux.
With WSL, Windows C: drive should be mounted at /mnt/c
in Linux. So you can just cd
to the Windows directory that has your files from Linux and run composer
commands.
drush
For drush
, you'll need to set up aliases and connect to the XAMPP server. You may also have to open some ports in your Windows firewall, which can present a security risk. The details of this are out of scope for this site (better fit for Server Fault).
a better solution
As @leymannx mentioned, DDEV is a solution that provides a solid Drupal local development environment with little configuration, and I personally use lando, which has served me well for the past 5+ years. They are both free (both open source and free as in beer), and give you solid defaults; you'll probably save a lot of time not setting things up for yourself.