Good idea, I'll look into setting that up it sounds useful. In the mean time, I've got a sort of work around. I put a property on my child element that holds a reference to the parent panel. (wired up once, and then I can Invalidate the visuals when a property changes). It feels less of a hack than doing it when the mouse moves.
thanks all for the input (especially Paul who "just knows") Stephen On Mon, Mar 22, 2010 at 9:35 PM, Joseph Cooney <[email protected]> wrote: > If you haven't done so already one thing I've often found useful in these > instances (other than asking Paul, who usually "just knows") is to get the > WPF symbols from the MS symbol server and just step through the WPF code at > run-time. It usually turns the exercise into more like normal debugging and > less like guess-work. > > Joseph > > > On Mon, Mar 22, 2010 at 4:48 PM, Stephen Price > <[email protected]>wrote: > >> That would work if I was only going to use this in a listbox. The reason >> I've gone with a Panel is that the Panel lays out its children, and I'm not >> locked into a Listbox. The Listbox can use a Panel for its layout (ie >> Canvas, StackPanel or my own Custom Panel). It seems like an important thing >> to be able to notify the panel that its contents have changed and it needs >> to redraw. How do the existing panels do it?) >> >> I was doing this without a listbox, and then just added the items in my >> viewmodel property manually to the children of the FloatPanel. (couldn't >> bind to it as the children property of a Panel is readonly) I've also tried >> the FrameworkPropertyMetadataOptions.AffectsParentArrange options too with >> no success. I was surprised when that didn't work as it seems exactly what >> it was written for. >> >> I've come up with a nasty work around, i'm invalidating the layout of the >> FloatPanel in the ItemsPanelTemplate on mouse move when the mouse button is >> down. The child items should be able to notify the parent panel its layout >> has changed. Oh, I've also posted this on StackOverflow here >> http://stackoverflow.com/questions/2490285/how-to-invalidate-layout-of-listbox-from-custom-children >> >> Thanks for the reply, I may look into seeing if I can get a listboxitem >> style to bind to the underlaying child item (ie use your example with my >> Panel instead of Canvas as you suggest). Not ready to abandon my panel just >> yet, it does other stuff too. >> >> cheers, >> Stephen >> >> On Mon, Mar 22, 2010 at 2:17 PM, Paul Stovell >> <[email protected]>wrote: >> >>> 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 >>> >>> >> >> _______________________________________________ >> ozwpf mailing list >> [email protected] >> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf >> >> > > _______________________________________________ > ozwpf mailing list > [email protected] > http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf > >
_______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
