Hi, 华 张. Welcome to Microsoft Q&A Forum.
You could use MediaCapture API in a WPF application. To do so you need to setup your project to target the right windows versions:
- For .NET 6, you can set the Target OS in properties to 10.0.17763.0 or above (or set the TargetFramrwork in project file to net6.0-windows10.0.17763.0)
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
To learn more, you can take a look at Call Windows Runtime APIs in desktop apps.
For a WPF project sample, you could try checking out MediaCaptureApiWPF .
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.