Hi Stephen,

One way to approach this, instead of custom panels, would be to use styles and 
a canvas.

<Style TargetType="ListBoxItem">
   <Setter Property="Canvas.Left" Value="{Binding Path=X}" >
   <Setter Property="Canvas.Top" Value="{Binding Path=Y}" >

<ListBox>
   <ListBox.ItemsPanel>
      <ItemsPanelTemplate>
         <Canvas />

The ListBox will then generate ListBoxItems and add them to the canvas, and the 
canvas will get the Left and Top from the binding you set up in the style. If 
calculation is needed you could use a converter in the setter.

Paul


From: [email protected] [mailto:[email protected]] On 
Behalf Of Stephen Price
Sent: Monday, 22 March 2010 2:27 PM
To: ozWPF
Subject: customised panel wrapped in listbox

Hey all,

I've got a custom Panel which lays out its children based on the X, Y 
properties of the children objects. It was working nicely. I then added the 
custom panel to a listbox via the ItemsPanelTemplate.
I had to modify the custom panel's arrangeoverride as the InternalChildren were 
wrapped in ListboxItems.

The issue I'm having now is that the items are no longer draggable. The item' 
underlaying properties change when dragging so its picking up the mouse events 
and changing the values. The issue seems to be that the dependency properties 
used to notify the parent panel it needed to redraw, (via the  
FrameworkPropertyMetadataOptions.AffectsRender parameter) and now that its 
wrapped up in the listbox is no longer redrawing the custom Panel.

Hopefully I've described what i'm doing well enough that someone can tell me 
how to make the panel (or its children) tell it needs to do the Layout routines 
again. It works once (initial draw) but then dragging items doesn't work 
(Listbox isnt aware that its children have changed and needs to relayout.)

thanks in advance!
Stephen
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf

Reply via email to