wpf - Is that possible to have a conditional setter, more than 0 value? -


how assign setter conditional value such more 0? need hide object if value not 0. best way it? ifeas highly appreciated.

xaml example of datatrigger:

<datatrigger binding="{binding role.count}" value="0">     <setter targetname="counts" property="visibility" value="hidden" /> </datatrigger> 

write value converter, isgreaterthanzero, write xaml as,

<window.resources>          <local:isgreaterthanzero x:key="isgreaterthanzero"/> </window.resources>  <datatrigger binding="{binding role.count, converter={staticresource isgreaterthanzero}" value="true">     <setter targetname="counts" property="visibility" value="hidden" /> </datatrigger> 

and isgreaterthanzero can written as,

public class isgreaterthanzero: ivalueconverter {          #region ivalueconverter members         public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture)         {             return int32.parse(value string) > 0;         }          public object convertback(object value, type targettype, object parameter, system.globalization.cultureinfo culture)         {             throw new notimplementedexception() ;//"presenterconverter.convertback() not implemented!");         }         #endregion } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -