Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
How to specify an empty string as Target null value in xaml

From here https://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.targetnullvalue(v=vs.110).aspx,

It gives an example of specifying 'TargetNullValue':

<TextBox Width="150"
         Text="{Binding Source={StaticResource object2}, 
  Path=PropertyB, BindingGroupName=bindingGroup, 
  TargetNullValue=please enter a string}" />

My question is how can I specify an empty string for TargetNullValue?

I have tried "TargetNullValue= }" (there is a space between = and }, but that does not work, the target null value is null, instead of an empty string.

Thank you.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can use x:Static in the xaml and define the string.empty there.

<TextBox Width="150"
         Text="{Binding Source={StaticResource object2}, 
  Path=PropertyB, BindingGroupName=bindingGroup, 
  TargetNullValue={x:Static system:String.Empty} }" />

You'll need to add the appropriate namespace to the xaml as needed. VS should do this for you though. Namespace required is

xmlns:system="clr-namespace:System;assembly=mscorlib"
over 4 years ago · Santiago Trujillo Denunciar

0

I don't know why the answer saying to use '' is deleted, but it works fine for me:

<TextBox Text="{Binding NumberOfCats, TargetNullValue=''}" />
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda