xaml - Windows Phone 8.1 ListView item visibility depending on some condition -


i'm developing windows phone 8.1 application using c#/xaml. main view of application contains windows.ui.xaml.controls.listview class populated items (the result of search query).

when users taps item additional information pane (extendedinfopanel) item should appear, this item (i.e. one item @ time should expose additional information).

i played customizing of <visualstategroup x:name="selectionstates"> editing copy of default itemcontainerstyle without success. here code (only relevant parts):

<style x:key="listviewitemstyle1" targettype="listviewitem">     <visualstategroup x:name="selectionstates">         <visualstate x:name="unselected"/>         <visualstate x:name="selectedunfocused">             <storyboard>                 <objectanimationusingkeyframes duration="0" storyboard.targetproperty="visibility" storyboard.targetname="extendedinfopanel">                     <discreteobjectkeyframe keytime="0" value="visible"/>                 </objectanimationusingkeyframes>             </storyboard>         </visualstate>     </visualstategroup> </style> 
<listview     x:name="mylist"     margin="0,0,0,0"     isitemclickenabled="false"     itemssource="{binding source={staticresource mydatasource}}"     selectionmode="single"     itemtemplate="{staticresource mysongdatatemplate}"     itemcontainerstyle="{staticresource listviewitemstyle1}"> </listview> 

running snippet above ends in windows.ui.xaml.unhandledexceptioneventargs exception being thrown in application message:

cannot resolve targetname extendedinfopanel.

could give me hints how can achieve needed behavior?

when have named elements in datatemplate cannot access them name outside of data template. reason , method access element explained here jerry nixon.

in short can navigate visual tree , find extendedinfopanel element , change it's visibility. however, in question want 1 item display it's details. means should search visual tree other extendedinfopanel elements , hide them. doesn't sound effective.

my approach more mvvm like. in model, provide boolean isvisible property class associated extendedinfopanel , bind visibility of element.

then on tap event of list cast datacontext of tapped item model class , change isvisible property tapped element , other elements in collection. tip: need observablecollection changes propagated ui. alternatively need implement inotifypropertychanged.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -