Set value to null in WPF binding

I am using .NET 3.5 SP1 so it’s very simple:

<TextBox Text="{Binding Price, TargetNullValue=""}"/>

Which stands for (thanks Gregor for your comment):

<TextBox Text="{Binding Price, TargetNullValue={x:Static sys:String.Empty}}"/>

sys is the imported xml namespace for System in mscorlib:

xmlns:sys="clr-namespace:System;assembly=mscorlib"

Hope that helped.

Leave a Comment