wpf controls - listbox wraps properly when parented in a vertical orientation stackpanel, but fails for horizontal -



wpf controls - listbox wraps properly when parented in a vertical orientation stackpanel, but fails for horizontal -

the next xaml explains trying do. listbox wraps want when parents orientation set vertical, want popout on left, , listbox wrapping behaves unexpectedly. i've seen other posts binding parent's size, using value converters etc math, not convinced. why would/should changing container 2 parents above break listboxes logic?

<window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:system;assembly=mscorlib" title="mainwindow" height="421" width="602"> <window.resources> <objectdataprovider x:key="orientationenum" methodname="getvalues" objecttype="{x:type system:enum}"> <objectdataprovider.methodparameters> <x:type typename="orientation"/> </objectdataprovider.methodparameters> </objectdataprovider> <style x:key="horizontalwraplistbox" targettype="listbox"> <style.setters> <setter property="itemspanel"> <setter.value> <itemspaneltemplate> <wrappanel orientation="horizontal" /> </itemspaneltemplate> </setter.value> </setter> <setter property="horizontalalignment" value="left"/> <setter property="template"> <setter.value> <controltemplate targettype="listbox"> <scrollviewer horizontalscrollbarvisibility="disabled" > <itemspresenter /> </scrollviewer> </controltemplate> </setter.value> </setter> </style.setters> </style> </window.resources> <grid> <stackpanel name="stackpanel1" orientation="vertical" > <expander > <grid background="#fffffdeb" > <stackpanel width="200" > <slider name="slider1" minimum="50" maximum="250"/> <combobox itemssource="{binding source={staticresource orientationenum}}" selecteditem="{binding elementname=stackpanel1,path=orientation}"/> </stackpanel> </grid> </expander> <grid name="parentinggrid"> <listbox horizontalalignment="stretch" datacontext="{binding elementname=slider1}" style="{staticresource horizontalwraplistbox}" > <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> <rectangle width="{binding value}" height="{binding value}" fill="#ffaa5353" margin="4" /> </listbox> </grid> </stackpanel> </grid>

wpf-controls

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -