pixelsense - ScatterViewItem custom size -



pixelsense - ScatterViewItem custom size -

i develop surface app using mvvm pattern. have different views , want place them 1 scatterview. want scatterviewitem size correspond size of views?

code example:

<datatemplate datatype="{x:type vm:pointlistviewmodel}"> <grid> <v:pointlistview> </v:pointlistview> </grid> </datatemplate> <datatemplate datatype="{x:type vm:bluetoothdevicesviewmodel}"> <grid> <v:bluetoothdevicesview></v:bluetoothdevicesview> </grid> </datatemplate>

....

<s:scatterview grid.rowspan="3" datacontext="{binding path=workspaces}" itemssource="{binding}" itemtemplate="{binding}" cliptobounds="true" allowdrop="true"> </s:scatterview>

... code works fine views have same size. tried configure scatterviewitem style like:

<style basedon="{staticresource {x:type s:scatterviewitem}}" targettype="{x:type s:scatterviewitem}"> <setter property="height" value="auto" /> <setter property="width" value="auto" /> </style>

but doesn't work.

update: i've turned reply code project article here: http://www.codeproject.com/kb/wpf/scatterviewsizing.aspx - check out more details , total sample code

this tricky right. had problem while ago , tried many different approaches - implemented own scatterviewitem handle automatic sizing - never found 100% working solution.

the solution did settle for, solved main problem of getting initial size right create custom command used attached properties set size of parent scatterviewitem when it's created. total code way big place here, i'll seek explain core of started.

so whenever added stuff scatterview (through databinding), itemtemplate set content of scatterviewitem command called "popupwindow" (which derived usercontrol). popupwindow defined attached property called initialsizerequest (of type size) in kid element. in loaded event handler search visual tree upwards locate scatterviewitem , set size accordingly.

the generated visual tree this:

scatterview '- scatterviewitem '- popupwindow '- actualcontent (datatemplate)

on actual content, declare size so:

<usercontrol x:class="...." ... localview:popupwindow.initialsizerequest="450,400" />

to hold of actual content popupwindow, used code below (error checking omitted). executed in loaded event of popupwindow:

// guihelpers helper class built find elements in visual tree // c_contentholder contentcontrol hold actual content var presenter = guihelpers.getchildobject<contentpresenter>(c_contentholder); // seems it's safe assume contentpresenter have 1 // kid , kid visual representation of actual content. var kid = visualtreehelper.getchild(presenter, 0); size requestedsize = popupwindow.getinitialsizerequest(child); // utilize requestedsize set size of parent scatterviewitem var svi = guihelpers.getparentobject<scatterviewitem>(this, false); svi.width = requestedsize.width; svi.height = requestedsize.height;

hopefully should started. please comment if need farther explainations.

pixelsense scatterview

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -