wpf - Show/Hide items in itemscontrol on condition -
i have itemscontrol using display list of start information sent timing system.
i need able "switch off"/stop displaying set of lane info if lane number isn't showing (if it's null or blank) , if timer sends info switch lane on show data again.
i can't set delete because timer sends information , except lane number reappear again.
is possible show/hide items on condition?
what happening
lanes 1 ------ 2 ------ ------ <- other info remains 4 ------
what want happen
lanes 1 ------ 2 ------ 4 ------
here sample of itemscontrol code
<itemscontrol itemssource="{binding cheat.swimlist}" margin="10,0" horizontalalignment="left" verticalalignment="top"> <itemscontrol.template> <controltemplate targettype="itemscontrol"> <stackpanel> <stackpanel orientation="horizontal"> <label content="lane" /> <label content="pos" /> <label content="swimmer" /> <label content="club" /> <label content="time" /> </stackpanel> <itemspresenter/> </stackpanel> </controltemplate> </itemscontrol.template> <itemscontrol.itemspanel> <itemspaneltemplate> <stackpanel/> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <grid> <grid.columndefinitions> <columndefinition width="35" /> <columndefinition width="30" /> <columndefinition width="150" /> <columndefinition width="50" /> <columndefinition width="80" /> </grid.columndefinitions> <label grid.column="0" content="{binding lanenumber}" /> <label grid.column="1" content="{binding position}" /> <label grid.column="2" content="{binding swimmer}" /> <label grid.column="3" content="{binding club}" /> <label grid.column="4" content="{binding time}" /> </grid> </stackpanel> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol>
if there way set content = ""
other data based off lanenumber believe work, because can bring bindings.
i'm new wpf detail helpful many thanks!
why don't try using visibility
property? have create public property in mvvm or code behind , bind element want hide.
<stackpanel visibility="{binding showelement, converter={staticresource visibilityconverter}, mode=twoway}">
by setting boolean value of showelement, can hide or show stackpanel.