.net - Making a WrapPanel respect his parent's width -


ok here's code. note stackpanel directly in usercontrol.

<stackpanel orientation="horizontal">     <scrollviewer     width="450"     verticalscrollbarvisibility="auto"     horizontalscrollbarvisibility="disabled"     >         <rectangle width="400" height="4000" fill="blanchedalmond"></rectangle>     </scrollviewer>      <scrollviewer     verticalscrollbarvisibility="auto"     horizontalscrollbarvisibility="disabled"     >      <itemscontrol         borderbrush="green"         borderthickness="2"         itemssource="{binding path=myobservablecollection}"         itemtemplate="{staticresource fattemplate}"         >         <itemscontrol.itemspanel>             <itemspaneltemplate>                 <wrappanel                          orientation="horizontal"                         >                 </wrappanel>             </itemspaneltemplate>         </itemscontrol.itemspanel>     </itemscontrol>  </scrollviewer> </stackpanel> 

(code edited)

note rectangle ther beacause content of scroll viewer irrevelant.

the problem : wrappanel expand horizontally , dosent wrap...

i found few solutions.

1- giving absolute width wrappanel (but dosent resize window).

2- binding width it's parent width either itemscontrol or scrollviewer (scrollviewer worked better in limited situation one).

width="{binding relativesource=     {relativesource findancestor,     ancestortype={x:type scrollviewer}},     path=actualwidth}" 

the problem technique if got control next in stackpanel or in grid, need bind it's parent size minus control next it. ther come hard stuff. builded converter apply mathematical operations on number recived substract guiven width it's parent width :

width="{binding relativesource= {relativesource findancestor, ancestortype={x:type usercontrol}}, path=actualwidth, converter={staticresource convertisseur_size_wxyz},  converterparameter=-260}" 

but still, since cant bind value pass converterparameter,

converterparameter={binding ...} (dosent work) 

i want able resize app wrappanel , scrollviewer resizing well,

i want usercontrol maintainable,

i code cleaner theses big binding expression relies on parent control's type.

so question : what's better solution?

note : if isint clear, can add detail.

why wrap when scrollviewer allows horizontal scrolling? should disable horizontal scrolling in scrollviewer:

<scrollviewer verticalscrollbarvisibility="auto" horizontalscrollbarvisibility="disabled"> 

edit after edit: it's because stackpanel oriented horizontally. horizontally-oriented stackpanel give whatever width child requests - won't constrain @ all. use right panel, , you'll fine. want grid 2 columns.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -