wpf - How to set a default empty binding unless the value is different from 0? -


when set binding <textblock text="{binding position}"..> ui gives 0 int defaults 0. first, how stop showing result unless position not 0 ? second, if position = 5, ui shows result, if goes 0 again, stop showing result again

in c#, int value type, meaning can never null. can use nullable<int> transform nullable, defaults null.

a shortcut question mark. if define position int? position should result you're after.

edit: didn't see request value disappearing after position = 0 again.

a alternative use ivalueconverter proposed in comments.

otherwise, use trigger, so:

<style targettype="textblock"        text="{binding position}">         <style.triggers>             <trigger property="text" value="0">                 <setter property="visibility" value="collapsed" />             </trigger>         </style.triggers> </style> 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -