Skip to content

Bug: WMC1510 appearing but x:Bind is used #1951

Open
@Sella-GH

Description

@Sella-GH

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

  1. Create new App
  2. 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" />
  1. 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;
}
  1. Compile once
  2. 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.

Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions