Skip to content

DatePicker crashes in Fluent theme #10846

Open
@harshit7962

Description

@harshit7962

Description

While using DatePicker with ThemeMode set to System, the application crashes with the exception: System.Windows.Markup.XamlParseException: 'Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.'

Reproduction Steps

  1. Create a simple WPF application
  2. Set the ThemeMode of applications as System
  3. Include a simple DatePicker in MainWindow.xaml
  4. Launch the Application
<Window x:Class="SampleApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:SampleApplication"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <DatePicker Margin="8" />
    </Grid>
</Window>

Expected behavior

Application should simple run with DatePicker rendered.

Actual behavior

Application crashes with the above mentioned exception.

Regression?

Yes

Known Workarounds

Instead of using ThemeMode as System, either use Light or Dark mode. Alternatively, to use system theme, include the Fluent.xaml directly in resourcedictionary.
In app.xaml include the following:

<Application x:Class="SampleApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:SampleApplication"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

Impact

No response

Configuration

.NET 10, preview 4
Windows 11
x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions