c# - Change visibility of GridView Items using binding -


how can change gridviewitems visibility using property binding?

i can't create observablecollection filter 1 using itemssource. tried use gridview.itemcontainerstyle change gridviewitem style seems not work binding (although works if set value collapsed).

<gridview.itemcontainerstyle>     <style targettype="gridviewitem">         <setter property="visibility" value="{binding isvisible, converter={staticresource booleantovisibilityconverter}}" />     </style> </gridview.itemcontainerstyle> 

i tried use datatemplateselector. can hide items binding there gaps on gridview because itemcontainer still there , does not collapse.

i need gridview items collapsed , not hidden.

edit: why want rid of filtered observablecollections?

i trying mirror 2 gridviews , 1 listview same itemssource , selecteditem both binded viewmodel properties items , current. without filters works expect without selectionchanged events, only two-way binding.

but gridview/listview must have differences such available items selection , datatemplates. using filtered collections brought me problems.

for example:

  • gridview1 has items 1, 2 , 3
  • gridview2 has items 1 , 3
  • i select item 1 of gridview1
  • i select item 2 of gridview1

when select item 1 gets selected on gridview2. now. when select item 2, item 1 maintains selected on gridview2. gridview2 should without selection if force it deselect item 2 of gridview2 since selecteditem of both two-way binded.

i hope understandable because english not native language.

so first off, there style isn't working because winrt doesn't support bindings in setters apparently (see here). article mention workaround issue , work (although have not tried myself).

in case doesn't pan out, gridview itemscontrol should able manually override layout setting itemspanel property custom panel. make small custom panel use in conjunction datatemplateselector working collapsing content of gridviewitems:

class custompanel : panel {     //children of panel should of type gridviewitem (which itemcontainer     //itemscontrol)      protected override size measureoverride(size availablesize)     {         foreach (var child in this.children)         {             var interior = (uielement)visualtreehelper.getchild(child, 0);             interior.measure(availablesize);              if (interior.desiredsize.width == 0 && interior.desiredsize.height == 0)                 //skip item             else             {                 child.measure(availablesize);                 //update total measure of panel child.desiredsize...             }              //return total calculated size         }     }      protected size override arrangeoverride(size finalsize)     {         foreach (var child in this.children)         {             var interior = (uielement)visualtreehelper.getvisualchild(child, 0);              if (interior.desiredsize.width == 0 || interior.desiredsize.height == 0)                 //skip item             else                 //call child.arrange appropriate arguments , update total size                 //used...              //return total size used         }     } } 

this code cleaned somewhat, should able resolve issue of dealing empty gridviewitems showing up.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -