How to resolve the XAML generated code is throwing NotImplementedException when using x:Bind RRS feed

  • General discussion

  • Recently, some developers face the issue when they use 'x:Bind' in their UserControl. In the UserControl, they use 'x:Bind' to bind to the property which is in the UserControl’s code-behind like the following:

        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock Text="{x:Bind ViewModel.Text, Mode=OneWay}"/>
    public sealed partial class MyUserControl : Page
        public MyUserControl()
            this.DataContextChanged += (s, e) => this.Bindings.Update();
        public SampleModel ViewModel => DataContext as SampleModel;
    public class SampleModel
        public string Text { get; set; }

    They use this UserControl as other control’s DataTemplate, for example, the ListView’s ItemTemplate.

    <ListView x:Name="SomeListView">
                    <local:MyUserControl />

    Then, once we set a value to the ListView’s ItemsSource like the following: 

    SomeListView.ItemsSource = Enumerable.Range(0, 10).Select(i => new SampleModel { Text = $"Model_{i}" });

    At the same time, the UserControl’s DataContext will be changed. In UserControl’s code-behind, the ViewModel property value will be updated, but on XAML of UserControl, it didn’t get updated. To make the x:Bind work in this case, we need to call the Bindings.Update() method in the 'DataContextChanged' event handler of UserControl. It will force it to update the source.

    Here, you might wonder where the 'Bindings.update ()' method comes from. If you check the document, it has explained:

    >> Pages and user controls that include Compiled bindings will have a "Bindings" property in the generated code. This includes an Update() method. This method will update the values of all compiled bindings. Any one-way/Two-Way bindings will have the listeners hooked up to detect changes.

    Then, if your project’s target version is earlier than 17763, your code does work without problem. But if your project’s target version is 17763, you will get exception:

    'System.NotImplementedException: The method or operation is not implemented.'

    We are aware of the problem and considering a fix for a future version of the Visual Studio product in the XAML Compiler generated code. To workaround the issue, you need to disable the x:Bind diagnostics feature by adding the following into your project (.csproj) file(under the first Propertygroup block).

    The detailed steps: 'Right click your project – Unload Project – Right click your project – Edit your project.csproj'.

    Friday, December 21, 2018 7:16 AM

All replies

  • When will this be fixed?  I'm still getting the issue in 1809...

    - James Esh

    Thursday, March 7, 2019 9:28 PM
  • iam waiting also
    Wednesday, May 29, 2019 1:54 PM
  • This issue has been fixed in Windows 10, version 1903(Windows SDK 18362).
    Wednesday, June 5, 2019 7:55 AM