Open
Description
Description
Despite using {x:Bind ViewModel.x}
the WMC1510 analyzer flags my XAML code. Apps works fine but the warning comes up when the app gets compiled.
Steps To Reproduce
- Create new App
- Use the following XAML Code
<ComboBox x:Name="ThemeMode"
ItemsSource="{x:Bind ViewModel.Themes, Mode=OneWay}"
DisplayMemberPath="DisplayName"
SelectedValuePath="Value"
SelectedValue="{x:Bind ViewModel.SelectedTheme, Mode=TwoWay}"
PlaceholderText="Select Theme" />
- Use the following C# Code
public sealed partial class SettingsPageViewModel : ObservableObject
{
[ObservableProperty]
public partial ElementTheme SelectedTheme { get; set; } = ElementTheme.Default;
public ObservableCollection<ThemeModel> Themes { get; } =
[
new(nameof(ElementTheme.Light), ElementTheme.Light),
new(nameof(ElementTheme.Dark), ElementTheme.Dark),
new(nameof(ElementTheme.Default), ElementTheme.Default)
];
}
[GeneratedBindableCustomProperty]
public sealed partial class ThemeModel(string displayName, ElementTheme value)
{
public string DisplayName { get; init; } = displayName;
public ElementTheme Value { get; init; } = value;
}
- Compile once
- See warning in output window (and then in error list if enabled)
Expected Behavior
The analyzer not flagging my code or some explanation why it does (and maybe how to correct my mistake).
Version Info
.NET SDK 9.0.201
Microsoft.CsWinRT 2.2.0
Microsoft.WindowsAppSDK 1.7.250208002-preview1
Additional Context
Interestingly this warning only occurs when the building of the application is done, not when it's just designed in the IDE.
I also tried to specify x:DataType
like it's said in the description but somehow I can't find a spot where it doesn't gets flagged as an error.