Integrates multimedia content in WPF including MediaElement video/audio playback, Image control display, and SoundPlayerAction effects. Use when building media players, galleries, or multimedia UIs.
View on GitHubchristian289/dotnet-with-claudecode
wpf-dev-pack
January 23, 2026
Select agents to install to:
npx add-skill https://github.com/christian289/dotnet-with-claudecode/blob/main/wpf-dev-pack/skills/integrating-wpf-media/SKILL.md -a claude-code --skill integrating-wpf-mediaInstallation paths:
.claude/skills/integrating-wpf-media/# WPF Media Integration Patterns
Integrating multimedia content such as images, video, and audio in WPF.
## 1. Image Control
### 1.1 Basic Image Display
```xml
<!-- Resource image -->
<Image Source="/Assets/logo.png" Width="100" Height="100"/>
<!-- Absolute path -->
<Image Source="C:\Images\photo.jpg"/>
<!-- URI -->
<Image Source="https://example.com/image.png"/>
<!-- Pack URI (embedded resource) -->
<Image Source="pack://application:,,,/MyAssembly;component/Images/icon.png"/>
```
### 1.2 Stretch Options
```xml
<!-- None: maintain original size -->
<Image Source="/photo.jpg" Stretch="None"/>
<!-- Fill: stretch to fit area (ignore aspect ratio) -->
<Image Source="/photo.jpg" Stretch="Fill"/>
<!-- Uniform: maintain aspect ratio, maximum size within area -->
<Image Source="/photo.jpg" Stretch="Uniform"/>
<!-- UniformToFill: maintain aspect ratio, fill area (may crop) -->
<Image Source="/photo.jpg" Stretch="UniformToFill"/>
```
### 1.3 Dynamic Image Loading
```csharp
namespace MyApp.Helpers;
using System;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
public static class ImageHelper
{
/// <summary>
/// Load image from file
/// </summary>
public static BitmapImage LoadFromFile(string filePath)
{
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(filePath, UriKind.Absolute);
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
bitmap.Freeze(); // Can be used outside UI thread
return bitmap;
}
/// <summary>
/// Load image from stream
/// </summary>
public static BitmapImage LoadFromStream(Stream stream)
{
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = stream;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
bitmap.Freeze();
return bitmap;
}
/// <summary>
/// Load thumbnail (m