c# - Having trouble setting visibility of control through DataTemplates -
so, i'm building order tracking app different user accounts, of whom have less need-to-know others. means controls displayed accounts, , hidden others.
the datacontext window set order class, , data binding within text fields works in regards displaying properties specific order. however, datatemplates , triggers i've made don't seem doing @ all, , i'm not entirely sure why. i've looked on web , can't seem find why it's not working. here's xaml:
<label name="statuslabeltext" content="status:" fontsize="15" dockpanel.dock="top"> <label.resources> <datatemplate datatype="x:type local:order"> <datatemplate.triggers> <datatrigger binding="{binding path=selectedaccount}" value="color correct"> <setter property="visibility" value="hidden"></setter> </datatrigger> </datatemplate.triggers> </datatemplate> </label.resources> </label>
i suspect want hide label
in case selectedaccount
value color correct
.
you need style , not template if assumption correct can done this:
<label name="statuslabeltext" content="status:" fontsize="15" dockpanel.dock="top"> <label.style> <style targettype="label"> <style.triggers> <datatrigger binding="{binding path=selectedaccount}" value="color correct"> <setter property="visibility" value="collapsed"/> </datatrigger> </style.triggers> </style> </label.style> </label>
on side note, should use collapsed
instead of hidden
set visibility of control in case don't want label take size when it's not visible on gui. read more here.
Comments
Post a Comment