Hello,
Welcome to Microsoft Q&A.
You could use RenderTargetBitmap class(which represents an image source that can be populated with the combined contents of a XAML visual tree) to do the job.
For example:
//Page.xaml
<StackPanel>
<Button x:Name="capturedButton" Content="capture me" Margin="10"/>
<Button x:Name="button" Content="click me" Margin="10" Click="button_Click"/>
<Image x:Name="image" Margin="10" Width="200" Height="200" Stretch="None"/>
</StackPanel>
//Page.xaml.cs
private async void button_Click(object sender, RoutedEventArgs e)
{
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
await renderTargetBitmap.RenderAsync(capturedButton);
image.Source = renderTargetBitmap;
}
If the response is helpful, please click "Accept Answer" and upvote it.
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.