Formats dates, numbers, and currency with culture awareness in WPF. Use when displaying localized data formats or building international applications.
View on GitHubchristian289/dotnet-with-claudecode
wpf-dev-pack
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/christian289/dotnet-with-claudecode/blob/main/wpf-dev-pack/skills/formatting-culture-aware-data/SKILL.md -a claude-code --skill formatting-culture-aware-dataInstallation paths:
.claude/skills/formatting-culture-aware-data/# Culture-Aware Data Formatting in WPF
Format dates, numbers, and currency based on user's culture preferences.
## 1. Culture Formatting Overview
| Data Type | en-US | ko-KR | de-DE |
|-----------|-------|-------|-------|
| Date (d) | 1/21/2026 | 2026-01-21 | 21.01.2026 |
| Currency (C) | $1,234.56 | ₩1,235 | 1.234,56 € |
| Number (N2) | 1,234.56 | 1,234.56 | 1.234,56 |
| Percent (P) | 75.00% | 75.00% | 75,00 % |
---
## 2. XAML Formatting
### 2.1 Date Formatting
```xml
<!-- Short date (culture-aware) -->
<TextBlock Text="{Binding Date, StringFormat={}{0:d}}"/>
<!-- Long date -->
<TextBlock Text="{Binding Date, StringFormat={}{0:D}}"/>
<!-- Custom format (not culture-aware) -->
<TextBlock Text="{Binding Date, StringFormat={}{0:yyyy-MM-dd}}"/>
<!-- Date and time -->
<TextBlock Text="{Binding Date, StringFormat={}{0:g}}"/>
```
### 2.2 Number Formatting
```xml
<!-- Number with 2 decimal places -->
<TextBlock Text="{Binding Amount, StringFormat={}{0:N2}}"/>
<!-- Number with no decimals -->
<TextBlock Text="{Binding Count, StringFormat={}{0:N0}}"/>
<!-- Fixed decimal places -->
<TextBlock Text="{Binding Value, StringFormat={}{0:F2}}"/>
```
### 2.3 Currency Formatting
```xml
<!-- Currency (culture-aware symbol and format) -->
<TextBlock Text="{Binding Price, StringFormat={}{0:C}}"/>
<!-- Currency with no decimals -->
<TextBlock Text="{Binding Price, StringFormat={}{0:C0}}"/>
```
### 2.4 Percent Formatting
```xml
<!-- Percent (multiplies by 100) -->
<TextBlock Text="{Binding Rate, StringFormat={}{0:P}}"/>
<!-- Percent with 1 decimal -->
<TextBlock Text="{Binding Rate, StringFormat={}{0:P1}}"/>
```
---
## 3. Code Formatting
### 3.1 Using Current Culture
```csharp
// Uses Thread.CurrentThread.CurrentCulture
var dateStr = DateTime.Now.ToString("d");
var currencyStr = price.ToString("C");
var numberStr = amount.ToString("N2");
```
### 3.2 Specific Culture
```csharp
var koKr = new CultureInfo("ko-KR");
var deDE = new CultureInfo("de-DE");
// Korean for