Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Cómo especificar una cadena vacía como valor nulo de destino en xaml

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

Da un ejemplo de especificar 'TargetNullValue':

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

Mi pregunta es ¿cómo puedo especificar una cadena vacía para TargetNullValue?

"TargetNullValue= }" (hay un espacio entre = y }, pero eso no funciona, el valor nulo objetivo es nulo, en lugar de una cadena vacía.

Gracias.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puede usar x:Static en el xaml y definir el string.empty allí.

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

Deberá agregar el espacio de nombres apropiado al xaml según sea necesario. Sin embargo, VS debería hacer esto por ti. El espacio de nombres requerido es

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

0

No sé por qué se elimina la respuesta que dice usar '' , pero funciona bien para mí:

 <TextBox Text="{Binding NumberOfCats, TargetNullValue=''}" />
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!