microsoft / microsoft/microsoft-ui-xaml

Binding ClockIdentifier in TimePicker causes System.AccessViolationException

Open
#10,671 6 comments 0 reactions 0 assignees View on GitHub
area-DateTimePickers bug Crash team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When using a Binding for ClockIdentifier parameter of TimePicker, app crashes with System.AccessViolationException. This does not happen when directly using ClockIdentifier="24HourClock".

### Steps to reproduce the bug

1. Create a sample app
2. In `MainWindow.xaml`,
2.1 Add `x:Name="TestGrid"` to the `Grid`
2.2 Add a `TimePicker`
3. In `MainWindow.xaml.cs`
3.1 Under `InitializeComponent();` add `TestGrid.DataContext = this;`
3.2 Add property `public string ClockIdentifier { get; } = "24HourClock";`
4. In `MainWindow.xaml`,
4.1 Use `ClockIdentifier="{Binding ClockIdentifier}"` in the `TimePicker`
5. Run app
6. Notice error

[MainWindow.xaml](https://github.com/user-attachments/files/21263143/MainWindow.xaml.txt)
[MainWindow.xaml.cs](https://github.com/user-attachments/files/21263142/MainWindow.xaml.cs.txt)

### Expected behavior

App doesn't crash and displays time picker in 24h format.

### Screenshots

Image

### NuGet package version

WinUI 3 - Windows App SDK 1.7.3: 1.7.250606001

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the attached MainWindow.xaml and MainWindow.xaml.cs, reproducing the crash with a bound ClockIdentifier on TimePicker. Trace the TimePicker binding path and compare it with the direct 24HourClock value. Done means the sample runs without System.AccessViolationException and displays the picker in 24-hour format.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.