c# - how to trigger visibility change to child controls with a trigger -
i have databound listbox thet generates items in datatemplate of type wrappanel other controls within it. have behavior to, when change visibility affect differently controls within wrappanel
<wrappanel orientation="horizontal" tag="{binding .}" horizontalalignment="stretch" visibility="{binding editmode, converter={staticresource visibilityconverter}}"> <label width="150" content="{binding path=avaiableattribute.text}" name="lblname"/> <label width="150" content="{binding path=informationitem.itemstring, mode=twoway, updatesourcetrigger=propertychanged}" initialized="label_initialized" name="lbltext" /> <contentpresenter minwidth="200" maxheight="200" content="{binding ., converter={staticresource informationitemconverter}, mode=twoway}" horizontalalignment="stretch" name="cpvalue" initialized="contentpresenter_initialized"/> <wrappanel.style> <style targettype="{x:type wrappanel}"> <style.triggers> <trigger property="visibility" value="visible" > <trigger.setters> <setter targetname="lbltext" property="visibility" value="collapsed" /> <setter targetname="cpvalue" property="visibility" value="visible" /> </trigger.setters> </trigger> </style.triggers> </style> </wrappanel.style> </wrappanel>
i following build error
the property 'targetname' not represent valid target 'setter' because element
when using setter
, targetname
applies elements in template
. means trigger
has exist in datatemplate
or controltemplate
. easiest way want create own ivalueconverter
inverse of booleantovisibilityconverter
(ie return visibility.collapsed
when value true).
Comments
Post a Comment