x:Static in conjunction with XamlCompilation results in XFC0101 compile time error.
See original GitHub issueDescription
The following XAML snippet will result in failed compilation on a NOOB application as compiled XAML is the default for MAUI apps. Simply add it as a binding to any property.
<Binding Path="Foo" TargetNullValue="{x:Static Binding.DoNothing}"/>
Specifically the following error code is returned:
Error XFC0101 x:Static: unable to find a public -- or accessible internal -- static field, static property, const or enum value named "DoNothing" in "Binding".
It would appear that string “Binding” is somehow special during type lookup in XAML compilation operations as using another static field from the same namespace Microsoft.Maui.Controls works without error:
<Binding Path="Foo" TargetNullValue="{x:Static Application.AccentColor}"/>
Steps to Reproduce
- Create a new MAUI app
- Add the binding that causes error to one of the Image elements in MainPage.xaml
<Image.AnchorX>
<Binding Path="Foo" TargetNullValue="{x:Static Binding.DoNothing}"/>
</Image.AnchorX>
- Compile
Link to public reproduction project repository
https://github.com/bakerhillpins/Issues/tree/NetMauiIssue11833
Version with bug
6.0 Release Candidate 2 or older
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows, macOS, Other (Tizen, Linux, etc. not supported by Microsoft directly)
Affected platform versions
All
Did you find any workaround?
This is a Compiled Bindings issue. There are the following workarounds:
- Add the
[XamlCompilation(XamlCompilationOptions.Skip)]Attribute to the View class in the .xaml.cs file. - Create a static field/property that exists in your own namespace, reference that from the binding, and have the field redirect to the
Microsoft.Maui.Controls.Binding.DoNothingfield.
<Binding Path="Foo" TargetNullValue="{x:Static views:Binding.DoNothing}" />
namespace MyProject.Views
{
public sealed class Binding
{
public static readonly object DoNothing = Microsoft.Maui.Controls.Binding.DoNothing;
}
}
Relevant log output
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
in XAML, Binding resolves to… BindingExtension 🤦
As far as I can tell in the code,
Binding.DoNothingis just for cases when usingIMultiValueConverterorMultiBinding. XamlC still should not fail, but I am not sure usingBinding.DoNothingis what you are looking for. It is used only in multi-bindings.Also note to future people: even
Static(not justx:Static) gives the same error.